use std::collections::HashMap; use std::cell::RefCell; use std::default::Default; use std::collections::BTreeSet; use std::error::Error as StdError; use serde_json as json; use std::io; use std::fs; use std::mem; use hyper::client::connect; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::time::sleep; use tower_service; use serde::{Serialize, Deserialize}; use crate::{client, client::GetToken, client::serde_with}; // ############## // UTILITIES ### // ############ /// Identifies the an OAuth2 authorization scope. /// A scope is needed when requesting an /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)] pub enum Scope { /// See, edit, create, and delete all of your Google Drive files Full, /// See, create, and delete its own configuration data in your Google Drive Appdata, /// View your Google Drive apps AppReadonly, /// See, edit, create, and delete only the specific Google Drive files you use with this app File, /// View and manage metadata of files in your Google Drive Metadata, /// See information about your Google Drive files MetadataReadonly, /// View the photos, videos and albums in your Google Photos PhotoReadonly, /// See and download all your Google Drive files Readonly, /// Modify your Google Apps Script scripts' behavior Script, } impl AsRef for Scope { fn as_ref(&self) -> &str { match *self { Scope::Full => "https://www.googleapis.com/auth/drive", Scope::Appdata => "https://www.googleapis.com/auth/drive.appdata", Scope::AppReadonly => "https://www.googleapis.com/auth/drive.apps.readonly", Scope::File => "https://www.googleapis.com/auth/drive.file", Scope::Metadata => "https://www.googleapis.com/auth/drive.metadata", Scope::MetadataReadonly => "https://www.googleapis.com/auth/drive.metadata.readonly", Scope::PhotoReadonly => "https://www.googleapis.com/auth/drive.photos.readonly", Scope::Readonly => "https://www.googleapis.com/auth/drive.readonly", Scope::Script => "https://www.googleapis.com/auth/drive.scripts", } } } impl Default for Scope { fn default() -> Scope { Scope::AppReadonly } } // ######## // HUB ### // ###### /// Central instance to access all DriveHub related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// use drive2::api::File; /// use drive2::{Result, Error}; /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. /// let secret: oauth2::ApplicationSecret = Default::default(); /// // Instantiate the authenticator. It will choose a suitable authentication flow for you, /// // unless you replace `None` with the desired Flow. /// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about /// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and /// // retrieve them from storage. /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = File::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().patch(req, "fileId") /// .use_content_as_indexable_text(false) /// .update_viewed_date(false) /// .timed_text_track_name("duo") /// .timed_text_language("vero") /// .supports_team_drives(false) /// .supports_all_drives(false) /// .set_modified_date(true) /// .remove_parents("vero") /// .pinned(true) /// .ocr_language("Lorem") /// .ocr(true) /// .new_revision(false) /// .modified_date_behavior("accusam") /// .include_permissions_for_view("takimata") /// .include_labels("consetetur") /// .enforce_single_parent(false) /// .convert(false) /// .add_parents("amet.") /// .doit().await; /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits /// Error::HttpError(_) /// |Error::Io(_) /// |Error::MissingAPIKey /// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) /// |Error::BadRequest(_) /// |Error::FieldClash(_) /// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } /// # } /// ``` #[derive(Clone)] pub struct DriveHub { pub client: hyper::Client, pub auth: Box, _user_agent: String, _base_url: String, _root_url: String, } impl<'a, S> client::Hub for DriveHub {} impl<'a, S> DriveHub { pub fn new(client: hyper::Client, auth: A) -> DriveHub { DriveHub { client, auth: Box::new(auth), _user_agent: "google-api-rust-client/5.0.4".to_string(), _base_url: "https://www.googleapis.com/drive/v2/".to_string(), _root_url: "https://www.googleapis.com/".to_string(), } } pub fn about(&'a self) -> AboutMethods<'a, S> { AboutMethods { hub: &self } } pub fn apps(&'a self) -> AppMethods<'a, S> { AppMethods { hub: &self } } pub fn changes(&'a self) -> ChangeMethods<'a, S> { ChangeMethods { hub: &self } } pub fn channels(&'a self) -> ChannelMethods<'a, S> { ChannelMethods { hub: &self } } pub fn children(&'a self) -> ChildMethods<'a, S> { ChildMethods { hub: &self } } pub fn comments(&'a self) -> CommentMethods<'a, S> { CommentMethods { hub: &self } } pub fn drives(&'a self) -> DriveMethods<'a, S> { DriveMethods { hub: &self } } pub fn files(&'a self) -> FileMethods<'a, S> { FileMethods { hub: &self } } pub fn parents(&'a self) -> ParentMethods<'a, S> { ParentMethods { hub: &self } } pub fn permissions(&'a self) -> PermissionMethods<'a, S> { PermissionMethods { hub: &self } } pub fn properties(&'a self) -> PropertyMethods<'a, S> { PropertyMethods { hub: &self } } pub fn replies(&'a self) -> ReplyMethods<'a, S> { ReplyMethods { hub: &self } } pub fn revisions(&'a self) -> RevisionMethods<'a, S> { RevisionMethods { hub: &self } } pub fn teamdrives(&'a self) -> TeamdriveMethods<'a, S> { TeamdriveMethods { hub: &self } } /// Set the user-agent header field to use in all requests to the server. /// It defaults to `google-api-rust-client/5.0.4`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { mem::replace(&mut self._user_agent, agent_name) } /// Set the base url to use in all requests to the server. /// It defaults to `https://www.googleapis.com/drive/v2/`. /// /// Returns the previously set base url. pub fn base_url(&mut self, new_base_url: String) -> String { mem::replace(&mut self._base_url, new_base_url) } /// Set the root url to use in all requests to the server. /// It defaults to `https://www.googleapis.com/`. /// /// Returns the previously set root url. pub fn root_url(&mut self, new_root_url: String) -> String { mem::replace(&mut self._root_url, new_root_url) } } // ############ // SCHEMAS ### // ########## /// An item with user information and settings. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get about](AboutGetCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct About { /// Information about supported additional roles per file type. The most specific type takes precedence. #[serde(rename="additionalRoleInfo")] pub additional_role_info: Option>, /// Whether the user can create shared drives. #[serde(rename="canCreateDrives")] pub can_create_drives: Option, /// Deprecated: Use `canCreateDrives` instead. #[serde(rename="canCreateTeamDrives")] pub can_create_team_drives: Option, /// The domain sharing policy for the current user. Possible values are: * `allowed` * `allowedWithWarning` * `incomingOnly` * `disallowed` #[serde(rename="domainSharingPolicy")] pub domain_sharing_policy: Option, /// A list of themes that are supported for shared drives. #[serde(rename="driveThemes")] pub drive_themes: Option>, /// The ETag of the item. pub etag: Option, /// The allowable export formats. #[serde(rename="exportFormats")] pub export_formats: Option>, /// List of additional features enabled on this account. pub features: Option>, /// The palette of allowable folder colors as RGB hex strings. #[serde(rename="folderColorPalette")] pub folder_color_palette: Option>, /// The allowable import formats. #[serde(rename="importFormats")] pub import_formats: Option>, /// A boolean indicating whether the authenticated app is installed by the authenticated user. #[serde(rename="isCurrentAppInstalled")] pub is_current_app_installed: Option, /// This is always `drive#about`. pub kind: Option, /// The user's language or locale code, as defined by BCP 47, with some extensions from Unicode's LDML format (http://www.unicode.org/reports/tr35/). #[serde(rename="languageCode")] pub language_code: Option, /// The largest change id. #[serde(rename="largestChangeId")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub largest_change_id: Option, /// List of max upload sizes for each file type. The most specific type takes precedence. #[serde(rename="maxUploadSizes")] pub max_upload_sizes: Option>, /// The name of the current user. pub name: Option, /// The current user's ID as visible in the permissions collection. #[serde(rename="permissionId")] pub permission_id: Option, /// The amount of storage quota used by different Google services. #[serde(rename="quotaBytesByService")] pub quota_bytes_by_service: Option>, /// The total number of quota bytes. This is only relevant when quotaType is LIMITED. #[serde(rename="quotaBytesTotal")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub quota_bytes_total: Option, /// The number of quota bytes used by Google Drive. #[serde(rename="quotaBytesUsed")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub quota_bytes_used: Option, /// The number of quota bytes used by all Google apps (Drive, Picasa, etc.). #[serde(rename="quotaBytesUsedAggregate")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub quota_bytes_used_aggregate: Option, /// The number of quota bytes used by trashed items. #[serde(rename="quotaBytesUsedInTrash")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub quota_bytes_used_in_trash: Option, /// The type of the user's storage quota. Possible values are: * `LIMITED` * `UNLIMITED` #[serde(rename="quotaType")] pub quota_type: Option, /// The number of remaining change ids, limited to no more than 2500. #[serde(rename="remainingChangeIds")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub remaining_change_ids: Option, /// The id of the root folder. #[serde(rename="rootFolderId")] pub root_folder_id: Option, /// A link back to this item. #[serde(rename="selfLink")] pub self_link: Option, /// Deprecated: Use `driveThemes` instead. #[serde(rename="teamDriveThemes")] pub team_drive_themes: Option>, /// The authenticated user. pub user: Option, } impl client::ResponseResult for About {} /// The apps resource provides a list of the apps that a user has installed, with information about each app’s supported MIME types, file extensions, and other details. Some resource methods (such as `apps.get`) require an `appId`. Use the `apps.list` method to retrieve the ID for an installed application. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get apps](AppGetCall) (response) /// * [list apps](AppListCall) (none) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct App { /// Whether the app is authorized to access data on the user's Drive. pub authorized: Option, /// The template url to create a new file with this app in a given folder. The template will contain {folderId} to be replaced by the folder to create the new file in. #[serde(rename="createInFolderTemplate")] pub create_in_folder_template: Option, /// The url to create a new file with this app. #[serde(rename="createUrl")] pub create_url: Option, /// Whether the app has drive-wide scope. An app with drive-wide scope can access all files in the user's drive. #[serde(rename="hasDriveWideScope")] pub has_drive_wide_scope: Option, /// The various icons for the app. pub icons: Option>, /// The ID of the app. pub id: Option, /// Whether the app is installed. pub installed: Option, /// This is always `drive#app`. pub kind: Option, /// A long description of the app. #[serde(rename="longDescription")] pub long_description: Option, /// The name of the app. pub name: Option, /// The type of object this app creates (e.g. Chart). If empty, the app name should be used instead. #[serde(rename="objectType")] pub object_type: Option, /// The template url for opening files with this app. The template will contain `{ids}` and/or `{exportIds}` to be replaced by the actual file ids. See Open Files for the full documentation. #[serde(rename="openUrlTemplate")] pub open_url_template: Option, /// The list of primary file extensions. #[serde(rename="primaryFileExtensions")] pub primary_file_extensions: Option>, /// The list of primary mime types. #[serde(rename="primaryMimeTypes")] pub primary_mime_types: Option>, /// The ID of the product listing for this app. #[serde(rename="productId")] pub product_id: Option, /// A link to the product listing for this app. #[serde(rename="productUrl")] pub product_url: Option, /// The list of secondary file extensions. #[serde(rename="secondaryFileExtensions")] pub secondary_file_extensions: Option>, /// The list of secondary mime types. #[serde(rename="secondaryMimeTypes")] pub secondary_mime_types: Option>, /// A short description of the app. #[serde(rename="shortDescription")] pub short_description: Option, /// Whether this app supports creating new objects. #[serde(rename="supportsCreate")] pub supports_create: Option, /// Whether this app supports importing from Docs Editors. #[serde(rename="supportsImport")] pub supports_import: Option, /// Whether this app supports opening more than one file. #[serde(rename="supportsMultiOpen")] pub supports_multi_open: Option, /// Whether this app supports creating new files when offline. #[serde(rename="supportsOfflineCreate")] pub supports_offline_create: Option, /// Whether the app is selected as the default handler for the types it supports. #[serde(rename="useByDefault")] pub use_by_default: Option, } impl client::Resource for App {} impl client::ResponseResult for App {} /// A list of third-party applications which the user has installed or given access to Google Drive. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list apps](AppListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AppList { /// List of app IDs that the user has specified to use by default. The list is in reverse-priority order (lowest to highest). #[serde(rename="defaultAppIds")] pub default_app_ids: Option>, /// The ETag of the list. pub etag: Option, /// The list of apps. pub items: Option>, /// This is always `drive#appList`. pub kind: Option, /// A link back to this list. #[serde(rename="selfLink")] pub self_link: Option, } impl client::ResponseResult for AppList {} /// Representation of a change to a file or shared drive. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get changes](ChangeGetCall) (response) /// * [get start page token changes](ChangeGetStartPageTokenCall) (none) /// * [list changes](ChangeListCall) (none) /// * [watch changes](ChangeWatchCall) (none) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Change { /// The type of the change. Possible values are `file` and `drive`. #[serde(rename="changeType")] pub change_type: Option, /// Whether the file or shared drive has been removed from this list of changes, for example by deletion or loss of access. pub deleted: Option, /// 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. pub drive: Option, /// The ID of the shared drive associated with this change. #[serde(rename="driveId")] pub drive_id: Option, /// The updated state of the file. Present if the type is file and the file has not been removed from this list of changes. pub file: Option, /// The ID of the file associated with this change. #[serde(rename="fileId")] pub file_id: Option, /// The ID of the change. #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub id: Option, /// This is always `drive#change`. pub kind: Option, /// The time of this modification. #[serde(rename="modificationDate")] pub modification_date: Option>, /// A link back to this change. #[serde(rename="selfLink")] pub self_link: Option, /// Deprecated: Use `drive` instead. #[serde(rename="teamDrive")] pub team_drive: Option, /// Deprecated: Use `driveId` instead. #[serde(rename="teamDriveId")] pub team_drive_id: Option, /// Deprecated: Use `changeType` instead. #[serde(rename="type")] pub type_: Option, } impl client::Resource for Change {} impl client::ResponseResult for Change {} /// A list of changes for a user. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list changes](ChangeListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChangeList { /// The ETag of the list. pub etag: Option, /// The list of changes. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched. pub items: Option>, /// This is always `drive#changeList`. pub kind: Option, /// The current largest change ID. #[serde(rename="largestChangeId")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub largest_change_id: Option, /// The starting page token for future changes. This will be present only if the end of the current changes list has been reached. #[serde(rename="newStartPageToken")] pub new_start_page_token: Option, /// A link to the next page of changes. #[serde(rename="nextLink")] pub next_link: Option, /// 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// A link back to this list. #[serde(rename="selfLink")] pub self_link: Option, } impl client::ResponseResult for ChangeList {} /// A notification channel used to watch for resource changes. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [watch changes](ChangeWatchCall) (request|response) /// * [stop channels](ChannelStopCall) (request) /// * [watch files](FileWatchCall) (request|response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Channel { /// The address where notifications are delivered for this channel. pub address: Option, /// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional. #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub expiration: Option, /// A UUID or similar unique string that identifies this channel. pub id: Option, /// Identifies this as a notification channel used to watch for changes to a resource, which is `api#channel`. pub kind: Option, /// Additional parameters controlling delivery channel behavior. Optional. pub params: Option>, /// A Boolean value to indicate whether payload is wanted. Optional. pub payload: Option, /// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions. #[serde(rename="resourceId")] pub resource_id: Option, /// A version-specific identifier for the watched resource. #[serde(rename="resourceUri")] pub resource_uri: Option, /// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional. pub token: Option, /// The type of delivery mechanism used for this channel. Valid values are "web_hook" or "webhook". #[serde(rename="type")] pub type_: Option, } impl client::RequestValue for Channel {} impl client::Resource for Channel {} impl client::ResponseResult for Channel {} /// A list of children of a file. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list children](ChildListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChildList { /// The ETag of the list. pub etag: Option, /// The list of children. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched. pub items: Option>, /// This is always `drive#childList`. pub kind: Option, /// A link to the next page of children. #[serde(rename="nextLink")] pub next_link: Option, /// The page token for the next page of children. This will be absent if the end of the children 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// A link back to this list. #[serde(rename="selfLink")] pub self_link: Option, } impl client::ResponseResult for ChildList {} /// A reference to a folder’s child. Some resource methods (such as `children.get`) require a `childId`. Use the `children.list` method to retrieve the ID of the child. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get children](ChildGetCall) (response) /// * [insert children](ChildInsertCall) (request|response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChildReference { /// Output only. A link to the child. #[serde(rename="childLink")] pub child_link: Option, /// The ID of the child. pub id: Option, /// Output only. This is always `drive#childReference`. pub kind: Option, /// Output only. A link back to this reference. #[serde(rename="selfLink")] pub self_link: Option, } impl client::RequestValue for ChildReference {} impl client::ResponseResult for ChildReference {} /// A comment on a file in Google Drive. Some resource methods (such as `comments.update`) require a `commentId`. Use the `comments.list` method to retrieve the ID for a comment in a file. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete comments](CommentDeleteCall) (none) /// * [get comments](CommentGetCall) (response) /// * [insert comments](CommentInsertCall) (request|response) /// * [list comments](CommentListCall) (none) /// * [patch comments](CommentPatchCall) (request|response) /// * [update comments](CommentUpdateCall) (request|response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Comment { /// A region of the document represented as a JSON string. For details on defining anchor properties, refer to [Add comments and replies](https://developers.google.com/drive/api/v2/manage-comments). pub anchor: Option, /// Output only. The author of the comment. The author's email address and permission ID will not be populated. pub author: Option, /// Output only. The ID of the comment. #[serde(rename="commentId")] pub comment_id: Option, /// The plain text content used to create this comment. This is not HTML safe and should only be used as a starting point to make edits to a comment's content. pub content: Option, /// The context of the file which is being commented on. pub context: Option, /// The date when this comment was first created. #[serde(rename="createdDate")] pub created_date: Option>, /// Output only. Whether this comment has been deleted. If a comment has been deleted the content will be cleared and this will only represent a comment that once existed. pub deleted: Option, /// Output only. The file which this comment is addressing. #[serde(rename="fileId")] pub file_id: Option, /// Output only. The title of the file which this comment is addressing. #[serde(rename="fileTitle")] pub file_title: Option, /// Output only. HTML formatted content for this comment. #[serde(rename="htmlContent")] pub html_content: Option, /// Output only. This is always `drive#comment`. pub kind: Option, /// The date when this comment or any of its replies were last modified. #[serde(rename="modifiedDate")] pub modified_date: Option>, /// Output only. Replies to this post. pub replies: Option>, /// Output only. A link back to this comment. #[serde(rename="selfLink")] pub self_link: Option, /// Output only. The status of this comment. Status can be changed by posting a reply to a comment with the desired status. * `open` - The comment is still open. * `resolved` - The comment has been resolved by one of its replies. pub status: Option, } impl client::RequestValue for Comment {} impl client::Resource for Comment {} impl client::ResponseResult for Comment {} /// A list of comments on a file in Google Drive. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list comments](CommentListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentList { /// The list of comments. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched. pub items: Option>, /// This is always `drive#commentList`. pub kind: Option, /// A link to the next page of comments. #[serde(rename="nextLink")] pub next_link: Option, /// 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// A link back to this list. #[serde(rename="selfLink")] pub self_link: Option, } impl client::ResponseResult for CommentList {} /// A comment on a file in Google Drive. Some resource methods (such as `replies.update`) require a `replyId`. Use the `replies.list` method to retrieve the ID for a reply. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get replies](ReplyGetCall) (response) /// * [insert replies](ReplyInsertCall) (request|response) /// * [patch replies](ReplyPatchCall) (request|response) /// * [update replies](ReplyUpdateCall) (request|response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentReply { /// Output only. The author of the reply. The author's email address and permission ID will not be populated. pub author: Option, /// The plain text content used to create this reply. This is not HTML safe and should only be used as a starting point to make edits to a reply's content. This field is required on inserts if no verb is specified (resolve/reopen). pub content: Option, /// The date when this reply was first created. #[serde(rename="createdDate")] pub created_date: Option>, /// Output only. Whether this reply has been deleted. If a reply has been deleted the content will be cleared and this will only represent a reply that once existed. pub deleted: Option, /// Output only. HTML formatted content for this reply. #[serde(rename="htmlContent")] pub html_content: Option, /// Output only. This is always `drive#commentReply`. pub kind: Option, /// The date when this reply was last modified. #[serde(rename="modifiedDate")] pub modified_date: Option>, /// Output only. The ID of the reply. #[serde(rename="replyId")] pub reply_id: Option, /// The action this reply performed to the parent comment. When creating a new reply this is the action to be perform to the parent comment. Possible values are: * `resolve` - To resolve a comment. * `reopen` - To reopen (un-resolve) a comment. pub verb: Option, } impl client::RequestValue for CommentReply {} impl client::ResponseResult for CommentReply {} /// A list of replies to a comment on a file in Google Drive. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list replies](ReplyListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentReplyList { /// The list of replies. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched. pub items: Option>, /// This is always `drive#commentReplyList`. pub kind: Option, /// A link to the next page of replies. #[serde(rename="nextLink")] pub next_link: Option, /// 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// A link back to this list. #[serde(rename="selfLink")] pub self_link: Option, } impl client::ResponseResult for CommentReplyList {} /// A restriction for accessing the content of the file. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ContentRestriction { /// Whether the content restriction can only be modified or removed by a user who owns the file. For files in shared drives, any user with `organizer` capabilities can modify or remove this content restriction. #[serde(rename="ownerRestricted")] pub owner_restricted: Option, /// 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. #[serde(rename="readOnly")] pub read_only: Option, /// Reason for why the content of the file is restricted. This is only mutable on requests that also set `readOnly=true`. pub reason: Option, /// Output only. The user who set the content restriction. Only populated if `readOnly` is true. #[serde(rename="restrictingUser")] pub restricting_user: Option, /// The time at which the content restriction was set (formatted RFC 3339 timestamp). Only populated if readOnly is true. #[serde(rename="restrictionDate")] pub restriction_date: Option>, /// Output only. Whether the content restriction was applied by the system, for example due to an esignature. Users cannot modify or remove system restricted content restrictions. #[serde(rename="systemRestricted")] pub system_restricted: Option, /// Output only. The type of the content restriction. Currently the only possible value is `globalContentRestriction`. #[serde(rename="type")] pub type_: Option, } impl client::Part for ContentRestriction {} /// Representation of a shared drive. Some resource methods (such as `drives.update`) require a `driveId`. Use the `drives.list` method to retrieve the ID for a shared drive. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete drives](DriveDeleteCall) (none) /// * [get drives](DriveGetCall) (response) /// * [hide drives](DriveHideCall) (response) /// * [insert drives](DriveInsertCall) (request|response) /// * [list drives](DriveListCall) (none) /// * [unhide drives](DriveUnhideCall) (response) /// * [update drives](DriveUpdateCall) (request|response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Drive { /// 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. #[serde(rename="backgroundImageFile")] pub background_image_file: Option, /// Output only. A short-lived link to this shared drive's background image. #[serde(rename="backgroundImageLink")] pub background_image_link: Option, /// Output only. Capabilities the current user has on this shared drive. pub capabilities: Option, /// 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`. #[serde(rename="colorRgb")] pub color_rgb: Option, /// The time at which the shared drive was created (RFC 3339 date-time). #[serde(rename="createdDate")] pub created_date: Option>, /// Whether the shared drive is hidden from default view. pub hidden: Option, /// Output only. The ID of this shared drive which is also the ID of the top level folder of this shared drive. pub id: Option, /// Output only. This is always `drive#drive` pub kind: Option, /// The name of this shared drive. pub name: Option, /// Output only. The organizational unit of this shared drive. This field is only populated on `drives.list` responses when the `useDomainAdminAccess` parameter is set to `true`. #[serde(rename="orgUnitId")] pub org_unit_id: Option, /// A set of restrictions that apply to this shared drive or items inside this shared drive. pub restrictions: Option, /// 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.insert` 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`. #[serde(rename="themeId")] pub theme_id: Option, } impl client::RequestValue for Drive {} impl client::Resource for Drive {} impl client::ResponseResult for Drive {} /// A list of shared drives. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list drives](DriveListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DriveList { /// The list of shared drives. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched. pub items: Option>, /// This is always `drive#driveList` pub kind: Option, /// 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for DriveList {} /// The metadata for a file. Some resource methods (such as `files.update`) require a `fileId`. Use the `files.list` method to retrieve the ID for a file. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [copy files](FileCopyCall) (request|response) /// * [delete files](FileDeleteCall) (none) /// * [empty trash files](FileEmptyTrashCall) (none) /// * [export files](FileExportCall) (none) /// * [generate ids files](FileGenerateIdCall) (none) /// * [get files](FileGetCall) (response) /// * [insert files](FileInsertCall) (request|response) /// * [list files](FileListCall) (none) /// * [list labels files](FileListLabelCall) (none) /// * [modify labels files](FileModifyLabelCall) (none) /// * [patch files](FilePatchCall) (request|response) /// * [touch files](FileTouchCall) (response) /// * [trash files](FileTrashCall) (response) /// * [untrash files](FileUntrashCall) (response) /// * [update files](FileUpdateCall) (request|response) /// * [watch files](FileWatchCall) (none) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct File { /// Output only. A link for opening the file in a relevant Google editor or viewer. #[serde(rename="alternateLink")] pub alternate_link: Option, /// Output only. Whether this file is in the Application Data folder. #[serde(rename="appDataContents")] pub app_data_contents: Option, /// Output only. Deprecated: Use `capabilities/canComment` instead. #[serde(rename="canComment")] pub can_comment: Option, /// Output only. Deprecated: Use `capabilities/canReadRevisions` instead. #[serde(rename="canReadRevisions")] pub can_read_revisions: Option, /// Output only. Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take. pub capabilities: Option, /// Restrictions for accessing the content of the file. Only populated if such a restriction exists. #[serde(rename="contentRestrictions")] pub content_restrictions: Option>, /// Whether the options to copy, print, or download this file, should be disabled for readers and commenters. #[serde(rename="copyRequiresWriterPermission")] pub copy_requires_writer_permission: Option, /// Output only. Deprecated: Use `capabilities/canCopy` instead. pub copyable: Option, /// Create time for this file (formatted RFC 3339 timestamp). #[serde(rename="createdDate")] pub created_date: Option>, /// Output only. A link to open this file with the user's default app for this file. Only populated when the drive.apps.readonly scope is used. #[serde(rename="defaultOpenWithLink")] pub default_open_with_link: Option, /// A short description of the file. pub description: Option, /// Output only. Short lived download URL for the file. This field is only populated for files with content stored in Google Drive; it is not populated for Google Docs or shortcut files. #[serde(rename="downloadUrl")] pub download_url: Option, /// Output only. ID of the shared drive the file resides in. Only populated for items in shared drives. #[serde(rename="driveId")] pub drive_id: Option, /// Output only. Deprecated: Use `capabilities/canEdit` instead. pub editable: Option, /// Output only. A link for embedding the file. #[serde(rename="embedLink")] pub embed_link: Option, /// Output only. ETag of the file. pub etag: Option, /// Output only. Whether this file has been explicitly trashed, as opposed to recursively trashed. #[serde(rename="explicitlyTrashed")] pub explicitly_trashed: Option, /// Output only. Links for exporting Docs Editors files to specific formats. #[serde(rename="exportLinks")] pub export_links: Option>, /// Output only. The final component of `fullFileExtension` with trailing text that does not appear to be part of the extension removed. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files. #[serde(rename="fileExtension")] pub file_extension: Option, /// Output only. Size in bytes of blobs and first party editor files. Won't be populated for files that have no size, like shortcuts and folders. #[serde(rename="fileSize")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub file_size: Option, /// Folder color as an RGB hex string if the file is a folder or a shortcut to a folder. The list of supported colors is available in the folderColorPalette field of the About resource. If an unsupported color is specified, it will be changed to the closest color in the palette. #[serde(rename="folderColorRgb")] pub folder_color_rgb: Option, /// Output only. The full file extension; extracted from the title. May contain multiple concatenated extensions, such as "tar.gz". Removing an extension from the title does not clear this field; however, changing the extension on the title does update this field. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files. #[serde(rename="fullFileExtension")] pub full_file_extension: Option, /// Output only. Whether there are permissions directly on this file. This field is only populated for items in shared drives. #[serde(rename="hasAugmentedPermissions")] pub has_augmented_permissions: Option, /// Output only. 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. #[serde(rename="hasThumbnail")] pub has_thumbnail: Option, /// Output only. The ID of the file's head revision. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files. #[serde(rename="headRevisionId")] pub head_revision_id: Option, /// Output only. A link to the file's icon. #[serde(rename="iconLink")] pub icon_link: Option, /// The ID of the file. pub id: Option, /// Output only. Metadata about image media. This will only be present for image types, and its contents will depend on what can be parsed from the image content. #[serde(rename="imageMediaMetadata")] pub image_media_metadata: Option, /// Indexable text attributes for the file (can only be written) #[serde(rename="indexableText")] pub indexable_text: Option, /// Output only. Whether the file was created or opened by the requesting app. #[serde(rename="isAppAuthorized")] pub is_app_authorized: Option, /// Output only. The type of file. This is always `drive#file`. pub kind: Option, /// Output only. An overview of the labels on the file. #[serde(rename="labelInfo")] pub label_info: Option, /// A group of labels for the file. pub labels: Option, /// Output only. The last user to modify this file. #[serde(rename="lastModifyingUser")] pub last_modifying_user: Option, /// Output only. Name of the last user to modify this file. #[serde(rename="lastModifyingUserName")] pub last_modifying_user_name: Option, /// Last time this file was viewed by the user (formatted RFC 3339 timestamp). #[serde(rename="lastViewedByMeDate")] pub last_viewed_by_me_date: Option>, /// Contains details about the link URLs that clients are using to refer to this item. #[serde(rename="linkShareMetadata")] pub link_share_metadata: Option, /// Deprecated. #[serde(rename="markedViewedByMeDate")] pub marked_viewed_by_me_date: Option>, /// Output only. An MD5 checksum for the content of this file. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files. #[serde(rename="md5Checksum")] pub md5_checksum: Option, /// The MIME type of the file. This is only mutable on update when uploading new content. This field can be left blank, and the mimetype will be determined from the uploaded content's MIME type. #[serde(rename="mimeType")] pub mime_type: Option, /// Last time this file was modified by the user (formatted RFC 3339 timestamp). Note that setting modifiedDate will also update the modifiedByMe date for the user which set the date. #[serde(rename="modifiedByMeDate")] pub modified_by_me_date: Option>, /// Last time this file was modified by anyone (formatted RFC 3339 timestamp). This is only mutable on update when the setModifiedDate parameter is set. #[serde(rename="modifiedDate")] pub modified_date: Option>, /// Output only. A map of the id of each of the user's apps to a link to open this file with that app. Only populated when the drive.apps.readonly scope is used. #[serde(rename="openWithLinks")] pub open_with_links: Option>, /// The original filename of the uploaded content if available, or else the original value of the `title` field. This is only available for files with binary content in Google Drive. #[serde(rename="originalFilename")] pub original_filename: Option, /// Output only. Whether the file is owned by the current user. Not populated for items in shared drives. #[serde(rename="ownedByMe")] pub owned_by_me: Option, /// Output only. Name(s) of the owner(s) of this file. Not populated for items in shared drives. #[serde(rename="ownerNames")] pub owner_names: Option>, /// Output only. 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. pub owners: Option>, /// Collection of parent folders which contain this file. If not specified as part of an insert 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 can also use the `addParents` and `removeParents` parameters to modify the parents list. pub parents: Option>, /// Output only. List of permission IDs for users with access to this file. #[serde(rename="permissionIds")] pub permission_ids: Option>, /// Output only. The list of permissions for users with access to this file. Not populated for items in shared drives. pub permissions: Option>, /// The list of properties. pub properties: Option>, /// Output only. The number of quota bytes used by this file. #[serde(rename="quotaBytesUsed")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub quota_bytes_used: Option, /// Output only. A key needed to access the item via a shared link. #[serde(rename="resourceKey")] pub resource_key: Option, /// Output only. A link back to this file. #[serde(rename="selfLink")] pub self_link: Option, /// Output only. The SHA1 checksum associated with this file, if available. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files. #[serde(rename="sha1Checksum")] pub sha1_checksum: Option, /// Output only. The SHA256 checksum associated with this file, if available. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files. #[serde(rename="sha256Checksum")] pub sha256_checksum: Option, /// Output only. Deprecated: Use `capabilities/canShare` instead. pub shareable: Option, /// Output only. Whether the file has been shared. Not populated for items in shared drives. pub shared: Option, /// Time at which this file was shared with the user (formatted RFC 3339 timestamp). #[serde(rename="sharedWithMeDate")] pub shared_with_me_date: Option>, /// Output only. User that shared the item with the current user, if available. #[serde(rename="sharingUser")] pub sharing_user: Option, /// Shortcut file details. Only populated for shortcut files, which have the mimeType field set to `application/vnd.google-apps.shortcut`. #[serde(rename="shortcutDetails")] pub shortcut_details: Option, /// Output only. The list of spaces which contain the file. Supported values are `drive`, `appDataFolder` and `photos`. pub spaces: Option>, /// Output only. Deprecated: Use `driveId` instead. #[serde(rename="teamDriveId")] pub team_drive_id: Option, /// A thumbnail for the file. This will only be used if a standard thumbnail cannot be generated. pub thumbnail: Option, /// Output only. 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. #[serde(rename="thumbnailLink")] pub thumbnail_link: Option, /// Output only. The thumbnail version for use in thumbnail cache invalidation. #[serde(rename="thumbnailVersion")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub thumbnail_version: Option, /// The title of this file. Note that for immutable items such as the top level folders of shared drives, My Drive root folder, and Application Data folder the title is constant. pub title: Option, /// The time that the item was trashed (formatted RFC 3339 timestamp). Only populated for items in shared drives. #[serde(rename="trashedDate")] pub trashed_date: Option>, /// Output only. If the file has been explicitly trashed, the user who trashed it. Only populated for items in shared drives. #[serde(rename="trashingUser")] pub trashing_user: Option, /// Output only. The permissions for the authenticated user on this file. #[serde(rename="userPermission")] pub user_permission: Option, /// Output only. 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 requesting user. #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub version: Option, /// Output only. Metadata about video media. This will only be present for video types. #[serde(rename="videoMediaMetadata")] pub video_media_metadata: Option, /// Output only. A link for downloading the content of the file in a browser using cookie based authentication. In cases where the content is shared publicly, the content can be downloaded without any credentials. #[serde(rename="webContentLink")] pub web_content_link: Option, /// Output only. A link only available on public folders for viewing their static web assets (HTML, CSS, JS, etc) via Google Drive's Website Hosting. #[serde(rename="webViewLink")] pub web_view_link: Option, /// Whether writers can share the document with other users. Not populated for items in shared drives. #[serde(rename="writersCanShare")] pub writers_can_share: Option, } impl client::RequestValue for File {} impl client::Resource for File {} impl client::ResponseResult for File {} /// A list of files. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list files](FileListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileList { /// The ETag of the list. pub etag: Option, /// 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 "default" or "drive". #[serde(rename="incompleteSearch")] pub incomplete_search: Option, /// The list of files. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched. pub items: Option>, /// This is always `drive#fileList`. pub kind: Option, /// A link to the next page of files. #[serde(rename="nextLink")] pub next_link: Option, /// 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// A link back to this list. #[serde(rename="selfLink")] pub self_link: Option, } impl client::ResponseResult for FileList {} /// A list of generated IDs which can be provided in insert requests /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [generate ids files](FileGenerateIdCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GeneratedIds { /// The IDs generated for the requesting user in the specified space. pub ids: Option>, /// This is always `drive#generatedIds` pub kind: Option, /// The type of file that can be created with these IDs. pub space: Option, } impl client::ResponseResult for GeneratedIds {} /// Representation of a label and label fields. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Label { /// A map of the fields on the label, keyed by the field's ID. pub fields: Option>, /// The ID of the label. pub id: Option, /// This is always `drive#label` pub kind: Option, /// The revision ID of the label. #[serde(rename="revisionId")] pub revision_id: Option, } impl client::Part for Label {} /// Representation of field, which is a typed key-value pair. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LabelField { /// Only present if valueType is dateString. RFC 3339 formatted date: YYYY-MM-DD. #[serde(rename="dateString")] pub date_string: Option>, /// The identifier of this label field. pub id: Option, /// Only present if `valueType` is `integer`. #[serde_as(as = "Option>")] pub integer: Option>, /// This is always `drive#labelField`. pub kind: Option, /// Only present if `valueType` is `selection` pub selection: Option>, /// Only present if `valueType` is `text`. pub text: Option>, /// Only present if `valueType` is `user`. pub user: Option>, /// The field type. While new values may be supported in the future, the following are currently allowed: * `dateString` * `integer` * `selection` * `text` * `user` #[serde(rename="valueType")] pub value_type: Option, } impl client::Part for LabelField {} /// A modification to a label's field. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LabelFieldModification { /// The ID of the field to be modified. #[serde(rename="fieldId")] pub field_id: Option, /// This is always `drive#labelFieldModification`. pub kind: Option, /// Replaces the value of a dateString Field with these new values. The string must be in the RFC 3339 full-date format: YYYY-MM-DD. #[serde(rename="setDateValues")] pub set_date_values: Option>, /// Replaces the value of an `integer` field with these new values. #[serde(rename="setIntegerValues")] #[serde_as(as = "Option>")] pub set_integer_values: Option>, /// Replaces a `selection` field with these new values. #[serde(rename="setSelectionValues")] pub set_selection_values: Option>, /// Sets the value of a `text` field. #[serde(rename="setTextValues")] pub set_text_values: Option>, /// Replaces a `user` field with these new values. The values must be valid email addresses. #[serde(rename="setUserValues")] pub set_user_values: Option>, /// Unsets the values for this field. #[serde(rename="unsetValues")] pub unset_values: Option, } impl client::Part for LabelFieldModification {} /// A list of labels applied to a file. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list labels files](FileListLabelCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LabelList { /// The list of labels. pub items: Option>, /// This is always `drive#labelList` pub kind: Option, /// The page token for the next page of labels. This field 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for LabelList {} /// A modification to a label on a file. A LabelModification can be used to apply a label to a file, update an existing label on a file, or remove a label from a file. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LabelModification { /// The list of modifications to this label's fields. #[serde(rename="fieldModifications")] pub field_modifications: Option>, /// This is always `drive#labelModification`. pub kind: Option, /// The ID of the label to modify. #[serde(rename="labelId")] pub label_id: Option, /// If true, the label will be removed from the file. #[serde(rename="removeLabel")] pub remove_label: Option, } impl client::Part for LabelModification {} /// A request to modify the set of labels on a file. This request may contain many modifications that will either all succeed or all fail atomically. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [modify labels files](FileModifyLabelCall) (request) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ModifyLabelsRequest { /// This is always `drive#modifyLabelsRequest`. pub kind: Option, /// The list of modifications to apply to the labels on the file. #[serde(rename="labelModifications")] pub label_modifications: Option>, } impl client::RequestValue for ModifyLabelsRequest {} /// Response to a ModifyLabels request. This contains only those labels which were added or updated by the request. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [modify labels files](FileModifyLabelCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ModifyLabelsResponse { /// This is always `drive#modifyLabelsResponse` pub kind: Option, /// The list of labels which were added or updated by the request. #[serde(rename="modifiedLabels")] pub modified_labels: Option>, } impl client::ResponseResult for ModifyLabelsResponse {} /// A list of a file’s parents. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list parents](ParentListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ParentList { /// The ETag of the list. pub etag: Option, /// The list of parents. pub items: Option>, /// This is always `drive#parentList`. pub kind: Option, /// A link back to this list. #[serde(rename="selfLink")] pub self_link: Option, } impl client::ResponseResult for ParentList {} /// A reference to a file’s parent. Some resource methods (such as `parents.get`) require a `parentId`. Use the `parents.list` method to retrieve the ID for a parent. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get parents](ParentGetCall) (response) /// * [insert parents](ParentInsertCall) (request|response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ParentReference { /// The ID of the parent. pub id: Option, /// Output only. Whether or not the parent is the root folder. #[serde(rename="isRoot")] pub is_root: Option, /// Output only. This is always `drive#parentReference`. pub kind: Option, /// Output only. A link to the parent. #[serde(rename="parentLink")] pub parent_link: Option, /// Output only. A link back to this reference. #[serde(rename="selfLink")] pub self_link: Option, } impl client::RequestValue for ParentReference {} impl client::ResponseResult for ParentReference {} /// A permission for a file. A permission grants a user, group, domain, or the world access to a file or a folder hierarchy. Some resource methods (such as `permissions.update`) require a `permissionId`. Use the `permissions.list` method to retrieve the ID for a file, folder, or shared drive. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete permissions](PermissionDeleteCall) (none) /// * [get permissions](PermissionGetCall) (response) /// * [get id for email permissions](PermissionGetIdForEmailCall) (none) /// * [insert permissions](PermissionInsertCall) (request|response) /// * [list permissions](PermissionListCall) (none) /// * [patch permissions](PermissionPatchCall) (request|response) /// * [update permissions](PermissionUpdateCall) (request|response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Permission { /// Additional roles for this user. Only `commenter` is currently allowed, though more may be supported in the future. #[serde(rename="additionalRoles")] pub additional_roles: Option>, /// Output only. Deprecated. #[serde(rename="authKey")] pub auth_key: Option, /// Output only. Whether the account associated with this permission has been deleted. This field only pertains to user and group permissions. pub deleted: Option, /// Output only. The domain name of the entity this permission refers to. This is an output-only field which is present when the permission type is `user`, `group` or `domain`. pub domain: Option, /// Output only. The email address of the user or group this permission refers to. This is an output-only field which is present when the permission type is `user` or `group`. #[serde(rename="emailAddress")] pub email_address: Option, /// Output only. The ETag of the permission. pub etag: Option, /// The time at which this permission will expire (RFC 3339 date-time). Expiration dates have the following restrictions: - They can only be set on user and group permissions - The date must be in the future - The date cannot be more than a year in the future - The date can only be set on drive.permissions.update or drive.permissions.patch requests #[serde(rename="expirationDate")] pub expiration_date: Option>, /// The ID of the user this permission refers to, and identical to the `permissionId` in the About and Files resources. When making a `drive.permissions.insert` request, exactly one of the `id` or `value` fields must be specified unless the permission type is `anyone`, in which case both `id` and `value` are ignored. pub id: Option, /// Output only. This is always `drive#permission`. pub kind: Option, /// Output only. The name for this permission. pub name: Option, /// 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. #[serde(rename="pendingOwner")] pub pending_owner: Option, /// Output only. 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. #[serde(rename="permissionDetails")] pub permission_details: Option>, /// Output only. A link to the profile photo, if available. #[serde(rename="photoLink")] pub photo_link: Option, /// The primary role for this user. While new values may be supported in the future, the following are currently allowed: * `owner` * `organizer` * `fileOrganizer` * `writer` * `reader` pub role: Option, /// Output only. A link back to this permission. #[serde(rename="selfLink")] pub self_link: Option, /// Output only. Deprecated: Use `permissionDetails` instead. #[serde(rename="teamDrivePermissionDetails")] pub team_drive_permission_details: Option>, /// The account type. Allowed values are: * `user` * `group` * `domain` * `anyone` #[serde(rename="type")] pub type_: Option, /// The email address or domain name for the entity. This is used during inserts and is not populated in responses. When making a `drive.permissions.insert` request, exactly one of the `id` or `value` fields must be specified unless the permission type is `anyone`, in which case both `id` and `value` are ignored. pub value: Option, /// Indicates the view for this permission. Only populated for permissions that belong to a view. `published` is the only supported value. pub view: Option, /// Whether the link is required for this permission. #[serde(rename="withLink")] pub with_link: Option, } impl client::RequestValue for Permission {} impl client::Resource for Permission {} impl client::ResponseResult for Permission {} /// An ID for a user or group as seen in Permission items. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get id for email permissions](PermissionGetIdForEmailCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PermissionId { /// The permission ID. pub id: Option, /// This is always `drive#permissionId`. pub kind: Option, } impl client::ResponseResult for PermissionId {} /// A list of permissions associated with a file. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list permissions](PermissionListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PermissionList { /// The ETag of the list. pub etag: Option, /// The list of permissions. pub items: Option>, /// This is always `drive#permissionList`. pub kind: Option, /// 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// A link back to this list. #[serde(rename="selfLink")] pub self_link: Option, } impl client::ResponseResult for PermissionList {} /// A key-value pair attached to a file that is either public or private to an application. The following limits apply to file properties: * Maximum of 100 properties total per file * Maximum of 30 private properties per app * Maximum of 30 public properties * Maximum of 124 bytes size limit on (key + value) string in UTF-8 encoding for a single property Some resource methods (such as `properties.update`) require a `propertyKey`. Use the `properties.list` method to retrieve the key for a property. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get properties](PropertyGetCall) (response) /// * [insert properties](PropertyInsertCall) (request|response) /// * [patch properties](PropertyPatchCall) (request|response) /// * [update properties](PropertyUpdateCall) (request|response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Property { /// Output only. ETag of the property. pub etag: Option, /// The key of this property. pub key: Option, /// Output only. This is always `drive#property`. pub kind: Option, /// Output only. The link back to this property. #[serde(rename="selfLink")] pub self_link: Option, /// The value of this property. pub value: Option, /// The visibility of this property. Allowed values are PRIVATE (default) and PUBLIC. Private 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. pub visibility: Option, } impl client::RequestValue for Property {} impl client::ResponseResult for Property {} /// A collection of properties, key-value pairs that are either public or private to an application. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list properties](PropertyListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PropertyList { /// The ETag of the list. pub etag: Option, /// The list of properties. pub items: Option>, /// This is always `drive#propertyList`. pub kind: Option, /// The link back to this list. #[serde(rename="selfLink")] pub self_link: Option, } impl client::ResponseResult for PropertyList {} /// A revision of a file. Some resource methods (such as `revisions.update`) require a `revisionId`. Use the `revisions.list` method to retrieve the ID for a revision. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete revisions](RevisionDeleteCall) (none) /// * [get revisions](RevisionGetCall) (response) /// * [list revisions](RevisionListCall) (none) /// * [patch revisions](RevisionPatchCall) (request|response) /// * [update revisions](RevisionUpdateCall) (request|response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Revision { /// Output only. Short term download URL for the file. This will only be populated on files with content stored in Drive. #[serde(rename="downloadUrl")] pub download_url: Option, /// Output only. The ETag of the revision. pub etag: Option, /// Output only. Links for exporting Docs Editors files to specific formats. #[serde(rename="exportLinks")] pub export_links: Option>, /// Output only. The size of the revision in bytes. This will only be populated on files with content stored in Drive. #[serde(rename="fileSize")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub file_size: Option, /// Output only. The ID of the revision. pub id: Option, /// Output only. This is always `drive#revision`. pub kind: Option, /// Output only. The last user to modify this revision. #[serde(rename="lastModifyingUser")] pub last_modifying_user: Option, /// Output only. Name of the last user to modify this revision. #[serde(rename="lastModifyingUserName")] pub last_modifying_user_name: Option, /// Output only. An MD5 checksum for the content of this revision. This will only be populated on files with content stored in Drive. #[serde(rename="md5Checksum")] pub md5_checksum: Option, /// Output only. The MIME type of the revision. #[serde(rename="mimeType")] pub mime_type: Option, /// Last time this revision was modified (formatted RFC 3339 timestamp). #[serde(rename="modifiedDate")] pub modified_date: Option>, /// Output only. The original filename when this revision was created. This will only be populated on files with content stored in Drive. #[serde(rename="originalFilename")] pub original_filename: Option, /// Whether this revision is pinned to prevent automatic purging. If not set, the revision is automatically purged 30 days after newer content is uploaded. This field can only be modified on files with content stored in Drive, excluding Docs Editors files. Revisions can also be pinned when they are created through the drive.files.insert/update/copy by using the pinned query parameter. Pinned revisions are stored indefinitely using additional storage quota, up to a maximum of 200 revisions. pub pinned: Option, /// Whether subsequent revisions will be automatically republished. This is only populated and can only be modified for Docs Editors files. #[serde(rename="publishAuto")] pub publish_auto: Option, /// Whether this revision is published. This is only populated and can only be modified for Docs Editors files. pub published: Option, /// Output only. A link to the published revision. This is only populated for Google Sites files. #[serde(rename="publishedLink")] pub published_link: Option, /// Whether this revision is published outside the domain. This is only populated and can only be modified for Docs Editors files. #[serde(rename="publishedOutsideDomain")] pub published_outside_domain: Option, /// Output only. A link back to this revision. #[serde(rename="selfLink")] pub self_link: Option, } impl client::RequestValue for Revision {} impl client::Resource for Revision {} impl client::ResponseResult for Revision {} /// A list of revisions of a file. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list revisions](RevisionListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RevisionList { /// The ETag of the list. pub etag: Option, /// The list of revisions. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched. pub items: Option>, /// This is always `drive#revisionList`. pub kind: Option, /// The page token for the next page of revisions. This field 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// A link back to this list. #[serde(rename="selfLink")] pub self_link: Option, } impl client::ResponseResult for RevisionList {} /// There is no detailed description. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get start page token changes](ChangeGetStartPageTokenCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StartPageToken { /// Identifies what kind of resource this is. Value: the fixed string `"drive#startPageToken"`. pub kind: Option, /// The starting page token for listing changes. #[serde(rename="startPageToken")] pub start_page_token: Option, } impl client::ResponseResult for StartPageToken {} /// Deprecated: Use the `drive` collection instead. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get teamdrives](TeamdriveGetCall) (response) /// * [insert teamdrives](TeamdriveInsertCall) (request|response) /// * [update teamdrives](TeamdriveUpdateCall) (request|response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TeamDrive { /// 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. #[serde(rename="backgroundImageFile")] pub background_image_file: Option, /// A short-lived link to this Team Drive's background image. #[serde(rename="backgroundImageLink")] pub background_image_link: Option, /// Capabilities the current user has on this Team Drive. pub capabilities: Option, /// 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`. #[serde(rename="colorRgb")] pub color_rgb: Option, /// The time at which the Team Drive was created (RFC 3339 date-time). #[serde(rename="createdDate")] pub created_date: Option>, /// The ID of this Team Drive which is also the ID of the top level folder of this Team Drive. pub id: Option, /// This is always `drive#teamDrive` pub kind: Option, /// The name of this Team Drive. pub name: Option, /// The organizational unit of this shared drive. This field is only populated on `drives.list` responses when the `useDomainAdminAccess` parameter is set to `true`. #[serde(rename="orgUnitId")] pub org_unit_id: Option, /// A set of restrictions that apply to this Team Drive or items inside this Team Drive. pub restrictions: Option, /// 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.insert` 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`. #[serde(rename="themeId")] pub theme_id: Option, } impl client::RequestValue for TeamDrive {} impl client::Resource for TeamDrive {} impl client::ResponseResult for TeamDrive {} /// A list of Team Drives. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list teamdrives](TeamdriveListCall) (response) #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TeamDriveList { /// The list of Team Drives. pub items: Option>, /// This is always `drive#teamDriveList` pub kind: Option, /// The page token for the next page of Team Drives. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for TeamDriveList {} /// Information about a Drive user. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct User { /// Output only. A plain text displayable name for this user. #[serde(rename="displayName")] pub display_name: Option, /// Output only. The email address of the user. #[serde(rename="emailAddress")] pub email_address: Option, /// Output only. Whether this user is the same as the authenticated user for whom the request was made. #[serde(rename="isAuthenticatedUser")] pub is_authenticated_user: Option, /// Output only. This is always `drive#user`. pub kind: Option, /// Output only. The user's ID as visible in the permissions collection. #[serde(rename="permissionId")] pub permission_id: Option, /// Output only. The user's profile picture. pub picture: Option, } impl client::Part for User {} /// Information about supported additional roles per file type. The most specific type takes precedence. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutAdditionalRoleInfo { /// The supported additional roles per primary role. #[serde(rename="roleSets")] pub role_sets: Option>, /// The content type that this additional role info applies to. #[serde(rename="type")] pub type_: Option, } impl client::NestedType for AboutAdditionalRoleInfo {} impl client::Part for AboutAdditionalRoleInfo {} /// The supported additional roles per primary role. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutAdditionalRoleInfoRoleSets { /// The supported additional roles with the primary role. #[serde(rename="additionalRoles")] pub additional_roles: Option>, /// A primary permission role. #[serde(rename="primaryRole")] pub primary_role: Option, } impl client::NestedType for AboutAdditionalRoleInfoRoleSets {} impl client::Part for AboutAdditionalRoleInfoRoleSets {} /// A list of themes that are supported for shared drives. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutDriveThemes { /// A link to this theme's background image. #[serde(rename="backgroundImageLink")] pub background_image_link: Option, /// The color of this theme as an RGB hex string. #[serde(rename="colorRgb")] pub color_rgb: Option, /// The ID of the theme. pub id: Option, } impl client::NestedType for AboutDriveThemes {} impl client::Part for AboutDriveThemes {} /// The allowable export formats. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutExportFormats { /// The content type to convert from. pub source: Option, /// The possible content types to convert to. pub targets: Option>, } impl client::NestedType for AboutExportFormats {} impl client::Part for AboutExportFormats {} /// List of additional features enabled on this account. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutFeatures { /// The name of the feature. #[serde(rename="featureName")] pub feature_name: Option, /// The request limit rate for this feature, in queries per second. #[serde(rename="featureRate")] pub feature_rate: Option, } impl client::NestedType for AboutFeatures {} impl client::Part for AboutFeatures {} /// The allowable import formats. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutImportFormats { /// The imported file's content type to convert from. pub source: Option, /// The possible content types to convert to. pub targets: Option>, } impl client::NestedType for AboutImportFormats {} impl client::Part for AboutImportFormats {} /// List of max upload sizes for each file type. The most specific type takes precedence. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutMaxUploadSizes { /// The max upload size for this type. #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub size: Option, /// The file type. #[serde(rename="type")] pub type_: Option, } impl client::NestedType for AboutMaxUploadSizes {} impl client::Part for AboutMaxUploadSizes {} /// The amount of storage quota used by different Google services. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutQuotaBytesByService { /// The storage quota bytes used by the service. #[serde(rename="bytesUsed")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub bytes_used: Option, /// The service's name, e.g. DRIVE, GMAIL, or PHOTOS. #[serde(rename="serviceName")] pub service_name: Option, } impl client::NestedType for AboutQuotaBytesByService {} impl client::Part for AboutQuotaBytesByService {} /// Deprecated: Use `driveThemes` instead. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutTeamDriveThemes { /// Deprecated: Use `driveThemes/backgroundImageLink` instead. #[serde(rename="backgroundImageLink")] pub background_image_link: Option, /// Deprecated: Use `driveThemes/colorRgb` instead. #[serde(rename="colorRgb")] pub color_rgb: Option, /// Deprecated: Use `driveThemes/id` instead. pub id: Option, } impl client::NestedType for AboutTeamDriveThemes {} impl client::Part for AboutTeamDriveThemes {} /// The various icons for the app. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AppIcons { /// Category of the icon. Allowed values are: * `application` - icon for the application * `document` - icon for a file associated with the app * `documentShared` - icon for a shared file associated with the app pub category: Option, /// URL for the icon. #[serde(rename="iconUrl")] pub icon_url: Option, /// Size of the icon. Represented as the maximum of the width and height. pub size: Option, } impl client::NestedType for AppIcons {} impl client::Part for AppIcons {} /// The context of the file which is being commented on. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentContext { /// The MIME type of the context snippet. #[serde(rename="type")] pub type_: Option, /// Data representation of the segment of the file being commented on. In the case of a text file for example, this would be the actual text that the comment is about. pub value: Option, } impl client::NestedType for CommentContext {} impl client::Part for CommentContext {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DriveBackgroundImageFile { /// The ID of an image file in Google Drive to use for the background image. pub id: Option, /// 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. pub width: Option, /// 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. #[serde(rename="xCoordinate")] pub x_coordinate: Option, /// 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. #[serde(rename="yCoordinate")] pub y_coordinate: Option, } impl client::NestedType for DriveBackgroundImageFile {} impl client::Part for DriveBackgroundImageFile {} /// Output only. Capabilities the current user has on this shared drive. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DriveCapabilities { /// Output only. Whether the current user can add children to folders in this shared drive. #[serde(rename="canAddChildren")] pub can_add_children: Option, /// Output only. Whether the current user can change the `copyRequiresWriterPermission` restriction of this shared drive. #[serde(rename="canChangeCopyRequiresWriterPermissionRestriction")] pub can_change_copy_requires_writer_permission_restriction: Option, /// Output only. Whether the current user can change the `domainUsersOnly` restriction of this shared drive. #[serde(rename="canChangeDomainUsersOnlyRestriction")] pub can_change_domain_users_only_restriction: Option, /// Output only. Whether the current user can change the background of this shared drive. #[serde(rename="canChangeDriveBackground")] pub can_change_drive_background: Option, /// Output only. Whether the current user can change the `driveMembersOnly` restriction of this shared drive. #[serde(rename="canChangeDriveMembersOnlyRestriction")] pub can_change_drive_members_only_restriction: Option, /// Output only. Whether the current user can change the `sharingFoldersRequiresOrganizerPermission` restriction of this shared drive. #[serde(rename="canChangeSharingFoldersRequiresOrganizerPermissionRestriction")] pub can_change_sharing_folders_requires_organizer_permission_restriction: Option, /// Output only. Whether the current user can comment on files in this shared drive. #[serde(rename="canComment")] pub can_comment: Option, /// Output only. Whether the current user can copy files in this shared drive. #[serde(rename="canCopy")] pub can_copy: Option, /// Output only. Whether the current user can delete children from folders in this shared drive. #[serde(rename="canDeleteChildren")] pub can_delete_children: Option, /// Output only. 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. #[serde(rename="canDeleteDrive")] pub can_delete_drive: Option, /// Output only. Whether the current user can download files in this shared drive. #[serde(rename="canDownload")] pub can_download: Option, /// Output only. Whether the current user can edit files in this shared drive #[serde(rename="canEdit")] pub can_edit: Option, /// Output only. Whether the current user can list the children of folders in this shared drive. #[serde(rename="canListChildren")] pub can_list_children: Option, /// Output only. Whether the current user can add members to this shared drive or remove them or change their role. #[serde(rename="canManageMembers")] pub can_manage_members: Option, /// Output only. Whether the current user can read the revisions resource of files in this shared drive. #[serde(rename="canReadRevisions")] pub can_read_revisions: Option, /// Output only. Whether the current user can rename files or folders in this shared drive. #[serde(rename="canRename")] pub can_rename: Option, /// Output only. Whether the current user can rename this shared drive. #[serde(rename="canRenameDrive")] pub can_rename_drive: Option, /// Output only. Whether the current user can reset the shared drive restrictions to defaults. #[serde(rename="canResetDriveRestrictions")] pub can_reset_drive_restrictions: Option, /// Output only. Whether the current user can share files or folders in this shared drive. #[serde(rename="canShare")] pub can_share: Option, /// Output only. Whether the current user can trash children from folders in this shared drive. #[serde(rename="canTrashChildren")] pub can_trash_children: Option, } impl client::NestedType for DriveCapabilities {} impl client::Part for DriveCapabilities {} /// A set of restrictions that apply to this shared drive or items inside this shared drive. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DriveRestrictions { /// Whether administrative privileges on this shared drive are required to modify restrictions. #[serde(rename="adminManagedRestrictions")] pub admin_managed_restrictions: Option, /// 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. #[serde(rename="copyRequiresWriterPermission")] pub copy_requires_writer_permission: Option, /// 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. #[serde(rename="domainUsersOnly")] pub domain_users_only: Option, /// Whether access to items inside this shared drive is restricted to its members. #[serde(rename="driveMembersOnly")] pub drive_members_only: Option, /// If true, only users with the organizer role can share folders. If false, users with either the organizer role or the file organizer role can share folders. #[serde(rename="sharingFoldersRequiresOrganizerPermission")] pub sharing_folders_requires_organizer_permission: Option, } impl client::NestedType for DriveRestrictions {} impl client::Part for DriveRestrictions {} /// Output only. Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileCapabilities { /// Output only. Whether the current user is the pending owner of the file. Not populated for shared drive files. #[serde(rename="canAcceptOwnership")] pub can_accept_ownership: Option, /// Output only. Whether the current user can add children to this folder. This is always false when the item is not a folder. #[serde(rename="canAddChildren")] pub can_add_children: Option, /// Output only. 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. #[serde(rename="canAddFolderFromAnotherDrive")] pub can_add_folder_from_another_drive: Option, /// Output only. 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. #[serde(rename="canAddMyDriveParent")] pub can_add_my_drive_parent: Option, /// Output only. Whether the current user can change the `copyRequiresWriterPermission` restriction of this file. #[serde(rename="canChangeCopyRequiresWriterPermission")] pub can_change_copy_requires_writer_permission: Option, /// Output only. Deprecated. #[serde(rename="canChangeRestrictedDownload")] pub can_change_restricted_download: Option, /// Output only. Whether the current user can change the securityUpdateEnabled field on link share metadata. #[serde(rename="canChangeSecurityUpdateEnabled")] pub can_change_security_update_enabled: Option, /// Output only. Whether the current user can comment on this file. #[serde(rename="canComment")] pub can_comment: Option, /// Output only. 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. #[serde(rename="canCopy")] pub can_copy: Option, /// Output only. Whether the current user can delete this file. #[serde(rename="canDelete")] pub can_delete: Option, /// Output only. 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. #[serde(rename="canDeleteChildren")] pub can_delete_children: Option, /// Output only. Whether the current user can download this file. #[serde(rename="canDownload")] pub can_download: Option, /// Output only. 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`. #[serde(rename="canEdit")] pub can_edit: Option, /// Output only. Whether the current user can list the children of this folder. This is always false when the item is not a folder. #[serde(rename="canListChildren")] pub can_list_children: Option, /// Output only. Whether the current user can modify the content of this file. #[serde(rename="canModifyContent")] pub can_modify_content: Option, /// Deprecated: Output only. Use one of `canModifyEditorContentRestriction`, `canModifyOwnerContentRestriction` or `canRemoveContentRestriction`. #[serde(rename="canModifyContentRestriction")] pub can_modify_content_restriction: Option, /// Output only. Whether the current user can add or modify content restrictions on the file which are editor restricted. #[serde(rename="canModifyEditorContentRestriction")] pub can_modify_editor_content_restriction: Option, /// Output only. Whether the current user can modify the labels on the file. #[serde(rename="canModifyLabels")] pub can_modify_labels: Option, /// Output only. Whether the current user can add or modify content restrictions which are owner restricted. #[serde(rename="canModifyOwnerContentRestriction")] pub can_modify_owner_content_restriction: Option, /// Output only. 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. #[serde(rename="canMoveChildrenOutOfDrive")] pub can_move_children_out_of_drive: Option, /// Output only. Deprecated: Use `canMoveChildrenOutOfDrive` instead. #[serde(rename="canMoveChildrenOutOfTeamDrive")] pub can_move_children_out_of_team_drive: Option, /// Output only. 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. #[serde(rename="canMoveChildrenWithinDrive")] pub can_move_children_within_drive: Option, /// Output only. Deprecated: Use `canMoveChildrenWithinDrive` instead. #[serde(rename="canMoveChildrenWithinTeamDrive")] pub can_move_children_within_team_drive: Option, /// Output only. Deprecated: Use `canMoveItemOutOfDrive` instead. #[serde(rename="canMoveItemIntoTeamDrive")] pub can_move_item_into_team_drive: Option, /// Output only. 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. #[serde(rename="canMoveItemOutOfDrive")] pub can_move_item_out_of_drive: Option, /// Output only. Deprecated: Use `canMoveItemOutOfDrive` instead. #[serde(rename="canMoveItemOutOfTeamDrive")] pub can_move_item_out_of_team_drive: Option, /// Output only. 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. #[serde(rename="canMoveItemWithinDrive")] pub can_move_item_within_drive: Option, /// Output only. Deprecated: Use `canMoveItemWithinDrive` instead. #[serde(rename="canMoveItemWithinTeamDrive")] pub can_move_item_within_team_drive: Option, /// Output only. Deprecated: Use `canMoveItemWithinDrive` or `canMoveItemOutOfDrive` instead. #[serde(rename="canMoveTeamDriveItem")] pub can_move_team_drive_item: Option, /// Output only. Whether the current user can read the shared drive to which this file belongs. Only populated for items in shared drives. #[serde(rename="canReadDrive")] pub can_read_drive: Option, /// Output only. Whether the current user can read the labels on the file. #[serde(rename="canReadLabels")] pub can_read_labels: Option, /// Output only. 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. #[serde(rename="canReadRevisions")] pub can_read_revisions: Option, /// Output only. Deprecated: Use `canReadDrive` instead. #[serde(rename="canReadTeamDrive")] pub can_read_team_drive: Option, /// Output only. 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. #[serde(rename="canRemoveChildren")] pub can_remove_children: Option, /// Output only. Whether there is a content restriction on the file that can be removed by the current user. #[serde(rename="canRemoveContentRestriction")] pub can_remove_content_restriction: Option, /// Output only. 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. #[serde(rename="canRemoveMyDriveParent")] pub can_remove_my_drive_parent: Option, /// Output only. Whether the current user can rename this file. #[serde(rename="canRename")] pub can_rename: Option, /// Output only. Whether the current user can modify the sharing settings for this file. #[serde(rename="canShare")] pub can_share: Option, /// Output only. Whether the current user can move this file to trash. #[serde(rename="canTrash")] pub can_trash: Option, /// Output only. 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. #[serde(rename="canTrashChildren")] pub can_trash_children: Option, /// Output only. Whether the current user can restore this file from trash. #[serde(rename="canUntrash")] pub can_untrash: Option, } impl client::NestedType for FileCapabilities {} impl client::Part for FileCapabilities {} /// Output only. Metadata about image media. This will only be present for image types, and its contents will depend on what can be parsed from the image content. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileImageMediaMetadata { /// Output only. The aperture used to create the photo (f-number). pub aperture: Option, /// Output only. The make of the camera used to create the photo. #[serde(rename="cameraMake")] pub camera_make: Option, /// Output only. The model of the camera used to create the photo. #[serde(rename="cameraModel")] pub camera_model: Option, /// Output only. The color space of the photo. #[serde(rename="colorSpace")] pub color_space: Option, /// Output only. The date and time the photo was taken (EXIF format timestamp). pub date: Option, /// Output only. The exposure bias of the photo (APEX value). #[serde(rename="exposureBias")] pub exposure_bias: Option, /// Output only. The exposure mode used to create the photo. #[serde(rename="exposureMode")] pub exposure_mode: Option, /// Output only. The length of the exposure, in seconds. #[serde(rename="exposureTime")] pub exposure_time: Option, /// Output only. Whether a flash was used to create the photo. #[serde(rename="flashUsed")] pub flash_used: Option, /// Output only. The focal length used to create the photo, in millimeters. #[serde(rename="focalLength")] pub focal_length: Option, /// Output only. The height of the image in pixels. pub height: Option, /// Output only. The ISO speed used to create the photo. #[serde(rename="isoSpeed")] pub iso_speed: Option, /// Output only. The lens used to create the photo. pub lens: Option, /// Output only. Geographic location information stored in the image. pub location: Option, /// Output only. The smallest f-number of the lens at the focal length used to create the photo (APEX value). #[serde(rename="maxApertureValue")] pub max_aperture_value: Option, /// Output only. The metering mode used to create the photo. #[serde(rename="meteringMode")] pub metering_mode: Option, /// Output only. The number of clockwise 90 degree rotations applied from the image's original orientation. pub rotation: Option, /// Output only. The type of sensor used to create the photo. pub sensor: Option, /// Output only. The distance to the subject of the photo, in meters. #[serde(rename="subjectDistance")] pub subject_distance: Option, /// Output only. The white balance mode used to create the photo. #[serde(rename="whiteBalance")] pub white_balance: Option, /// Output only. The width of the image in pixels. pub width: Option, } impl client::NestedType for FileImageMediaMetadata {} impl client::Part for FileImageMediaMetadata {} /// Output only. Geographic location information stored in the image. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileImageMediaMetadataLocation { /// Output only. The altitude stored in the image. pub altitude: Option, /// Output only. The latitude stored in the image. pub latitude: Option, /// Output only. The longitude stored in the image. pub longitude: Option, } impl client::NestedType for FileImageMediaMetadataLocation {} impl client::Part for FileImageMediaMetadataLocation {} /// Indexable text attributes for the file (can only be written) /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileIndexableText { /// The text to be indexed for this file. pub text: Option, } impl client::NestedType for FileIndexableText {} impl client::Part for FileIndexableText {} /// Output only. An overview of the labels on the file. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileLabelInfo { /// Output only. The set of labels on the file as requested by the label IDs in the `includeLabels` parameter. By default, no labels are returned. pub labels: Option>, } impl client::NestedType for FileLabelInfo {} impl client::Part for FileLabelInfo {} /// A group of labels for the file. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileLabels { /// Output only. Deprecated. pub hidden: Option, /// Output only. Whether the file has been modified by this user. pub modified: Option, /// Output only. Deprecated: Use `copyRequiresWriterPermission` instead. pub restricted: Option, /// Whether this file is starred by the user. pub starred: Option, /// Whether this file has been trashed. This label applies to all users accessing the file; however, only owners are allowed to see and untrash files. pub trashed: Option, /// Whether this file has been viewed by this user. pub viewed: Option, } impl client::NestedType for FileLabels {} impl client::Part for FileLabels {} /// Contains details about the link URLs that clients are using to refer to this item. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileLinkShareMetadata { /// Output only. Whether the file is eligible for security update. #[serde(rename="securityUpdateEligible")] pub security_update_eligible: Option, /// Output only. Whether the security update is enabled for this file. #[serde(rename="securityUpdateEnabled")] pub security_update_enabled: Option, } impl client::NestedType for FileLinkShareMetadata {} impl client::Part for FileLinkShareMetadata {} /// Shortcut file details. Only populated for shortcut files, which have the mimeType field set to `application/vnd.google-apps.shortcut`. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileShortcutDetails { /// The ID of the file that this shortcut points to. #[serde(rename="targetId")] pub target_id: Option, /// Output only. 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. #[serde(rename="targetMimeType")] pub target_mime_type: Option, /// Output only. The ResourceKey for the target file. #[serde(rename="targetResourceKey")] pub target_resource_key: Option, } impl client::NestedType for FileShortcutDetails {} impl client::Part for FileShortcutDetails {} /// A thumbnail for the file. This will only be used if a standard thumbnail cannot be generated. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileThumbnail { /// The URL-safe Base64 encoded bytes of the thumbnail image. It should conform to RFC 4648 section 5. #[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")] pub image: Option>, /// The MIME type of the thumbnail. #[serde(rename="mimeType")] pub mime_type: Option, } impl client::NestedType for FileThumbnail {} impl client::Part for FileThumbnail {} /// Output only. Metadata about video media. This will only be present for video types. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileVideoMediaMetadata { /// Output only. The duration of the video in milliseconds. #[serde(rename="durationMillis")] #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] pub duration_millis: Option, /// Output only. The height of the video in pixels. pub height: Option, /// Output only. The width of the video in pixels. pub width: Option, } impl client::NestedType for FileVideoMediaMetadata {} impl client::Part for FileVideoMediaMetadata {} /// Output only. 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PermissionPermissionDetails { /// Output only. Additional roles for this user. Only `commenter` is currently possible, though more may be supported in the future. #[serde(rename="additionalRoles")] pub additional_roles: Option>, /// Output only. Whether this permission is inherited. This field is always populated. This is an output-only field. pub inherited: Option, /// Output only. The ID of the item from which this permission is inherited. This is an output-only field. #[serde(rename="inheritedFrom")] pub inherited_from: Option, /// Output only. The permission type for this user. While new values may be added in future, the following are currently possible: * `file` * `member` #[serde(rename="permissionType")] pub permission_type: Option, /// Output only. The primary role for this user. While new values may be added in the future, the following are currently possible: * `organizer` * `fileOrganizer` * `writer` * `reader` pub role: Option, } impl client::NestedType for PermissionPermissionDetails {} impl client::Part for PermissionPermissionDetails {} /// Output only. Deprecated: Use `permissionDetails` instead. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PermissionTeamDrivePermissionDetails { /// Output only. Deprecated: Use `permissionDetails/additionalRoles` instead. #[serde(rename="additionalRoles")] pub additional_roles: Option>, /// Output only. Deprecated: Use `permissionDetails/inherited` instead. pub inherited: Option, /// Output only. Deprecated: Use `permissionDetails/inheritedFrom` instead. #[serde(rename="inheritedFrom")] pub inherited_from: Option, /// Output only. Deprecated: Use `permissionDetails/role` instead. pub role: Option, /// Output only. Deprecated: Use `permissionDetails/permissionType` instead. #[serde(rename="teamDrivePermissionType")] pub team_drive_permission_type: Option, } impl client::NestedType for PermissionTeamDrivePermissionDetails {} impl client::Part for PermissionTeamDrivePermissionDetails {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TeamDriveBackgroundImageFile { /// The ID of an image file in Drive to use for the background image. pub id: Option, /// 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. pub width: Option, /// 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. #[serde(rename="xCoordinate")] pub x_coordinate: Option, /// 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. #[serde(rename="yCoordinate")] pub y_coordinate: Option, } impl client::NestedType for TeamDriveBackgroundImageFile {} impl client::Part for TeamDriveBackgroundImageFile {} /// Capabilities the current user has on this Team Drive. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TeamDriveCapabilities { /// Whether the current user can add children to folders in this Team Drive. #[serde(rename="canAddChildren")] pub can_add_children: Option, /// Whether the current user can change the `copyRequiresWriterPermission` restriction of this Team Drive. #[serde(rename="canChangeCopyRequiresWriterPermissionRestriction")] pub can_change_copy_requires_writer_permission_restriction: Option, /// Whether the current user can change the `domainUsersOnly` restriction of this Team Drive. #[serde(rename="canChangeDomainUsersOnlyRestriction")] pub can_change_domain_users_only_restriction: Option, /// Whether the current user can change the `sharingFoldersRequiresOrganizerPermission` restriction of this Team Drive. #[serde(rename="canChangeSharingFoldersRequiresOrganizerPermissionRestriction")] pub can_change_sharing_folders_requires_organizer_permission_restriction: Option, /// Whether the current user can change the background of this Team Drive. #[serde(rename="canChangeTeamDriveBackground")] pub can_change_team_drive_background: Option, /// Whether the current user can change the `teamMembersOnly` restriction of this Team Drive. #[serde(rename="canChangeTeamMembersOnlyRestriction")] pub can_change_team_members_only_restriction: Option, /// Whether the current user can comment on files in this Team Drive. #[serde(rename="canComment")] pub can_comment: Option, /// Whether the current user can copy files in this Team Drive. #[serde(rename="canCopy")] pub can_copy: Option, /// Whether the current user can delete children from folders in this Team Drive. #[serde(rename="canDeleteChildren")] pub can_delete_children: Option, /// 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. #[serde(rename="canDeleteTeamDrive")] pub can_delete_team_drive: Option, /// Whether the current user can download files in this Team Drive. #[serde(rename="canDownload")] pub can_download: Option, /// Whether the current user can edit files in this Team Drive #[serde(rename="canEdit")] pub can_edit: Option, /// Whether the current user can list the children of folders in this Team Drive. #[serde(rename="canListChildren")] pub can_list_children: Option, /// Whether the current user can add members to this Team Drive or remove them or change their role. #[serde(rename="canManageMembers")] pub can_manage_members: Option, /// Whether the current user can read the revisions resource of files in this Team Drive. #[serde(rename="canReadRevisions")] pub can_read_revisions: Option, /// Deprecated: Use `canDeleteChildren` or `canTrashChildren` instead. #[serde(rename="canRemoveChildren")] pub can_remove_children: Option, /// Whether the current user can rename files or folders in this Team Drive. #[serde(rename="canRename")] pub can_rename: Option, /// Whether the current user can rename this Team Drive. #[serde(rename="canRenameTeamDrive")] pub can_rename_team_drive: Option, /// Whether the current user can reset the Team Drive restrictions to defaults. #[serde(rename="canResetTeamDriveRestrictions")] pub can_reset_team_drive_restrictions: Option, /// Whether the current user can share files or folders in this Team Drive. #[serde(rename="canShare")] pub can_share: Option, /// Whether the current user can trash children from folders in this Team Drive. #[serde(rename="canTrashChildren")] pub can_trash_children: Option, } impl client::NestedType for TeamDriveCapabilities {} impl client::Part for TeamDriveCapabilities {} /// A set of restrictions that apply to this Team Drive or items inside this Team Drive. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TeamDriveRestrictions { /// Whether administrative privileges on this Team Drive are required to modify restrictions. #[serde(rename="adminManagedRestrictions")] pub admin_managed_restrictions: Option, /// 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. #[serde(rename="copyRequiresWriterPermission")] pub copy_requires_writer_permission: Option, /// 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. #[serde(rename="domainUsersOnly")] pub domain_users_only: Option, /// If true, only users with the organizer role can share folders. If false, users with either the organizer role or the file organizer role can share folders. #[serde(rename="sharingFoldersRequiresOrganizerPermission")] pub sharing_folders_requires_organizer_permission: Option, /// Whether access to items inside this Team Drive is restricted to members of this Team Drive. #[serde(rename="teamMembersOnly")] pub team_members_only: Option, } impl client::NestedType for TeamDriveRestrictions {} impl client::Part for TeamDriveRestrictions {} /// Output only. The user's profile picture. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[serde_with::serde_as(crate = "::client::serde_with")] #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserPicture { /// Output Only. A URL that points to a profile picture of this user. pub url: Option, } impl client::NestedType for UserPicture {} impl client::Part for UserPicture {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *about* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` /// // to build up your call. /// let rb = hub.about(); /// # } /// ``` pub struct AboutMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for AboutMethods<'a, S> {} impl<'a, S> AboutMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets the information about the current user along with Drive API settings pub fn get(&self) -> AboutGetCall<'a, S> { AboutGetCall { hub: self.hub, _start_change_id: Default::default(), _max_change_id_count: Default::default(), _include_subscribed: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *app* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.apps(); /// # } /// ``` pub struct AppMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for AppMethods<'a, S> {} impl<'a, S> AppMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets a specific app. /// /// # Arguments /// /// * `appId` - The ID of the app. pub fn get(&self, app_id: &str) -> AppGetCall<'a, S> { AppGetCall { hub: self.hub, _app_id: app_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists a user's installed apps. pub fn list(&self) -> AppListCall<'a, S> { AppListCall { hub: self.hub, _language_code: Default::default(), _app_filter_mime_types: Default::default(), _app_filter_extensions: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *change* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `get_start_page_token(...)`, `list(...)` and `watch(...)` /// // to build up your call. /// let rb = hub.changes(); /// # } /// ``` pub struct ChangeMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for ChangeMethods<'a, S> {} impl<'a, S> ChangeMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deprecated: Use `changes.getStartPageToken` and `changes.list` to retrieve recent changes. /// /// # Arguments /// /// * `changeId` - The ID of the change. pub fn get(&self, change_id: &str) -> ChangeGetCall<'a, S> { ChangeGetCall { hub: self.hub, _change_id: change_id.to_string(), _team_drive_id: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _drive_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets the starting pageToken for listing future changes. pub fn get_start_page_token(&self) -> ChangeGetStartPageTokenCall<'a, S> { ChangeGetStartPageTokenCall { hub: self.hub, _team_drive_id: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _drive_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists the changes for a user or shared drive. pub fn list(&self) -> ChangeListCall<'a, S> { ChangeListCall { hub: self.hub, _team_drive_id: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _start_change_id: Default::default(), _spaces: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _include_team_drive_items: Default::default(), _include_subscribed: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _include_items_from_all_drives: Default::default(), _include_deleted: Default::default(), _include_corpus_removals: Default::default(), _drive_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Subscribe to changes for a user. /// /// # Arguments /// /// * `request` - No description provided. pub fn watch(&self, request: Channel) -> ChangeWatchCall<'a, S> { ChangeWatchCall { hub: self.hub, _request: request, _team_drive_id: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _start_change_id: Default::default(), _spaces: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _include_team_drive_items: Default::default(), _include_subscribed: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _include_items_from_all_drives: Default::default(), _include_deleted: Default::default(), _include_corpus_removals: Default::default(), _drive_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *channel* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `stop(...)` /// // to build up your call. /// let rb = hub.channels(); /// # } /// ``` pub struct ChannelMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for ChannelMethods<'a, S> {} impl<'a, S> ChannelMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Stops watching resources through this channel. /// /// # Arguments /// /// * `request` - No description provided. pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, S> { ChannelStopCall { hub: self.hub, _request: request, _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *child* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)` /// // to build up your call. /// let rb = hub.children(); /// # } /// ``` pub struct ChildMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for ChildMethods<'a, S> {} impl<'a, S> ChildMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Removes a child from a folder. /// /// # Arguments /// /// * `folderId` - The ID of the folder. /// * `childId` - The ID of the child. pub fn delete(&self, folder_id: &str, child_id: &str) -> ChildDeleteCall<'a, S> { ChildDeleteCall { hub: self.hub, _folder_id: folder_id.to_string(), _child_id: child_id.to_string(), _enforce_single_parent: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a specific child reference. /// /// # Arguments /// /// * `folderId` - The ID of the folder. /// * `childId` - The ID of the child. pub fn get(&self, folder_id: &str, child_id: &str) -> ChildGetCall<'a, S> { ChildGetCall { hub: self.hub, _folder_id: folder_id.to_string(), _child_id: child_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a file into a folder. /// /// # Arguments /// /// * `request` - No description provided. /// * `folderId` - The ID of the folder. pub fn insert(&self, request: ChildReference, folder_id: &str) -> ChildInsertCall<'a, S> { ChildInsertCall { hub: self.hub, _request: request, _folder_id: folder_id.to_string(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _enforce_single_parent: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists a folder's children. /// /// # Arguments /// /// * `folderId` - The ID of the folder. pub fn list(&self, folder_id: &str) -> ChildListCall<'a, S> { ChildListCall { hub: self.hub, _folder_id: folder_id.to_string(), _q: Default::default(), _page_token: Default::default(), _order_by: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *comment* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.comments(); /// # } /// ``` pub struct CommentMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for CommentMethods<'a, S> {} impl<'a, S> CommentMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes a comment. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. pub fn delete(&self, file_id: &str, comment_id: &str) -> CommentDeleteCall<'a, S> { CommentDeleteCall { hub: self.hub, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a comment by ID. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. pub fn get(&self, file_id: &str, comment_id: &str) -> CommentGetCall<'a, S> { CommentGetCall { hub: self.hub, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _include_deleted: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a new comment on the given file. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. pub fn insert(&self, request: Comment, file_id: &str) -> CommentInsertCall<'a, S> { CommentInsertCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists a file's comments. /// /// # Arguments /// /// * `fileId` - The ID of the file. pub fn list(&self, file_id: &str) -> CommentListCall<'a, S> { CommentListCall { hub: self.hub, _file_id: file_id.to_string(), _updated_min: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _include_deleted: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing comment. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. pub fn patch(&self, request: Comment, file_id: &str, comment_id: &str) -> CommentPatchCall<'a, S> { CommentPatchCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing comment. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. pub fn update(&self, request: Comment, file_id: &str, comment_id: &str) -> CommentUpdateCall<'a, S> { CommentUpdateCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *drive* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `hide(...)`, `insert(...)`, `list(...)`, `unhide(...)` and `update(...)` /// // to build up your call. /// let rb = hub.drives(); /// # } /// ``` pub struct DriveMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for DriveMethods<'a, S> {} impl<'a, S> DriveMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Permanently deletes a shared drive for which the user is an `organizer`. The shared drive cannot contain any untrashed items. /// /// # Arguments /// /// * `driveId` - The ID of the shared drive. pub fn delete(&self, drive_id: &str) -> DriveDeleteCall<'a, S> { DriveDeleteCall { hub: self.hub, _drive_id: drive_id.to_string(), _use_domain_admin_access: Default::default(), _allow_item_deletion: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a shared drive's metadata by ID. /// /// # Arguments /// /// * `driveId` - The ID of the shared drive. pub fn get(&self, drive_id: &str) -> DriveGetCall<'a, S> { DriveGetCall { hub: self.hub, _drive_id: drive_id.to_string(), _use_domain_admin_access: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Hides a shared drive from the default view. /// /// # Arguments /// /// * `driveId` - The ID of the shared drive. pub fn hide(&self, drive_id: &str) -> DriveHideCall<'a, S> { DriveHideCall { hub: self.hub, _drive_id: drive_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a new shared drive. /// /// # Arguments /// /// * `request` - No description provided. /// * `requestId` - Required. 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. pub fn insert(&self, request: Drive, request_id: &str) -> DriveInsertCall<'a, S> { DriveInsertCall { hub: self.hub, _request: request, _request_id: request_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists the user’s shared drives. This method accepts the `q` parameter, which is a search query combining one or more search terms. For more information, see the [Search for shared drives](https://developers.google.com/drive/api/guides/search-shareddrives) guide. pub fn list(&self) -> DriveListCall<'a, S> { DriveListCall { hub: self.hub, _use_domain_admin_access: Default::default(), _q: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Restores a shared drive to the default view. /// /// # Arguments /// /// * `driveId` - The ID of the shared drive. pub fn unhide(&self, drive_id: &str) -> DriveUnhideCall<'a, S> { DriveUnhideCall { hub: self.hub, _drive_id: drive_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates the metadata for a shared drive. /// /// # Arguments /// /// * `request` - No description provided. /// * `driveId` - The ID of the shared drive. pub fn update(&self, request: Drive, drive_id: &str) -> DriveUpdateCall<'a, S> { DriveUpdateCall { hub: self.hub, _request: request, _drive_id: drive_id.to_string(), _use_domain_admin_access: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *file* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `copy(...)`, `delete(...)`, `empty_trash(...)`, `export(...)`, `generate_ids(...)`, `get(...)`, `insert(...)`, `list(...)`, `list_labels(...)`, `modify_labels(...)`, `patch(...)`, `touch(...)`, `trash(...)`, `untrash(...)`, `update(...)` and `watch(...)` /// // to build up your call. /// let rb = hub.files(); /// # } /// ``` pub struct FileMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for FileMethods<'a, S> {} impl<'a, S> FileMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Creates a copy of the specified file. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file to copy. pub fn copy(&self, request: File, file_id: &str) -> FileCopyCall<'a, S> { FileCopyCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _visibility: Default::default(), _timed_text_track_name: Default::default(), _timed_text_language: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _pinned: Default::default(), _ocr_language: Default::default(), _ocr: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _enforce_single_parent: Default::default(), _convert: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// 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 folder. If the target is a folder, all descendants owned by the user are also deleted. /// /// # Arguments /// /// * `fileId` - The ID of the file to delete. pub fn delete(&self, file_id: &str) -> FileDeleteCall<'a, S> { FileDeleteCall { hub: self.hub, _file_id: file_id.to_string(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _enforce_single_parent: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Permanently deletes all of the user's trashed files. pub fn empty_trash(&self) -> FileEmptyTrashCall<'a, S> { FileEmptyTrashCall { hub: self.hub, _enforce_single_parent: Default::default(), _drive_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Exports a Google Workspace document to the requested MIME type and returns exported byte content. Note that the exported content is limited to 10MB. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `mimeType` - Required. The MIME type of the format requested for this export. pub fn export(&self, file_id: &str, mime_type: &str) -> FileExportCall<'a, S> { FileExportCall { hub: self.hub, _file_id: file_id.to_string(), _mime_type: mime_type.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Generates a set of file IDs which can be provided in insert or copy requests. pub fn generate_ids(&self) -> FileGenerateIdCall<'a, S> { FileGenerateIdCall { hub: self.hub, _type_: Default::default(), _space: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a file’s metadata or content by ID. If you provide the URL parameter `alt=media`, then the response includes the file contents in the response body. Downloading content with `alt=media` only works if the file is stored in Drive. To download Google Docs, Sheets, and Slides use [`files.export`](https://developers.google.com/drive/api/reference/rest/v2/files/export) instead. For more information, see [Download & export files](https://developers.google.com/drive/api/guides/manage-downloads). /// /// # Arguments /// /// * `fileId` - The ID for the file in question. pub fn get(&self, file_id: &str) -> FileGetCall<'a, S> { FileGetCall { hub: self.hub, _file_id: file_id.to_string(), _update_viewed_date: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _revision_id: Default::default(), _projection: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _acknowledge_abuse: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new file. This method supports an */upload* URI and accepts uploaded media with the following characteristics: - *Maximum file size:* 5,120 GB - *Accepted Media MIME types:*`*/*` Note: Specify a valid MIME type, rather than the literal `*/*` value. The literal `*/*` is only used to indicate that any valid MIME type can be uploaded. For more information on uploading files, see [Upload file data](https://developers.google.com/drive/api/guides/manage-uploads). Apps creating shortcuts with `files.insert` must specify the MIME type `application/vnd.google-apps.shortcut`. Apps should specify a file extension in the `title` property when inserting files with the API. For example, an operation to insert a JPEG file should specify something like `"title": "cat.jpg"` in the metadata. Subsequent `GET` requests include the read-only `fileExtension` property populated with the extension originally specified in the `title` property. When a Google Drive user requests to download a file, or when the file is downloaded through the sync client, Drive builds a full filename (with extension) based on the title. In cases where the extension is missing, Drive attempts to determine the extension based on the file’s MIME type. /// /// # Arguments /// /// * `request` - No description provided. pub fn insert(&self, request: File) -> FileInsertCall<'a, S> { FileInsertCall { hub: self.hub, _request: request, _visibility: Default::default(), _use_content_as_indexable_text: Default::default(), _timed_text_track_name: Default::default(), _timed_text_language: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _pinned: Default::default(), _ocr_language: Default::default(), _ocr: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _enforce_single_parent: Default::default(), _convert: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists the user’s files. This method accepts the `q` parameter, which is a search query combining one or more search terms. For more information, see the [Search for files & folders](https://developers.google.com/drive/api/guides/search-files) guide. *Note:* This method returns *all* files by default, including trashed files. If you don’t want trashed files to appear in the list, use the `trashed=false` query parameter to remove trashed files from the results. pub fn list(&self) -> FileListCall<'a, S> { FileListCall { hub: self.hub, _team_drive_id: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _spaces: Default::default(), _q: Default::default(), _projection: Default::default(), _page_token: Default::default(), _order_by: Default::default(), _max_results: Default::default(), _include_team_drive_items: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _include_items_from_all_drives: Default::default(), _drive_id: Default::default(), _corpus: Default::default(), _corpora: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists the labels on a file. /// /// # Arguments /// /// * `fileId` - The ID for the file. pub fn list_labels(&self, file_id: &str) -> FileListLabelCall<'a, S> { FileListLabelCall { hub: self.hub, _file_id: file_id.to_string(), _page_token: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Modifies the set of labels applied to a file. Returns a list of the labels that were added or modified. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file to which the labels belong. pub fn modify_labels(&self, request: ModifyLabelsRequest, file_id: &str) -> FileModifyLabelCall<'a, S> { FileModifyLabelCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// 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. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file to update. pub fn patch(&self, request: File, file_id: &str) -> FilePatchCall<'a, S> { FilePatchCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _use_content_as_indexable_text: Default::default(), _update_viewed_date: Default::default(), _timed_text_track_name: Default::default(), _timed_text_language: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _set_modified_date: Default::default(), _remove_parents: Default::default(), _pinned: Default::default(), _ocr_language: Default::default(), _ocr: Default::default(), _new_revision: Default::default(), _modified_date_behavior: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _enforce_single_parent: Default::default(), _convert: Default::default(), _add_parents: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Set the file's updated time to the current server time. /// /// # Arguments /// /// * `fileId` - The ID of the file to update. pub fn touch(&self, file_id: &str) -> FileTouchCall<'a, S> { FileTouchCall { hub: self.hub, _file_id: file_id.to_string(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Moves a file to the trash. The currently authenticated user must own the file or be at least a `fileOrganizer` on the parent for shared drive files. /// /// # Arguments /// /// * `fileId` - The ID of the file to trash. pub fn trash(&self, file_id: &str) -> FileTrashCall<'a, S> { FileTrashCall { hub: self.hub, _file_id: file_id.to_string(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Restores a file from the trash. The currently authenticated user must own the file or be at least a `fileOrganizer` on the parent for shared drive files. /// /// # Arguments /// /// * `fileId` - The ID of the file to untrash. pub fn untrash(&self, file_id: &str) -> FileUntrashCall<'a, S> { FileUntrashCall { hub: self.hub, _file_id: file_id.to_string(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// 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 be changed automatically, such as `modifiedDate`. This method supports patch semantics. This method supports an */upload* URI and accepts uploaded media with the following characteristics: - *Maximum file size:* 5,120 GB - *Accepted Media MIME types:*`*/*` Note: Specify a valid MIME type, rather than the literal `*/*` value. The literal `*/*` is only used to indicate that any valid MIME type can be uploaded. For more information on uploading files, see [Upload file data](https://developers.google.com/drive/api/guides/manage-uploads). /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file to update. pub fn update(&self, request: File, file_id: &str) -> FileUpdateCall<'a, S> { FileUpdateCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _use_content_as_indexable_text: Default::default(), _update_viewed_date: Default::default(), _timed_text_track_name: Default::default(), _timed_text_language: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _set_modified_date: Default::default(), _remove_parents: Default::default(), _pinned: Default::default(), _ocr_language: Default::default(), _ocr: Default::default(), _new_revision: Default::default(), _modified_date_behavior: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _enforce_single_parent: Default::default(), _convert: Default::default(), _add_parents: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Subscribes to changes to a file. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID for the file in question. pub fn watch(&self, request: Channel, file_id: &str) -> FileWatchCall<'a, S> { FileWatchCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _update_viewed_date: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _revision_id: Default::default(), _projection: Default::default(), _include_permissions_for_view: Default::default(), _include_labels: Default::default(), _acknowledge_abuse: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *parent* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)` /// // to build up your call. /// let rb = hub.parents(); /// # } /// ``` pub struct ParentMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for ParentMethods<'a, S> {} impl<'a, S> ParentMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Removes a parent from a file. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `parentId` - The ID of the parent. pub fn delete(&self, file_id: &str, parent_id: &str) -> ParentDeleteCall<'a, S> { ParentDeleteCall { hub: self.hub, _file_id: file_id.to_string(), _parent_id: parent_id.to_string(), _enforce_single_parent: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a specific parent reference. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `parentId` - The ID of the parent. pub fn get(&self, file_id: &str, parent_id: &str) -> ParentGetCall<'a, S> { ParentGetCall { hub: self.hub, _file_id: file_id.to_string(), _parent_id: parent_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Adds a parent folder for a file. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. pub fn insert(&self, request: ParentReference, file_id: &str) -> ParentInsertCall<'a, S> { ParentInsertCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _enforce_single_parent: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists a file's parents. /// /// # Arguments /// /// * `fileId` - The ID of the file. pub fn list(&self, file_id: &str) -> ParentListCall<'a, S> { ParentListCall { hub: self.hub, _file_id: file_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *permission* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `get_id_for_email(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.permissions(); /// # } /// ``` pub struct PermissionMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for PermissionMethods<'a, S> {} impl<'a, S> PermissionMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes a permission from a file or shared drive. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied. /// /// # Arguments /// /// * `fileId` - The ID for the file or shared drive. /// * `permissionId` - The ID for the permission. pub fn delete(&self, file_id: &str, permission_id: &str) -> PermissionDeleteCall<'a, S> { PermissionDeleteCall { hub: self.hub, _file_id: file_id.to_string(), _permission_id: permission_id.to_string(), _use_domain_admin_access: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a permission by ID. /// /// # Arguments /// /// * `fileId` - The ID for the file or shared drive. /// * `permissionId` - The ID for the permission. pub fn get(&self, file_id: &str, permission_id: &str) -> PermissionGetCall<'a, S> { PermissionGetCall { hub: self.hub, _file_id: file_id.to_string(), _permission_id: permission_id.to_string(), _use_domain_admin_access: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Returns the permission ID for an email address. /// /// # Arguments /// /// * `email` - The email address for which to return a permission ID pub fn get_id_for_email(&self, email: &str) -> PermissionGetIdForEmailCall<'a, S> { PermissionGetIdForEmailCall { hub: self.hub, _email: email.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a permission for a file or shared drive. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID for the file or shared drive. pub fn insert(&self, request: Permission, file_id: &str) -> PermissionInsertCall<'a, S> { PermissionInsertCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _use_domain_admin_access: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _send_notification_emails: Default::default(), _move_to_new_owners_root: Default::default(), _enforce_single_parent: Default::default(), _email_message: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists a file's or shared drive's permissions. /// /// # Arguments /// /// * `fileId` - The ID for the file or shared drive. pub fn list(&self, file_id: &str) -> PermissionListCall<'a, S> { PermissionListCall { hub: self.hub, _file_id: file_id.to_string(), _use_domain_admin_access: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _include_permissions_for_view: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a permission using patch semantics. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID for the file or shared drive. /// * `permissionId` - The ID for the permission. pub fn patch(&self, request: Permission, file_id: &str, permission_id: &str) -> PermissionPatchCall<'a, S> { PermissionPatchCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _permission_id: permission_id.to_string(), _use_domain_admin_access: Default::default(), _transfer_ownership: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _remove_expiration: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a permission. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID for the file or shared drive. /// * `permissionId` - The ID for the permission. pub fn update(&self, request: Permission, file_id: &str, permission_id: &str) -> PermissionUpdateCall<'a, S> { PermissionUpdateCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _permission_id: permission_id.to_string(), _use_domain_admin_access: Default::default(), _transfer_ownership: Default::default(), _supports_team_drives: Default::default(), _supports_all_drives: Default::default(), _remove_expiration: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *property* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.properties(); /// # } /// ``` pub struct PropertyMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for PropertyMethods<'a, S> {} impl<'a, S> PropertyMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes a property. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `propertyKey` - The key of the property. pub fn delete(&self, file_id: &str, property_key: &str) -> PropertyDeleteCall<'a, S> { PropertyDeleteCall { hub: self.hub, _file_id: file_id.to_string(), _property_key: property_key.to_string(), _visibility: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a property by its key. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `propertyKey` - The key of the property. pub fn get(&self, file_id: &str, property_key: &str) -> PropertyGetCall<'a, S> { PropertyGetCall { hub: self.hub, _file_id: file_id.to_string(), _property_key: property_key.to_string(), _visibility: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Adds a property to a file, or updates it if it already exists. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. pub fn insert(&self, request: Property, file_id: &str) -> PropertyInsertCall<'a, S> { PropertyInsertCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists a file's properties. /// /// # Arguments /// /// * `fileId` - The ID of the file. pub fn list(&self, file_id: &str) -> PropertyListCall<'a, S> { PropertyListCall { hub: self.hub, _file_id: file_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a property. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `propertyKey` - The key of the property. pub fn patch(&self, request: Property, file_id: &str, property_key: &str) -> PropertyPatchCall<'a, S> { PropertyPatchCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _property_key: property_key.to_string(), _visibility: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a property. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `propertyKey` - The key of the property. pub fn update(&self, request: Property, file_id: &str, property_key: &str) -> PropertyUpdateCall<'a, S> { PropertyUpdateCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _property_key: property_key.to_string(), _visibility: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *reply* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.replies(); /// # } /// ``` pub struct ReplyMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for ReplyMethods<'a, S> {} impl<'a, S> ReplyMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes a reply. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. /// * `replyId` - The ID of the reply. pub fn delete(&self, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyDeleteCall<'a, S> { ReplyDeleteCall { hub: self.hub, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _reply_id: reply_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a reply. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. /// * `replyId` - The ID of the reply. pub fn get(&self, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyGetCall<'a, S> { ReplyGetCall { hub: self.hub, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _reply_id: reply_id.to_string(), _include_deleted: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a new reply to the given comment. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. pub fn insert(&self, request: CommentReply, file_id: &str, comment_id: &str) -> ReplyInsertCall<'a, S> { ReplyInsertCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all of the replies to a comment. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. pub fn list(&self, file_id: &str, comment_id: &str) -> ReplyListCall<'a, S> { ReplyListCall { hub: self.hub, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _page_token: Default::default(), _max_results: Default::default(), _include_deleted: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing reply. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. /// * `replyId` - The ID of the reply. pub fn patch(&self, request: CommentReply, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyPatchCall<'a, S> { ReplyPatchCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _reply_id: reply_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing reply. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID of the file. /// * `commentId` - The ID of the comment. /// * `replyId` - The ID of the reply. pub fn update(&self, request: CommentReply, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyUpdateCall<'a, S> { ReplyUpdateCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _comment_id: comment_id.to_string(), _reply_id: reply_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *revision* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.revisions(); /// # } /// ``` pub struct RevisionMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for RevisionMethods<'a, S> {} impl<'a, S> RevisionMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Permanently deletes a file version. You can only delete revisions for files with binary content, like images or videos. Revisions for other files, like Google Docs or Sheets, and the last remaining file version can't be deleted. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `revisionId` - The ID of the revision. pub fn delete(&self, file_id: &str, revision_id: &str) -> RevisionDeleteCall<'a, S> { RevisionDeleteCall { hub: self.hub, _file_id: file_id.to_string(), _revision_id: revision_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a specific revision. /// /// # Arguments /// /// * `fileId` - The ID of the file. /// * `revisionId` - The ID of the revision. pub fn get(&self, file_id: &str, revision_id: &str) -> RevisionGetCall<'a, S> { RevisionGetCall { hub: self.hub, _file_id: file_id.to_string(), _revision_id: revision_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists a file's revisions. /// /// # Arguments /// /// * `fileId` - The ID of the file. pub fn list(&self, file_id: &str) -> RevisionListCall<'a, S> { RevisionListCall { hub: self.hub, _file_id: file_id.to_string(), _page_token: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a revision. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID for the file. /// * `revisionId` - The ID for the revision. pub fn patch(&self, request: Revision, file_id: &str, revision_id: &str) -> RevisionPatchCall<'a, S> { RevisionPatchCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _revision_id: revision_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a revision. /// /// # Arguments /// /// * `request` - No description provided. /// * `fileId` - The ID for the file. /// * `revisionId` - The ID for the revision. pub fn update(&self, request: Revision, file_id: &str, revision_id: &str) -> RevisionUpdateCall<'a, S> { RevisionUpdateCall { hub: self.hub, _request: request, _file_id: file_id.to_string(), _revision_id: revision_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *teamdrive* resources. /// It is not used directly, but through the [`DriveHub`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_drive2 as drive2; /// /// # async fn dox() { /// use std::default::Default; /// use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)` and `update(...)` /// // to build up your call. /// let rb = hub.teamdrives(); /// # } /// ``` pub struct TeamdriveMethods<'a, S> where S: 'a { hub: &'a DriveHub, } impl<'a, S> client::MethodsBuilder for TeamdriveMethods<'a, S> {} impl<'a, S> TeamdriveMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deprecated: Use `drives.delete` instead. /// /// # Arguments /// /// * `teamDriveId` - The ID of the Team Drive pub fn delete(&self, team_drive_id: &str) -> TeamdriveDeleteCall<'a, S> { TeamdriveDeleteCall { hub: self.hub, _team_drive_id: team_drive_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deprecated: Use `drives.get` instead. /// /// # Arguments /// /// * `teamDriveId` - The ID of the Team Drive pub fn get(&self, team_drive_id: &str) -> TeamdriveGetCall<'a, S> { TeamdriveGetCall { hub: self.hub, _team_drive_id: team_drive_id.to_string(), _use_domain_admin_access: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deprecated: Use `drives.insert` instead. /// /// # Arguments /// /// * `request` - No description provided. /// * `requestId` - Required. 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. pub fn insert(&self, request: TeamDrive, request_id: &str) -> TeamdriveInsertCall<'a, S> { TeamdriveInsertCall { hub: self.hub, _request: request, _request_id: request_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deprecated: Use `drives.list` instead. pub fn list(&self) -> TeamdriveListCall<'a, S> { TeamdriveListCall { hub: self.hub, _use_domain_admin_access: Default::default(), _q: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deprecated: Use `drives.update` instead. /// /// # Arguments /// /// * `request` - No description provided. /// * `teamDriveId` - The ID of the Team Drive pub fn update(&self, request: TeamDrive, team_drive_id: &str) -> TeamdriveUpdateCall<'a, S> { TeamdriveUpdateCall { hub: self.hub, _request: request, _team_drive_id: team_drive_id.to_string(), _use_domain_admin_access: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } // ################### // CallBuilders ### // ################# /// Gets the information about the current user along with Drive API settings /// /// A builder for the *get* method supported by a *about* resource. /// It is not used directly, but through a [`AboutMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.about().get() /// .start_change_id(-30) /// .max_change_id_count(-9) /// .include_subscribed(true) /// .doit().await; /// # } /// ``` pub struct AboutGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _start_change_id: Option, _max_change_id_count: Option, _include_subscribed: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for AboutGetCall<'a, S> {} impl<'a, S> AboutGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, About)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.about.get", http_method: hyper::Method::GET }); for &field in ["alt", "startChangeId", "maxChangeIdCount", "includeSubscribed"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); if let Some(value) = self._start_change_id.as_ref() { params.push("startChangeId", value.to_string()); } if let Some(value) = self._max_change_id_count.as_ref() { params.push("maxChangeIdCount", value.to_string()); } if let Some(value) = self._include_subscribed.as_ref() { params.push("includeSubscribed", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "about"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Change ID to start counting from when calculating number of remaining change IDs /// /// Sets the *start change id* query property to the given value. pub fn start_change_id(mut self, new_value: i64) -> AboutGetCall<'a, S> { self._start_change_id = Some(new_value); self } /// Maximum number of remaining change IDs to count /// /// Sets the *max change id count* query property to the given value. pub fn max_change_id_count(mut self, new_value: i64) -> AboutGetCall<'a, S> { self._max_change_id_count = Some(new_value); self } /// Whether to count changes outside the My Drive hierarchy. When set to false, changes to files such as those in the Application Data folder or shared files which have not been added to My Drive will be omitted from the `maxChangeIdCount`. /// /// Sets the *include subscribed* query property to the given value. pub fn include_subscribed(mut self, new_value: bool) -> AboutGetCall<'a, S> { self._include_subscribed = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AboutGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> AboutGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> AboutGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AboutGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AboutGetCall<'a, S> { self._scopes.clear(); self } } /// Gets a specific app. /// /// A builder for the *get* method supported by a *app* resource. /// It is not used directly, but through a [`AppMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.apps().get("appId") /// .doit().await; /// # } /// ``` pub struct AppGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _app_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for AppGetCall<'a, S> {} impl<'a, S> AppGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, App)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.apps.get", http_method: hyper::Method::GET }); for &field in ["alt", "appId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("appId", self._app_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "apps/{appId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::AppReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{appId}", "appId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["appId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the app. /// /// Sets the *app id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn app_id(mut self, new_value: &str) -> AppGetCall<'a, S> { self._app_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AppGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> AppGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::AppReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> AppGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AppGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AppGetCall<'a, S> { self._scopes.clear(); self } } /// Lists a user's installed apps. /// /// A builder for the *list* method supported by a *app* resource. /// It is not used directly, but through a [`AppMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.apps().list() /// .language_code("accusam") /// .app_filter_mime_types("voluptua.") /// .app_filter_extensions("dolore") /// .doit().await; /// # } /// ``` pub struct AppListCall<'a, S> where S: 'a { hub: &'a DriveHub, _language_code: Option, _app_filter_mime_types: Option, _app_filter_extensions: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for AppListCall<'a, S> {} impl<'a, S> AppListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AppList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.apps.list", http_method: hyper::Method::GET }); for &field in ["alt", "languageCode", "appFilterMimeTypes", "appFilterExtensions"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); if let Some(value) = self._language_code.as_ref() { params.push("languageCode", value); } if let Some(value) = self._app_filter_mime_types.as_ref() { params.push("appFilterMimeTypes", value); } if let Some(value) = self._app_filter_extensions.as_ref() { params.push("appFilterExtensions", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "apps"; if self._scopes.is_empty() { self._scopes.insert(Scope::AppReadonly.as_ref().to_string()); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// A language or locale code, as defined by BCP 47, with some extensions from Unicode's LDML format (http://www.unicode.org/reports/tr35/). /// /// Sets the *language code* query property to the given value. pub fn language_code(mut self, new_value: &str) -> AppListCall<'a, S> { self._language_code = Some(new_value.to_string()); self } /// A comma-separated list of MIME types for open with filtering. All apps within the given app query scope which can open any of the given MIME types will be included in the response. If `appFilterExtensions` are provided as well, the result is a union of the two resulting app lists. /// /// Sets the *app filter mime types* query property to the given value. pub fn app_filter_mime_types(mut self, new_value: &str) -> AppListCall<'a, S> { self._app_filter_mime_types = Some(new_value.to_string()); self } /// A comma-separated list of file extensions for open with filtering. All apps within the given app query scope which can open any of the given file extensions will be included in the response. If `appFilterMimeTypes` are provided as well, the result is a union of the two resulting app lists. /// /// Sets the *app filter extensions* query property to the given value. pub fn app_filter_extensions(mut self, new_value: &str) -> AppListCall<'a, S> { self._app_filter_extensions = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AppListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> AppListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::AppReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> AppListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AppListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AppListCall<'a, S> { self._scopes.clear(); self } } /// Deprecated: Use `changes.getStartPageToken` and `changes.list` to retrieve recent changes. /// /// A builder for the *get* method supported by a *change* resource. /// It is not used directly, but through a [`ChangeMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.changes().get("changeId") /// .team_drive_id("dolore") /// .supports_team_drives(false) /// .supports_all_drives(false) /// .drive_id("Lorem") /// .doit().await; /// # } /// ``` pub struct ChangeGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _change_id: String, _team_drive_id: Option, _supports_team_drives: Option, _supports_all_drives: Option, _drive_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ChangeGetCall<'a, S> {} impl<'a, S> ChangeGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Change)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.changes.get", http_method: hyper::Method::GET }); for &field in ["alt", "changeId", "teamDriveId", "supportsTeamDrives", "supportsAllDrives", "driveId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("changeId", self._change_id); if let Some(value) = self._team_drive_id.as_ref() { params.push("teamDriveId", value); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._drive_id.as_ref() { params.push("driveId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "changes/{changeId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::AppReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{changeId}", "changeId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["changeId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the change. /// /// Sets the *change id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn change_id(mut self, new_value: &str) -> ChangeGetCall<'a, S> { self._change_id = new_value.to_string(); self } /// Deprecated: Use `driveId` instead. /// /// Sets the *team drive id* query property to the given value. pub fn team_drive_id(mut self, new_value: &str) -> ChangeGetCall<'a, S> { self._team_drive_id = Some(new_value.to_string()); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> ChangeGetCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> ChangeGetCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// The shared drive from which the change will be returned. /// /// Sets the *drive id* query property to the given value. pub fn drive_id(mut self, new_value: &str) -> ChangeGetCall<'a, S> { self._drive_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChangeGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ChangeGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::AppReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ChangeGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ChangeGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ChangeGetCall<'a, S> { self._scopes.clear(); self } } /// Gets the starting pageToken for listing future changes. /// /// A builder for the *getStartPageToken* method supported by a *change* resource. /// It is not used directly, but through a [`ChangeMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.changes().get_start_page_token() /// .team_drive_id("invidunt") /// .supports_team_drives(true) /// .supports_all_drives(false) /// .drive_id("et") /// .doit().await; /// # } /// ``` pub struct ChangeGetStartPageTokenCall<'a, S> where S: 'a { hub: &'a DriveHub, _team_drive_id: Option, _supports_team_drives: Option, _supports_all_drives: Option, _drive_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ChangeGetStartPageTokenCall<'a, S> {} impl<'a, S> ChangeGetStartPageTokenCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, StartPageToken)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.changes.getStartPageToken", http_method: hyper::Method::GET }); for &field in ["alt", "teamDriveId", "supportsTeamDrives", "supportsAllDrives", "driveId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); if let Some(value) = self._team_drive_id.as_ref() { params.push("teamDriveId", value); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._drive_id.as_ref() { params.push("driveId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "changes/startPageToken"; if self._scopes.is_empty() { self._scopes.insert(Scope::AppReadonly.as_ref().to_string()); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Deprecated: Use `driveId` instead. /// /// Sets the *team drive id* query property to the given value. pub fn team_drive_id(mut self, new_value: &str) -> ChangeGetStartPageTokenCall<'a, S> { self._team_drive_id = Some(new_value.to_string()); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> ChangeGetStartPageTokenCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> ChangeGetStartPageTokenCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// The ID of the shared drive for which the starting pageToken for listing future changes from that shared drive will be returned. /// /// Sets the *drive id* query property to the given value. pub fn drive_id(mut self, new_value: &str) -> ChangeGetStartPageTokenCall<'a, S> { self._drive_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChangeGetStartPageTokenCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ChangeGetStartPageTokenCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::AppReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ChangeGetStartPageTokenCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ChangeGetStartPageTokenCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ChangeGetStartPageTokenCall<'a, S> { self._scopes.clear(); self } } /// Lists the changes for a user or shared drive. /// /// A builder for the *list* method supported by a *change* resource. /// It is not used directly, but through a [`ChangeMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.changes().list() /// .team_drive_id("tempor") /// .supports_team_drives(true) /// .supports_all_drives(true) /// .start_change_id(-68) /// .spaces("sed") /// .page_token("no") /// .max_results(-85) /// .include_team_drive_items(false) /// .include_subscribed(false) /// .include_permissions_for_view("no") /// .include_labels("nonumy") /// .include_items_from_all_drives(false) /// .include_deleted(true) /// .include_corpus_removals(true) /// .drive_id("sadipscing") /// .doit().await; /// # } /// ``` pub struct ChangeListCall<'a, S> where S: 'a { hub: &'a DriveHub, _team_drive_id: Option, _supports_team_drives: Option, _supports_all_drives: Option, _start_change_id: Option, _spaces: Option, _page_token: Option, _max_results: Option, _include_team_drive_items: Option, _include_subscribed: Option, _include_permissions_for_view: Option, _include_labels: Option, _include_items_from_all_drives: Option, _include_deleted: Option, _include_corpus_removals: Option, _drive_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ChangeListCall<'a, S> {} impl<'a, S> ChangeListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ChangeList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.changes.list", http_method: hyper::Method::GET }); for &field in ["alt", "teamDriveId", "supportsTeamDrives", "supportsAllDrives", "startChangeId", "spaces", "pageToken", "maxResults", "includeTeamDriveItems", "includeSubscribed", "includePermissionsForView", "includeLabels", "includeItemsFromAllDrives", "includeDeleted", "includeCorpusRemovals", "driveId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(17 + self._additional_params.len()); if let Some(value) = self._team_drive_id.as_ref() { params.push("teamDriveId", value); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._start_change_id.as_ref() { params.push("startChangeId", value.to_string()); } if let Some(value) = self._spaces.as_ref() { params.push("spaces", value); } if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } if let Some(value) = self._include_team_drive_items.as_ref() { params.push("includeTeamDriveItems", value.to_string()); } if let Some(value) = self._include_subscribed.as_ref() { params.push("includeSubscribed", value.to_string()); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } if let Some(value) = self._include_items_from_all_drives.as_ref() { params.push("includeItemsFromAllDrives", value.to_string()); } if let Some(value) = self._include_deleted.as_ref() { params.push("includeDeleted", value.to_string()); } if let Some(value) = self._include_corpus_removals.as_ref() { params.push("includeCorpusRemovals", value.to_string()); } if let Some(value) = self._drive_id.as_ref() { params.push("driveId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "changes"; if self._scopes.is_empty() { self._scopes.insert(Scope::AppReadonly.as_ref().to_string()); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Deprecated: Use `driveId` instead. /// /// Sets the *team drive id* query property to the given value. pub fn team_drive_id(mut self, new_value: &str) -> ChangeListCall<'a, S> { self._team_drive_id = Some(new_value.to_string()); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> ChangeListCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> ChangeListCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Deprecated: Use `pageToken` instead. /// /// Sets the *start change id* query property to the given value. pub fn start_change_id(mut self, new_value: i64) -> ChangeListCall<'a, S> { self._start_change_id = Some(new_value); self } /// A comma-separated list of spaces to query. Supported values are `drive`, `appDataFolder` and `photos`. /// /// Sets the *spaces* query property to the given value. pub fn spaces(mut self, new_value: &str) -> ChangeListCall<'a, S> { self._spaces = Some(new_value.to_string()); self } /// 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. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ChangeListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of changes to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> ChangeListCall<'a, S> { self._max_results = Some(new_value); self } /// Deprecated: Use `includeItemsFromAllDrives` instead. /// /// Sets the *include team drive items* query property to the given value. pub fn include_team_drive_items(mut self, new_value: bool) -> ChangeListCall<'a, S> { self._include_team_drive_items = Some(new_value); self } /// Whether to include changes outside the My Drive hierarchy in the result. When set to false, changes to files such as those in the Application Data folder or shared files which have not been added to My Drive will be omitted from the result. /// /// Sets the *include subscribed* query property to the given value. pub fn include_subscribed(mut self, new_value: bool) -> ChangeListCall<'a, S> { self._include_subscribed = Some(new_value); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> ChangeListCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> ChangeListCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// Whether both My Drive and shared drive items should be included in results. /// /// Sets the *include items from all drives* query property to the given value. pub fn include_items_from_all_drives(mut self, new_value: bool) -> ChangeListCall<'a, S> { self._include_items_from_all_drives = Some(new_value); self } /// Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access. /// /// Sets the *include deleted* query property to the given value. pub fn include_deleted(mut self, new_value: bool) -> ChangeListCall<'a, S> { self._include_deleted = Some(new_value); self } /// 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. /// /// Sets the *include corpus removals* query property to the given value. pub fn include_corpus_removals(mut self, new_value: bool) -> ChangeListCall<'a, S> { self._include_corpus_removals = Some(new_value); self } /// The shared drive from which changes will be returned. If specified the change IDs will be reflective of the shared drive; use the combined drive ID and change ID as an identifier. /// /// Sets the *drive id* query property to the given value. pub fn drive_id(mut self, new_value: &str) -> ChangeListCall<'a, S> { self._drive_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChangeListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ChangeListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::AppReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ChangeListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ChangeListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ChangeListCall<'a, S> { self._scopes.clear(); self } } /// Subscribe to changes for a user. /// /// A builder for the *watch* method supported by a *change* resource. /// It is not used directly, but through a [`ChangeMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Channel; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.changes().watch(req) /// .team_drive_id("erat") /// .supports_team_drives(false) /// .supports_all_drives(true) /// .start_change_id(-57) /// .spaces("et") /// .page_token("sea") /// .max_results(-96) /// .include_team_drive_items(true) /// .include_subscribed(true) /// .include_permissions_for_view("est") /// .include_labels("aliquyam") /// .include_items_from_all_drives(false) /// .include_deleted(true) /// .include_corpus_removals(true) /// .drive_id("sit") /// .doit().await; /// # } /// ``` pub struct ChangeWatchCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Channel, _team_drive_id: Option, _supports_team_drives: Option, _supports_all_drives: Option, _start_change_id: Option, _spaces: Option, _page_token: Option, _max_results: Option, _include_team_drive_items: Option, _include_subscribed: Option, _include_permissions_for_view: Option, _include_labels: Option, _include_items_from_all_drives: Option, _include_deleted: Option, _include_corpus_removals: Option, _drive_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ChangeWatchCall<'a, S> {} impl<'a, S> ChangeWatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Channel)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.changes.watch", http_method: hyper::Method::POST }); for &field in ["alt", "teamDriveId", "supportsTeamDrives", "supportsAllDrives", "startChangeId", "spaces", "pageToken", "maxResults", "includeTeamDriveItems", "includeSubscribed", "includePermissionsForView", "includeLabels", "includeItemsFromAllDrives", "includeDeleted", "includeCorpusRemovals", "driveId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(18 + self._additional_params.len()); if let Some(value) = self._team_drive_id.as_ref() { params.push("teamDriveId", value); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._start_change_id.as_ref() { params.push("startChangeId", value.to_string()); } if let Some(value) = self._spaces.as_ref() { params.push("spaces", value); } if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } if let Some(value) = self._include_team_drive_items.as_ref() { params.push("includeTeamDriveItems", value.to_string()); } if let Some(value) = self._include_subscribed.as_ref() { params.push("includeSubscribed", value.to_string()); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } if let Some(value) = self._include_items_from_all_drives.as_ref() { params.push("includeItemsFromAllDrives", value.to_string()); } if let Some(value) = self._include_deleted.as_ref() { params.push("includeDeleted", value.to_string()); } if let Some(value) = self._include_corpus_removals.as_ref() { params.push("includeCorpusRemovals", value.to_string()); } if let Some(value) = self._drive_id.as_ref() { params.push("driveId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "changes/watch"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Channel) -> ChangeWatchCall<'a, S> { self._request = new_value; self } /// Deprecated: Use `driveId` instead. /// /// Sets the *team drive id* query property to the given value. pub fn team_drive_id(mut self, new_value: &str) -> ChangeWatchCall<'a, S> { self._team_drive_id = Some(new_value.to_string()); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Deprecated: Use `pageToken` instead. /// /// Sets the *start change id* query property to the given value. pub fn start_change_id(mut self, new_value: i64) -> ChangeWatchCall<'a, S> { self._start_change_id = Some(new_value); self } /// A comma-separated list of spaces to query. Supported values are `drive`, `appDataFolder` and `photos`. /// /// Sets the *spaces* query property to the given value. pub fn spaces(mut self, new_value: &str) -> ChangeWatchCall<'a, S> { self._spaces = Some(new_value.to_string()); self } /// 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. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ChangeWatchCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of changes to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> ChangeWatchCall<'a, S> { self._max_results = Some(new_value); self } /// Deprecated: Use `includeItemsFromAllDrives` instead. /// /// Sets the *include team drive items* query property to the given value. pub fn include_team_drive_items(mut self, new_value: bool) -> ChangeWatchCall<'a, S> { self._include_team_drive_items = Some(new_value); self } /// Whether to include changes outside the My Drive hierarchy in the result. When set to false, changes to files such as those in the Application Data folder or shared files which have not been added to My Drive will be omitted from the result. /// /// Sets the *include subscribed* query property to the given value. pub fn include_subscribed(mut self, new_value: bool) -> ChangeWatchCall<'a, S> { self._include_subscribed = Some(new_value); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> ChangeWatchCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> ChangeWatchCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// Whether both My Drive and shared drive items should be included in results. /// /// Sets the *include items from all drives* query property to the given value. pub fn include_items_from_all_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, S> { self._include_items_from_all_drives = Some(new_value); self } /// Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access. /// /// Sets the *include deleted* query property to the given value. pub fn include_deleted(mut self, new_value: bool) -> ChangeWatchCall<'a, S> { self._include_deleted = Some(new_value); self } /// 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. /// /// Sets the *include corpus removals* query property to the given value. pub fn include_corpus_removals(mut self, new_value: bool) -> ChangeWatchCall<'a, S> { self._include_corpus_removals = Some(new_value); self } /// The shared drive from which changes will be returned. If specified the change IDs will be reflective of the shared drive; use the combined drive ID and change ID as an identifier. /// /// Sets the *drive id* query property to the given value. pub fn drive_id(mut self, new_value: &str) -> ChangeWatchCall<'a, S> { self._drive_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChangeWatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ChangeWatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ChangeWatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ChangeWatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ChangeWatchCall<'a, S> { self._scopes.clear(); self } } /// Stops watching resources through this channel. /// /// A builder for the *stop* method supported by a *channel* resource. /// It is not used directly, but through a [`ChannelMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Channel; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.channels().stop(req) /// .doit().await; /// # } /// ``` pub struct ChannelStopCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Channel, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ChannelStopCall<'a, S> {} impl<'a, S> ChannelStopCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.channels.stop", http_method: hyper::Method::POST }); for &field in [].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(2 + self._additional_params.len()); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "channels/stop"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, S> { self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChannelStopCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ChannelStopCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ChannelStopCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ChannelStopCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ChannelStopCall<'a, S> { self._scopes.clear(); self } } /// Removes a child from a folder. /// /// A builder for the *delete* method supported by a *child* resource. /// It is not used directly, but through a [`ChildMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.children().delete("folderId", "childId") /// .enforce_single_parent(true) /// .doit().await; /// # } /// ``` pub struct ChildDeleteCall<'a, S> where S: 'a { hub: &'a DriveHub, _folder_id: String, _child_id: String, _enforce_single_parent: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ChildDeleteCall<'a, S> {} impl<'a, S> ChildDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.children.delete", http_method: hyper::Method::DELETE }); for &field in ["folderId", "childId", "enforceSingleParent"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("folderId", self._folder_id); params.push("childId", self._child_id); if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "files/{folderId}/children/{childId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{folderId}", "folderId"), ("{childId}", "childId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["childId", "folderId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the folder. /// /// Sets the *folder id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn folder_id(mut self, new_value: &str) -> ChildDeleteCall<'a, S> { self._folder_id = new_value.to_string(); self } /// The ID of the child. /// /// Sets the *child id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn child_id(mut self, new_value: &str) -> ChildDeleteCall<'a, S> { self._child_id = new_value.to_string(); self } /// Deprecated: If an item is not in a shared drive and its last parent is removed, the item is placed under its owner's root. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> ChildDeleteCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChildDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ChildDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ChildDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ChildDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ChildDeleteCall<'a, S> { self._scopes.clear(); self } } /// Gets a specific child reference. /// /// A builder for the *get* method supported by a *child* resource. /// It is not used directly, but through a [`ChildMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.children().get("folderId", "childId") /// .doit().await; /// # } /// ``` pub struct ChildGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _folder_id: String, _child_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ChildGetCall<'a, S> {} impl<'a, S> ChildGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ChildReference)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.children.get", http_method: hyper::Method::GET }); for &field in ["alt", "folderId", "childId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("folderId", self._folder_id); params.push("childId", self._child_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{folderId}/children/{childId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{folderId}", "folderId"), ("{childId}", "childId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["childId", "folderId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the folder. /// /// Sets the *folder id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn folder_id(mut self, new_value: &str) -> ChildGetCall<'a, S> { self._folder_id = new_value.to_string(); self } /// The ID of the child. /// /// Sets the *child id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn child_id(mut self, new_value: &str) -> ChildGetCall<'a, S> { self._child_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChildGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ChildGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ChildGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ChildGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ChildGetCall<'a, S> { self._scopes.clear(); self } } /// Inserts a file into a folder. /// /// A builder for the *insert* method supported by a *child* resource. /// It is not used directly, but through a [`ChildMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::ChildReference; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ChildReference::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.children().insert(req, "folderId") /// .supports_team_drives(true) /// .supports_all_drives(false) /// .enforce_single_parent(false) /// .doit().await; /// # } /// ``` pub struct ChildInsertCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: ChildReference, _folder_id: String, _supports_team_drives: Option, _supports_all_drives: Option, _enforce_single_parent: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ChildInsertCall<'a, S> {} impl<'a, S> ChildInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ChildReference)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.children.insert", http_method: hyper::Method::POST }); for &field in ["alt", "folderId", "supportsTeamDrives", "supportsAllDrives", "enforceSingleParent"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("folderId", self._folder_id); if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{folderId}/children"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{folderId}", "folderId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["folderId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: ChildReference) -> ChildInsertCall<'a, S> { self._request = new_value; self } /// The ID of the folder. /// /// Sets the *folder id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn folder_id(mut self, new_value: &str) -> ChildInsertCall<'a, S> { self._folder_id = new_value.to_string(); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> ChildInsertCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> ChildInsertCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Deprecated: Adding files to multiple folders is no longer supported. Use `shortcuts` instead. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> ChildInsertCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChildInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ChildInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ChildInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ChildInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ChildInsertCall<'a, S> { self._scopes.clear(); self } } /// Lists a folder's children. /// /// A builder for the *list* method supported by a *child* resource. /// It is not used directly, but through a [`ChildMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.children().list("folderId") /// .q("eirmod") /// .page_token("Lorem") /// .order_by("accusam") /// .max_results(-47) /// .doit().await; /// # } /// ``` pub struct ChildListCall<'a, S> where S: 'a { hub: &'a DriveHub, _folder_id: String, _q: Option, _page_token: Option, _order_by: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ChildListCall<'a, S> {} impl<'a, S> ChildListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ChildList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.children.list", http_method: hyper::Method::GET }); for &field in ["alt", "folderId", "q", "pageToken", "orderBy", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("folderId", self._folder_id); if let Some(value) = self._q.as_ref() { params.push("q", value); } if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._order_by.as_ref() { params.push("orderBy", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{folderId}/children"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{folderId}", "folderId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["folderId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the folder. /// /// Sets the *folder id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn folder_id(mut self, new_value: &str) -> ChildListCall<'a, S> { self._folder_id = new_value.to_string(); self } /// Query string for searching children. /// /// Sets the *q* query property to the given value. pub fn q(mut self, new_value: &str) -> ChildListCall<'a, S> { self._q = Some(new_value.to_string()); self } /// Page token for children. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ChildListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// A comma-separated list of sort keys. Valid keys are `createdDate`, `folder`, `lastViewedByMeDate`, `modifiedByMeDate`, `modifiedDate`, `quotaBytesUsed`, `recency`, `sharedWithMeDate`, `starred`, and `title`. Each key sorts ascending by default, but may be reversed with the `desc` modifier. Example usage: ?orderBy=folder,modifiedDate desc,title. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored. /// /// Sets the *order by* query property to the given value. pub fn order_by(mut self, new_value: &str) -> ChildListCall<'a, S> { self._order_by = Some(new_value.to_string()); self } /// Maximum number of children to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> ChildListCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChildListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ChildListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ChildListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ChildListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ChildListCall<'a, S> { self._scopes.clear(); self } } /// Deletes a comment. /// /// A builder for the *delete* method supported by a *comment* resource. /// It is not used directly, but through a [`CommentMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.comments().delete("fileId", "commentId") /// .doit().await; /// # } /// ``` pub struct CommentDeleteCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _comment_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for CommentDeleteCall<'a, S> {} impl<'a, S> CommentDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.comments.delete", http_method: hyper::Method::DELETE }); for &field in ["fileId", "commentId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("commentId", self._comment_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["commentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> CommentDeleteCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the comment. /// /// Sets the *comment id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn comment_id(mut self, new_value: &str) -> CommentDeleteCall<'a, S> { self._comment_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> CommentDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> CommentDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> CommentDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> CommentDeleteCall<'a, S> { self._scopes.clear(); self } } /// Gets a comment by ID. /// /// A builder for the *get* method supported by a *comment* resource. /// It is not used directly, but through a [`CommentMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.comments().get("fileId", "commentId") /// .include_deleted(true) /// .doit().await; /// # } /// ``` pub struct CommentGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _comment_id: String, _include_deleted: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for CommentGetCall<'a, S> {} impl<'a, S> CommentGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Comment)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.comments.get", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "commentId", "includeDeleted"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("commentId", self._comment_id); if let Some(value) = self._include_deleted.as_ref() { params.push("includeDeleted", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["commentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> CommentGetCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the comment. /// /// Sets the *comment id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn comment_id(mut self, new_value: &str) -> CommentGetCall<'a, S> { self._comment_id = new_value.to_string(); self } /// If set, this will succeed when retrieving a deleted comment, and will include any deleted replies. /// /// Sets the *include deleted* query property to the given value. pub fn include_deleted(mut self, new_value: bool) -> CommentGetCall<'a, S> { self._include_deleted = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> CommentGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> CommentGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> CommentGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> CommentGetCall<'a, S> { self._scopes.clear(); self } } /// Creates a new comment on the given file. /// /// A builder for the *insert* method supported by a *comment* resource. /// It is not used directly, but through a [`CommentMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Comment; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Comment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.comments().insert(req, "fileId") /// .doit().await; /// # } /// ``` pub struct CommentInsertCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Comment, _file_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for CommentInsertCall<'a, S> {} impl<'a, S> CommentInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Comment)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.comments.insert", http_method: hyper::Method::POST }); for &field in ["alt", "fileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("fileId", self._file_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Comment) -> CommentInsertCall<'a, S> { self._request = new_value; self } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> CommentInsertCall<'a, S> { self._file_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> CommentInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> CommentInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> CommentInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> CommentInsertCall<'a, S> { self._scopes.clear(); self } } /// Lists a file's comments. /// /// A builder for the *list* method supported by a *comment* resource. /// It is not used directly, but through a [`CommentMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.comments().list("fileId") /// .updated_min("At") /// .page_token("dolor") /// .max_results(-22) /// .include_deleted(true) /// .doit().await; /// # } /// ``` pub struct CommentListCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _updated_min: Option, _page_token: Option, _max_results: Option, _include_deleted: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for CommentListCall<'a, S> {} impl<'a, S> CommentListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CommentList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.comments.list", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "updatedMin", "pageToken", "maxResults", "includeDeleted"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._updated_min.as_ref() { params.push("updatedMin", value); } if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } if let Some(value) = self._include_deleted.as_ref() { params.push("includeDeleted", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> CommentListCall<'a, S> { self._file_id = new_value.to_string(); self } /// Only discussions that were updated after this timestamp will be returned. Formatted as an RFC 3339 timestamp. /// /// Sets the *updated min* query property to the given value. pub fn updated_min(mut self, new_value: &str) -> CommentListCall<'a, S> { self._updated_min = Some(new_value.to_string()); self } /// The continuation token, used to page through large result sets. To get the next page of results, set this parameter to the value of "nextPageToken" from the previous response. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> CommentListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// The maximum number of discussions to include in the response, used for paging. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> CommentListCall<'a, S> { self._max_results = Some(new_value); self } /// If set, all comments and replies, including deleted comments and replies (with content stripped) will be returned. /// /// Sets the *include deleted* query property to the given value. pub fn include_deleted(mut self, new_value: bool) -> CommentListCall<'a, S> { self._include_deleted = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> CommentListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> CommentListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> CommentListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> CommentListCall<'a, S> { self._scopes.clear(); self } } /// Updates an existing comment. /// /// A builder for the *patch* method supported by a *comment* resource. /// It is not used directly, but through a [`CommentMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Comment; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Comment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.comments().patch(req, "fileId", "commentId") /// .doit().await; /// # } /// ``` pub struct CommentPatchCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Comment, _file_id: String, _comment_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for CommentPatchCall<'a, S> {} impl<'a, S> CommentPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Comment)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.comments.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "fileId", "commentId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("commentId", self._comment_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["commentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Comment) -> CommentPatchCall<'a, S> { self._request = new_value; self } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> CommentPatchCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the comment. /// /// Sets the *comment id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn comment_id(mut self, new_value: &str) -> CommentPatchCall<'a, S> { self._comment_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> CommentPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> CommentPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> CommentPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> CommentPatchCall<'a, S> { self._scopes.clear(); self } } /// Updates an existing comment. /// /// A builder for the *update* method supported by a *comment* resource. /// It is not used directly, but through a [`CommentMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Comment; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Comment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.comments().update(req, "fileId", "commentId") /// .doit().await; /// # } /// ``` pub struct CommentUpdateCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Comment, _file_id: String, _comment_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for CommentUpdateCall<'a, S> {} impl<'a, S> CommentUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Comment)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.comments.update", http_method: hyper::Method::PUT }); for &field in ["alt", "fileId", "commentId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("commentId", self._comment_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["commentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Comment) -> CommentUpdateCall<'a, S> { self._request = new_value; self } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> CommentUpdateCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the comment. /// /// Sets the *comment id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn comment_id(mut self, new_value: &str) -> CommentUpdateCall<'a, S> { self._comment_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> CommentUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> CommentUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> CommentUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> CommentUpdateCall<'a, S> { self._scopes.clear(); self } } /// Permanently deletes a shared drive for which the user is an `organizer`. The shared drive cannot contain any untrashed items. /// /// A builder for the *delete* method supported by a *drive* resource. /// It is not used directly, but through a [`DriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.drives().delete("driveId") /// .use_domain_admin_access(true) /// .allow_item_deletion(false) /// .doit().await; /// # } /// ``` pub struct DriveDeleteCall<'a, S> where S: 'a { hub: &'a DriveHub, _drive_id: String, _use_domain_admin_access: Option, _allow_item_deletion: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for DriveDeleteCall<'a, S> {} impl<'a, S> DriveDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.drives.delete", http_method: hyper::Method::DELETE }); for &field in ["driveId", "useDomainAdminAccess", "allowItemDeletion"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("driveId", self._drive_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } if let Some(value) = self._allow_item_deletion.as_ref() { params.push("allowItemDeletion", value.to_string()); } params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "drives/{driveId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{driveId}", "driveId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["driveId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the shared drive. /// /// Sets the *drive id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn drive_id(mut self, new_value: &str) -> DriveDeleteCall<'a, S> { self._drive_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveDeleteCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// Whether any items inside the shared drive should also be deleted. This option is only supported when `useDomainAdminAccess` is also set to `true`. /// /// Sets the *allow item deletion* query property to the given value. pub fn allow_item_deletion(mut self, new_value: bool) -> DriveDeleteCall<'a, S> { self._allow_item_deletion = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> DriveDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> DriveDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> DriveDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> DriveDeleteCall<'a, S> { self._scopes.clear(); self } } /// Gets a shared drive's metadata by ID. /// /// A builder for the *get* method supported by a *drive* resource. /// It is not used directly, but through a [`DriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.drives().get("driveId") /// .use_domain_admin_access(false) /// .doit().await; /// # } /// ``` pub struct DriveGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _drive_id: String, _use_domain_admin_access: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for DriveGetCall<'a, S> {} impl<'a, S> DriveGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Drive)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.drives.get", http_method: hyper::Method::GET }); for &field in ["alt", "driveId", "useDomainAdminAccess"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("driveId", self._drive_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "drives/{driveId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } for &(find_this, param_name) in [("{driveId}", "driveId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["driveId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the shared drive. /// /// Sets the *drive id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn drive_id(mut self, new_value: &str) -> DriveGetCall<'a, S> { self._drive_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveGetCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> DriveGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> DriveGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> DriveGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> DriveGetCall<'a, S> { self._scopes.clear(); self } } /// Hides a shared drive from the default view. /// /// A builder for the *hide* method supported by a *drive* resource. /// It is not used directly, but through a [`DriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.drives().hide("driveId") /// .doit().await; /// # } /// ``` pub struct DriveHideCall<'a, S> where S: 'a { hub: &'a DriveHub, _drive_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for DriveHideCall<'a, S> {} impl<'a, S> DriveHideCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Drive)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.drives.hide", http_method: hyper::Method::POST }); for &field in ["alt", "driveId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("driveId", self._drive_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "drives/{driveId}/hide"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{driveId}", "driveId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["driveId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the shared drive. /// /// Sets the *drive id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn drive_id(mut self, new_value: &str) -> DriveHideCall<'a, S> { self._drive_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveHideCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> DriveHideCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> DriveHideCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> DriveHideCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> DriveHideCall<'a, S> { self._scopes.clear(); self } } /// Creates a new shared drive. /// /// A builder for the *insert* method supported by a *drive* resource. /// It is not used directly, but through a [`DriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Drive; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Drive::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.drives().insert(req, "requestId") /// .doit().await; /// # } /// ``` pub struct DriveInsertCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Drive, _request_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for DriveInsertCall<'a, S> {} impl<'a, S> DriveInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Drive)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.drives.insert", http_method: hyper::Method::POST }); for &field in ["alt", "requestId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("requestId", self._request_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "drives"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Drive) -> DriveInsertCall<'a, S> { self._request = new_value; self } /// Required. 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. /// /// Sets the *request id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request_id(mut self, new_value: &str) -> DriveInsertCall<'a, S> { self._request_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> DriveInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> DriveInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> DriveInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> DriveInsertCall<'a, S> { self._scopes.clear(); self } } /// Lists the user’s shared drives. This method accepts the `q` parameter, which is a search query combining one or more search terms. For more information, see the [Search for shared drives](https://developers.google.com/drive/api/guides/search-shareddrives) guide. /// /// A builder for the *list* method supported by a *drive* resource. /// It is not used directly, but through a [`DriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.drives().list() /// .use_domain_admin_access(true) /// .q("dolor") /// .page_token("aliquyam") /// .max_results(-61) /// .doit().await; /// # } /// ``` pub struct DriveListCall<'a, S> where S: 'a { hub: &'a DriveHub, _use_domain_admin_access: Option, _q: Option, _page_token: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for DriveListCall<'a, S> {} impl<'a, S> DriveListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, DriveList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.drives.list", http_method: hyper::Method::GET }); for &field in ["alt", "useDomainAdminAccess", "q", "pageToken", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } if let Some(value) = self._q.as_ref() { params.push("q", value); } if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "drives"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveListCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// Query string for searching shared drives. /// /// Sets the *q* query property to the given value. pub fn q(mut self, new_value: &str) -> DriveListCall<'a, S> { self._q = Some(new_value.to_string()); self } /// Page token for shared drives. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> DriveListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of shared drives to return per page. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> DriveListCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> DriveListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> DriveListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> DriveListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> DriveListCall<'a, S> { self._scopes.clear(); self } } /// Restores a shared drive to the default view. /// /// A builder for the *unhide* method supported by a *drive* resource. /// It is not used directly, but through a [`DriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.drives().unhide("driveId") /// .doit().await; /// # } /// ``` pub struct DriveUnhideCall<'a, S> where S: 'a { hub: &'a DriveHub, _drive_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for DriveUnhideCall<'a, S> {} impl<'a, S> DriveUnhideCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Drive)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.drives.unhide", http_method: hyper::Method::POST }); for &field in ["alt", "driveId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("driveId", self._drive_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "drives/{driveId}/unhide"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{driveId}", "driveId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["driveId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the shared drive. /// /// Sets the *drive id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn drive_id(mut self, new_value: &str) -> DriveUnhideCall<'a, S> { self._drive_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveUnhideCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> DriveUnhideCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> DriveUnhideCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> DriveUnhideCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> DriveUnhideCall<'a, S> { self._scopes.clear(); self } } /// Updates the metadata for a shared drive. /// /// A builder for the *update* method supported by a *drive* resource. /// It is not used directly, but through a [`DriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Drive; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Drive::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.drives().update(req, "driveId") /// .use_domain_admin_access(true) /// .doit().await; /// # } /// ``` pub struct DriveUpdateCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Drive, _drive_id: String, _use_domain_admin_access: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for DriveUpdateCall<'a, S> {} impl<'a, S> DriveUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Drive)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.drives.update", http_method: hyper::Method::PUT }); for &field in ["alt", "driveId", "useDomainAdminAccess"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("driveId", self._drive_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "drives/{driveId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{driveId}", "driveId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["driveId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Drive) -> DriveUpdateCall<'a, S> { self._request = new_value; self } /// The ID of the shared drive. /// /// Sets the *drive id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn drive_id(mut self, new_value: &str) -> DriveUpdateCall<'a, S> { self._drive_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveUpdateCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> DriveUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> DriveUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> DriveUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> DriveUpdateCall<'a, S> { self._scopes.clear(); self } } /// Creates a copy of the specified file. /// /// A builder for the *copy* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::File; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = File::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().copy(req, "fileId") /// .visibility("gubergren") /// .timed_text_track_name("sadipscing") /// .timed_text_language("At") /// .supports_team_drives(true) /// .supports_all_drives(true) /// .pinned(false) /// .ocr_language("et") /// .ocr(true) /// .include_permissions_for_view("dolor") /// .include_labels("Lorem") /// .enforce_single_parent(false) /// .convert(true) /// .doit().await; /// # } /// ``` pub struct FileCopyCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: File, _file_id: String, _visibility: Option, _timed_text_track_name: Option, _timed_text_language: Option, _supports_team_drives: Option, _supports_all_drives: Option, _pinned: Option, _ocr_language: Option, _ocr: Option, _include_permissions_for_view: Option, _include_labels: Option, _enforce_single_parent: Option, _convert: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileCopyCall<'a, S> {} impl<'a, S> FileCopyCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, File)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.copy", http_method: hyper::Method::POST }); for &field in ["alt", "fileId", "visibility", "timedTextTrackName", "timedTextLanguage", "supportsTeamDrives", "supportsAllDrives", "pinned", "ocrLanguage", "ocr", "includePermissionsForView", "includeLabels", "enforceSingleParent", "convert"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(16 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._visibility.as_ref() { params.push("visibility", value); } if let Some(value) = self._timed_text_track_name.as_ref() { params.push("timedTextTrackName", value); } if let Some(value) = self._timed_text_language.as_ref() { params.push("timedTextLanguage", value); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._pinned.as_ref() { params.push("pinned", value.to_string()); } if let Some(value) = self._ocr_language.as_ref() { params.push("ocrLanguage", value); } if let Some(value) = self._ocr.as_ref() { params.push("ocr", value.to_string()); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } if let Some(value) = self._convert.as_ref() { params.push("convert", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/copy"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: File) -> FileCopyCall<'a, S> { self._request = new_value; self } /// The ID of the file to copy. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileCopyCall<'a, S> { self._file_id = new_value.to_string(); self } /// The visibility of the new file. This parameter is only relevant when the source is not a native Google Doc and convert=false. /// /// Sets the *visibility* query property to the given value. pub fn visibility(mut self, new_value: &str) -> FileCopyCall<'a, S> { self._visibility = Some(new_value.to_string()); self } /// The timed text track name. /// /// Sets the *timed text track name* query property to the given value. pub fn timed_text_track_name(mut self, new_value: &str) -> FileCopyCall<'a, S> { self._timed_text_track_name = Some(new_value.to_string()); self } /// The language of the timed text. /// /// Sets the *timed text language* query property to the given value. pub fn timed_text_language(mut self, new_value: &str) -> FileCopyCall<'a, S> { self._timed_text_language = Some(new_value.to_string()); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FileCopyCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FileCopyCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Whether to pin the head revision of the new copy. A file can have a maximum of 200 pinned revisions. /// /// Sets the *pinned* query property to the given value. pub fn pinned(mut self, new_value: bool) -> FileCopyCall<'a, S> { self._pinned = Some(new_value); self } /// If `ocr` is true, hints at the language to use. Valid values are BCP 47 codes. /// /// Sets the *ocr language* query property to the given value. pub fn ocr_language(mut self, new_value: &str) -> FileCopyCall<'a, S> { self._ocr_language = Some(new_value.to_string()); self } /// Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads. /// /// Sets the *ocr* query property to the given value. pub fn ocr(mut self, new_value: bool) -> FileCopyCall<'a, S> { self._ocr = Some(new_value); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> FileCopyCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> FileCopyCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// Deprecated: Copying files into multiple folders is no longer supported. Use shortcuts instead. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> FileCopyCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// Whether to convert this file to the corresponding Docs Editors format. /// /// Sets the *convert* query property to the given value. pub fn convert(mut self, new_value: bool) -> FileCopyCall<'a, S> { self._convert = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileCopyCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileCopyCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileCopyCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileCopyCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileCopyCall<'a, S> { self._scopes.clear(); self } } /// 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 folder. If the target is a folder, all descendants owned by the user are also deleted. /// /// A builder for the *delete* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().delete("fileId") /// .supports_team_drives(false) /// .supports_all_drives(true) /// .enforce_single_parent(false) /// .doit().await; /// # } /// ``` pub struct FileDeleteCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _supports_team_drives: Option, _supports_all_drives: Option, _enforce_single_parent: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileDeleteCall<'a, S> {} impl<'a, S> FileDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.delete", http_method: hyper::Method::DELETE }); for &field in ["fileId", "supportsTeamDrives", "supportsAllDrives", "enforceSingleParent"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "files/{fileId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file to delete. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileDeleteCall<'a, S> { self._file_id = new_value.to_string(); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FileDeleteCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FileDeleteCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Deprecated: If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item is placed under its owner's root. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> FileDeleteCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileDeleteCall<'a, S> { self._scopes.clear(); self } } /// Permanently deletes all of the user's trashed files. /// /// A builder for the *emptyTrash* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().empty_trash() /// .enforce_single_parent(true) /// .drive_id("nonumy") /// .doit().await; /// # } /// ``` pub struct FileEmptyTrashCall<'a, S> where S: 'a { hub: &'a DriveHub, _enforce_single_parent: Option, _drive_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileEmptyTrashCall<'a, S> {} impl<'a, S> FileEmptyTrashCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.emptyTrash", http_method: hyper::Method::DELETE }); for &field in ["enforceSingleParent", "driveId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } if let Some(value) = self._drive_id.as_ref() { params.push("driveId", value); } params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "files/trash"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// Deprecated: If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item is placed under its owner's root. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> FileEmptyTrashCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// If set, empties the trash of the provided shared drive. /// /// Sets the *drive id* query property to the given value. pub fn drive_id(mut self, new_value: &str) -> FileEmptyTrashCall<'a, S> { self._drive_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileEmptyTrashCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileEmptyTrashCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileEmptyTrashCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileEmptyTrashCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileEmptyTrashCall<'a, S> { self._scopes.clear(); self } } /// Exports a Google Workspace document to the requested MIME type and returns exported byte content. Note that the exported content is limited to 10MB. /// /// This method supports **media download**. To enable it, adjust the builder like this: /// `.param("alt", "media")`. /// /// A builder for the *export* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().export("fileId", "mimeType") /// .doit().await; /// # } /// ``` pub struct FileExportCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _mime_type: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileExportCall<'a, S> {} impl<'a, S> FileExportCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.export", http_method: hyper::Method::GET }); for &field in ["fileId", "mimeType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("mimeType", self._mime_type); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "files/{fileId}/export"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileExportCall<'a, S> { self._file_id = new_value.to_string(); self } /// Required. The MIME type of the format requested for this export. /// /// Sets the *mime type* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn mime_type(mut self, new_value: &str) -> FileExportCall<'a, S> { self._mime_type = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileExportCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileExportCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileExportCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileExportCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileExportCall<'a, S> { self._scopes.clear(); self } } /// Generates a set of file IDs which can be provided in insert or copy requests. /// /// A builder for the *generateIds* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().generate_ids() /// .type_("dolore") /// .space("eos") /// .max_results(-52) /// .doit().await; /// # } /// ``` pub struct FileGenerateIdCall<'a, S> where S: 'a { hub: &'a DriveHub, _type_: Option, _space: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileGenerateIdCall<'a, S> {} impl<'a, S> FileGenerateIdCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, GeneratedIds)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.generateIds", http_method: hyper::Method::GET }); for &field in ["alt", "type", "space", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); if let Some(value) = self._type_.as_ref() { params.push("type", value); } if let Some(value) = self._space.as_ref() { params.push("space", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/generateIds"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// 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`) /// /// Sets the *type* query property to the given value. pub fn type_(mut self, new_value: &str) -> FileGenerateIdCall<'a, S> { self._type_ = Some(new_value.to_string()); self } /// The space in which the IDs can be used to create new files. Supported values are `drive` and `appDataFolder`. (Default: `drive`) /// /// Sets the *space* query property to the given value. pub fn space(mut self, new_value: &str) -> FileGenerateIdCall<'a, S> { self._space = Some(new_value.to_string()); self } /// Maximum number of IDs to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> FileGenerateIdCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileGenerateIdCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileGenerateIdCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileGenerateIdCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileGenerateIdCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileGenerateIdCall<'a, S> { self._scopes.clear(); self } } /// Gets a file’s metadata or content by ID. If you provide the URL parameter `alt=media`, then the response includes the file contents in the response body. Downloading content with `alt=media` only works if the file is stored in Drive. To download Google Docs, Sheets, and Slides use [`files.export`](https://developers.google.com/drive/api/reference/rest/v2/files/export) instead. For more information, see [Download & export files](https://developers.google.com/drive/api/guides/manage-downloads). /// /// This method supports **media download**. To enable it, adjust the builder like this: /// `.param("alt", "media")`. /// Please note that due to missing multi-part support on the server side, you will only receive the media, /// but not the `File` structure that you would usually get. The latter will be a default value. /// /// A builder for the *get* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().get("fileId") /// .update_viewed_date(false) /// .supports_team_drives(true) /// .supports_all_drives(false) /// .revision_id("duo") /// .projection("sadipscing") /// .include_permissions_for_view("ut") /// .include_labels("rebum.") /// .acknowledge_abuse(false) /// .doit().await; /// # } /// ``` pub struct FileGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _update_viewed_date: Option, _supports_team_drives: Option, _supports_all_drives: Option, _revision_id: Option, _projection: Option, _include_permissions_for_view: Option, _include_labels: Option, _acknowledge_abuse: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileGetCall<'a, S> {} impl<'a, S> FileGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, File)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.get", http_method: hyper::Method::GET }); for &field in ["fileId", "updateViewedDate", "supportsTeamDrives", "supportsAllDrives", "revisionId", "projection", "includePermissionsForView", "includeLabels", "acknowledgeAbuse"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(10 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._update_viewed_date.as_ref() { params.push("updateViewedDate", value.to_string()); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._revision_id.as_ref() { params.push("revisionId", value); } if let Some(value) = self._projection.as_ref() { params.push("projection", value); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } if let Some(value) = self._acknowledge_abuse.as_ref() { params.push("acknowledgeAbuse", value.to_string()); } params.extend(self._additional_params.iter()); let (alt_field_missing, enable_resource_parsing) = { if let Some(value) = params.get("alt") { (false, value == "json") } else { (true, true) } }; if alt_field_missing { params.push("alt", "json"); } let mut url = self.hub._base_url.clone() + "files/{fileId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = if enable_resource_parsing { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } } else { (res, Default::default()) }; dlg.finished(true); return Ok(result_value) } } } } /// The ID for the file in question. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileGetCall<'a, S> { self._file_id = new_value.to_string(); self } /// Deprecated: Use `files.update` with `modifiedDateBehavior=noChange, updateViewedDate=true` and an empty request body. /// /// Sets the *update viewed date* query property to the given value. pub fn update_viewed_date(mut self, new_value: bool) -> FileGetCall<'a, S> { self._update_viewed_date = Some(new_value); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FileGetCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FileGetCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Specifies the Revision ID that should be downloaded. Ignored unless alt=media is specified. /// /// Sets the *revision id* query property to the given value. pub fn revision_id(mut self, new_value: &str) -> FileGetCall<'a, S> { self._revision_id = Some(new_value.to_string()); self } /// Deprecated: This parameter has no function. /// /// Sets the *projection* query property to the given value. pub fn projection(mut self, new_value: &str) -> FileGetCall<'a, S> { self._projection = Some(new_value.to_string()); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> FileGetCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> FileGetCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. /// /// Sets the *acknowledge abuse* query property to the given value. pub fn acknowledge_abuse(mut self, new_value: bool) -> FileGetCall<'a, S> { self._acknowledge_abuse = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileGetCall<'a, S> { self._scopes.clear(); self } } /// Inserts a new file. This method supports an */upload* URI and accepts uploaded media with the following characteristics: - *Maximum file size:* 5,120 GB - *Accepted Media MIME types:*`*/*` Note: Specify a valid MIME type, rather than the literal `*/*` value. The literal `*/*` is only used to indicate that any valid MIME type can be uploaded. For more information on uploading files, see [Upload file data](https://developers.google.com/drive/api/guides/manage-uploads). Apps creating shortcuts with `files.insert` must specify the MIME type `application/vnd.google-apps.shortcut`. Apps should specify a file extension in the `title` property when inserting files with the API. For example, an operation to insert a JPEG file should specify something like `"title": "cat.jpg"` in the metadata. Subsequent `GET` requests include the read-only `fileExtension` property populated with the extension originally specified in the `title` property. When a Google Drive user requests to download a file, or when the file is downloaded through the sync client, Drive builds a full filename (with extension) based on the title. In cases where the extension is missing, Drive attempts to determine the extension based on the file’s MIME type. /// /// A builder for the *insert* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::File; /// use std::fs; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = File::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().insert(req) /// .visibility("kasd") /// .use_content_as_indexable_text(false) /// .timed_text_track_name("tempor") /// .timed_text_language("sea") /// .supports_team_drives(false) /// .supports_all_drives(true) /// .pinned(true) /// .ocr_language("rebum.") /// .ocr(false) /// .include_permissions_for_view("clita") /// .include_labels("Stet") /// .enforce_single_parent(false) /// .convert(false) /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; /// # } /// ``` pub struct FileInsertCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: File, _visibility: Option, _use_content_as_indexable_text: Option, _timed_text_track_name: Option, _timed_text_language: Option, _supports_team_drives: Option, _supports_all_drives: Option, _pinned: Option, _ocr_language: Option, _ocr: Option, _include_permissions_for_view: Option, _include_labels: Option, _enforce_single_parent: Option, _convert: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileInsertCall<'a, S> {} impl<'a, S> FileInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, File)> where RS: client::ReadSeek { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.insert", http_method: hyper::Method::POST }); for &field in ["alt", "visibility", "useContentAsIndexableText", "timedTextTrackName", "timedTextLanguage", "supportsTeamDrives", "supportsAllDrives", "pinned", "ocrLanguage", "ocr", "includePermissionsForView", "includeLabels", "enforceSingleParent", "convert"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(16 + self._additional_params.len()); if let Some(value) = self._visibility.as_ref() { params.push("visibility", value); } if let Some(value) = self._use_content_as_indexable_text.as_ref() { params.push("useContentAsIndexableText", value.to_string()); } if let Some(value) = self._timed_text_track_name.as_ref() { params.push("timedTextTrackName", value); } if let Some(value) = self._timed_text_language.as_ref() { params.push("timedTextLanguage", value); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._pinned.as_ref() { params.push("pinned", value.to_string()); } if let Some(value) = self._ocr_language.as_ref() { params.push("ocrLanguage", value); } if let Some(value) = self._ocr.as_ref() { params.push("ocr", value.to_string()); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } if let Some(value) = self._convert.as_ref() { params.push("convert", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let (mut url, upload_type) = if protocol == client::UploadProtocol::Resumable { (self.hub._root_url.clone() + "resumable/upload/drive/v2/files", "resumable") } else if protocol == client::UploadProtocol::Simple { (self.hub._root_url.clone() + "upload/drive/v2/files", "multipart") } else { unreachable!() }; params.push("uploadType", upload_type); if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut should_ask_dlg_for_url = false; let mut upload_url_from_server; let mut upload_url: Option = None; loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; upload_url_from_server = false; Ok(hyper::Response::builder() .status(hyper::StatusCode::OK) .header("Location", upload_url.as_ref().unwrap().clone()) .body(hyper::body::Body::empty()) .unwrap()) } else { let mut mp_reader: client::MultiPartReader = Default::default(); let (mut body_reader, content_type) = match protocol { client::UploadProtocol::Simple => { mp_reader.reserve_exact(2); let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 5497558138880 { return Err(client::Error::UploadSizeLimitExceeded(size, 5497558138880)) } mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) .add_part(&mut reader, size, reader_mime_type.clone()); (&mut mp_reader as &mut (dyn io::Read + Send), client::MultiPartReader::mime_type()) }, _ => (&mut request_value_reader as &mut (dyn io::Read + Send), json_mime_type.clone()), }; let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } upload_url_from_server = true; if protocol == client::UploadProtocol::Resumable { req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); } let mut body_reader_bytes = vec![]; body_reader.read_to_end(&mut body_reader_bytes).unwrap(); let request = req_builder .header(CONTENT_TYPE, content_type.to_string()) .body(hyper::body::Body::from(body_reader_bytes)); client.request(request.unwrap()).await } }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } if protocol == client::UploadProtocol::Resumable { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 5497558138880 { return Err(client::Error::UploadSizeLimitExceeded(size, 5497558138880)) } let upload_result = { let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); if upload_url_from_server { dlg.store_upload_url(Some(url_str)); } client::ResumableUploadHelper { client: &self.hub.client, delegate: dlg, start_at: if upload_url_from_server { Some(0) } else { None }, auth: &self.hub.auth, user_agent: &self.hub._user_agent, // TODO: Check this assumption auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size }.upload().await }; match upload_result { None => { dlg.finished(false); return Err(client::Error::Cancelled) } Some(Err(err)) => { dlg.finished(false); return Err(client::Error::HttpError(err)) } Some(Ok(upload_result)) => { res = upload_result; if !res.status().is_success() { dlg.store_upload_url(None); dlg.finished(false); return Err(client::Error::Failure(res)) } } } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Upload media in a resumable fashion. /// Even if the upload fails or is interrupted, it can be resumed for a /// certain amount of time as the server maintains state temporarily. /// /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using /// `cancel_chunk_upload(...)`. /// /// * *multipart*: yes /// * *max size*: 5497558138880 /// * *valid mime types*: '*/*' pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, File)> where RS: client::ReadSeek { self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await } /// Upload media all at once. /// If the upload fails for whichever reason, all progress is lost. /// /// * *multipart*: yes /// * *max size*: 5497558138880 /// * *valid mime types*: '*/*' pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, File)> where RS: client::ReadSeek { self.doit(stream, mime_type, client::UploadProtocol::Simple).await } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: File) -> FileInsertCall<'a, S> { self._request = new_value; self } /// The visibility of the new file. This parameter is only relevant when convert=false. /// /// Sets the *visibility* query property to the given value. pub fn visibility(mut self, new_value: &str) -> FileInsertCall<'a, S> { self._visibility = Some(new_value.to_string()); self } /// Whether to use the content as indexable text. /// /// Sets the *use content as indexable text* query property to the given value. pub fn use_content_as_indexable_text(mut self, new_value: bool) -> FileInsertCall<'a, S> { self._use_content_as_indexable_text = Some(new_value); self } /// The timed text track name. /// /// Sets the *timed text track name* query property to the given value. pub fn timed_text_track_name(mut self, new_value: &str) -> FileInsertCall<'a, S> { self._timed_text_track_name = Some(new_value.to_string()); self } /// The language of the timed text. /// /// Sets the *timed text language* query property to the given value. pub fn timed_text_language(mut self, new_value: &str) -> FileInsertCall<'a, S> { self._timed_text_language = Some(new_value.to_string()); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FileInsertCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FileInsertCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Whether to pin the head revision of the uploaded file. A file can have a maximum of 200 pinned revisions. /// /// Sets the *pinned* query property to the given value. pub fn pinned(mut self, new_value: bool) -> FileInsertCall<'a, S> { self._pinned = Some(new_value); self } /// If ocr is true, hints at the language to use. Valid values are BCP 47 codes. /// /// Sets the *ocr language* query property to the given value. pub fn ocr_language(mut self, new_value: &str) -> FileInsertCall<'a, S> { self._ocr_language = Some(new_value.to_string()); self } /// Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads. /// /// Sets the *ocr* query property to the given value. pub fn ocr(mut self, new_value: bool) -> FileInsertCall<'a, S> { self._ocr = Some(new_value); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> FileInsertCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> FileInsertCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// Deprecated: Creating files in multiple folders is no longer supported. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> FileInsertCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// Whether to convert this file to the corresponding Docs Editors format. /// /// Sets the *convert* query property to the given value. pub fn convert(mut self, new_value: bool) -> FileInsertCall<'a, S> { self._convert = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileInsertCall<'a, S> { self._scopes.clear(); self } } /// Lists the user’s files. This method accepts the `q` parameter, which is a search query combining one or more search terms. For more information, see the [Search for files & folders](https://developers.google.com/drive/api/guides/search-files) guide. *Note:* This method returns *all* files by default, including trashed files. If you don’t want trashed files to appear in the list, use the `trashed=false` query parameter to remove trashed files from the results. /// /// A builder for the *list* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().list() /// .team_drive_id("dolores") /// .supports_team_drives(true) /// .supports_all_drives(true) /// .spaces("dolor") /// .q("aliquyam") /// .projection("magna") /// .page_token("diam") /// .order_by("nonumy") /// .max_results(-18) /// .include_team_drive_items(true) /// .include_permissions_for_view("sed") /// .include_labels("est") /// .include_items_from_all_drives(false) /// .drive_id("diam") /// .corpus("At") /// .corpora("erat") /// .doit().await; /// # } /// ``` pub struct FileListCall<'a, S> where S: 'a { hub: &'a DriveHub, _team_drive_id: Option, _supports_team_drives: Option, _supports_all_drives: Option, _spaces: Option, _q: Option, _projection: Option, _page_token: Option, _order_by: Option, _max_results: Option, _include_team_drive_items: Option, _include_permissions_for_view: Option, _include_labels: Option, _include_items_from_all_drives: Option, _drive_id: Option, _corpus: Option, _corpora: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileListCall<'a, S> {} impl<'a, S> FileListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FileList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.list", http_method: hyper::Method::GET }); for &field in ["alt", "teamDriveId", "supportsTeamDrives", "supportsAllDrives", "spaces", "q", "projection", "pageToken", "orderBy", "maxResults", "includeTeamDriveItems", "includePermissionsForView", "includeLabels", "includeItemsFromAllDrives", "driveId", "corpus", "corpora"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(18 + self._additional_params.len()); if let Some(value) = self._team_drive_id.as_ref() { params.push("teamDriveId", value); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._spaces.as_ref() { params.push("spaces", value); } if let Some(value) = self._q.as_ref() { params.push("q", value); } if let Some(value) = self._projection.as_ref() { params.push("projection", value); } if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._order_by.as_ref() { params.push("orderBy", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } if let Some(value) = self._include_team_drive_items.as_ref() { params.push("includeTeamDriveItems", value.to_string()); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } if let Some(value) = self._include_items_from_all_drives.as_ref() { params.push("includeItemsFromAllDrives", value.to_string()); } if let Some(value) = self._drive_id.as_ref() { params.push("driveId", value); } if let Some(value) = self._corpus.as_ref() { params.push("corpus", value); } if let Some(value) = self._corpora.as_ref() { params.push("corpora", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files"; if self._scopes.is_empty() { self._scopes.insert(Scope::AppReadonly.as_ref().to_string()); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Deprecated: Use `driveId` instead. /// /// Sets the *team drive id* query property to the given value. pub fn team_drive_id(mut self, new_value: &str) -> FileListCall<'a, S> { self._team_drive_id = Some(new_value.to_string()); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FileListCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FileListCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// A comma-separated list of spaces to query. Supported values are `drive`, and `appDataFolder`. /// /// Sets the *spaces* query property to the given value. pub fn spaces(mut self, new_value: &str) -> FileListCall<'a, S> { self._spaces = Some(new_value.to_string()); self } /// Query string for searching files. /// /// Sets the *q* query property to the given value. pub fn q(mut self, new_value: &str) -> FileListCall<'a, S> { self._q = Some(new_value.to_string()); self } /// Deprecated: This parameter has no function. /// /// Sets the *projection* query property to the given value. pub fn projection(mut self, new_value: &str) -> FileListCall<'a, S> { self._projection = Some(new_value.to_string()); self } /// Page token for files. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> FileListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// A comma-separated list of sort keys. Valid keys are `createdDate`, `folder`, `lastViewedByMeDate`, `modifiedByMeDate`, `modifiedDate`, `quotaBytesUsed`, `recency`, `sharedWithMeDate`, `starred`, `title`, and `title_natural`. Each key sorts ascending by default, but may be reversed with the `desc` modifier. Example usage: ?orderBy=folder,modifiedDate desc,title. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored. /// /// Sets the *order by* query property to the given value. pub fn order_by(mut self, new_value: &str) -> FileListCall<'a, S> { self._order_by = Some(new_value.to_string()); self } /// 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. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> FileListCall<'a, S> { self._max_results = Some(new_value); self } /// Deprecated: Use `includeItemsFromAllDrives` instead. /// /// Sets the *include team drive items* query property to the given value. pub fn include_team_drive_items(mut self, new_value: bool) -> FileListCall<'a, S> { self._include_team_drive_items = Some(new_value); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> FileListCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> FileListCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// Whether both My Drive and shared drive items should be included in results. /// /// Sets the *include items from all drives* query property to the given value. pub fn include_items_from_all_drives(mut self, new_value: bool) -> FileListCall<'a, S> { self._include_items_from_all_drives = Some(new_value); self } /// ID of the shared drive to search. /// /// Sets the *drive id* query property to the given value. pub fn drive_id(mut self, new_value: &str) -> FileListCall<'a, S> { self._drive_id = Some(new_value.to_string()); self } /// Deprecated: The body of items (files/documents) to which the query applies. Use `corpora` instead. /// /// Sets the *corpus* query property to the given value. pub fn corpus(mut self, new_value: &str) -> FileListCall<'a, S> { self._corpus = Some(new_value.to_string()); self } /// Bodies of items (files/documents) to which the query applies. Supported bodies are `default`, `domain`, `drive` and `allDrives`. Prefer `default` or `drive` to `allDrives` for efficiency. /// /// Sets the *corpora* query property to the given value. pub fn corpora(mut self, new_value: &str) -> FileListCall<'a, S> { self._corpora = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::AppReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileListCall<'a, S> { self._scopes.clear(); self } } /// Lists the labels on a file. /// /// A builder for the *listLabels* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().list_labels("fileId") /// .page_token("ipsum") /// .max_results(-73) /// .doit().await; /// # } /// ``` pub struct FileListLabelCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _page_token: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileListLabelCall<'a, S> {} impl<'a, S> FileListLabelCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, LabelList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.listLabels", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "pageToken", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/listLabels"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID for the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileListLabelCall<'a, S> { self._file_id = new_value.to_string(); self } /// 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. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> FileListLabelCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// The maximum number of labels to return per page. When not set, defaults to 100. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> FileListLabelCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileListLabelCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileListLabelCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileListLabelCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileListLabelCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileListLabelCall<'a, S> { self._scopes.clear(); self } } /// Modifies the set of labels applied to a file. Returns a list of the labels that were added or modified. /// /// A builder for the *modifyLabels* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::ModifyLabelsRequest; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ModifyLabelsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().modify_labels(req, "fileId") /// .doit().await; /// # } /// ``` pub struct FileModifyLabelCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: ModifyLabelsRequest, _file_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileModifyLabelCall<'a, S> {} impl<'a, S> FileModifyLabelCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ModifyLabelsResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.modifyLabels", http_method: hyper::Method::POST }); for &field in ["alt", "fileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("fileId", self._file_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/modifyLabels"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: ModifyLabelsRequest) -> FileModifyLabelCall<'a, S> { self._request = new_value; self } /// The ID of the file to which the labels belong. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileModifyLabelCall<'a, S> { self._file_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileModifyLabelCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileModifyLabelCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileModifyLabelCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileModifyLabelCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileModifyLabelCall<'a, S> { self._scopes.clear(); self } } /// 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. /// /// A builder for the *patch* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::File; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = File::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().patch(req, "fileId") /// .use_content_as_indexable_text(true) /// .update_viewed_date(true) /// .timed_text_track_name("sea") /// .timed_text_language("ipsum") /// .supports_team_drives(true) /// .supports_all_drives(true) /// .set_modified_date(false) /// .remove_parents("kasd") /// .pinned(true) /// .ocr_language("Lorem") /// .ocr(false) /// .new_revision(false) /// .modified_date_behavior("nonumy") /// .include_permissions_for_view("sea") /// .include_labels("ipsum") /// .enforce_single_parent(true) /// .convert(false) /// .add_parents("erat") /// .doit().await; /// # } /// ``` pub struct FilePatchCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: File, _file_id: String, _use_content_as_indexable_text: Option, _update_viewed_date: Option, _timed_text_track_name: Option, _timed_text_language: Option, _supports_team_drives: Option, _supports_all_drives: Option, _set_modified_date: Option, _remove_parents: Option, _pinned: Option, _ocr_language: Option, _ocr: Option, _new_revision: Option, _modified_date_behavior: Option, _include_permissions_for_view: Option, _include_labels: Option, _enforce_single_parent: Option, _convert: Option, _add_parents: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FilePatchCall<'a, S> {} impl<'a, S> FilePatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, File)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "fileId", "useContentAsIndexableText", "updateViewedDate", "timedTextTrackName", "timedTextLanguage", "supportsTeamDrives", "supportsAllDrives", "setModifiedDate", "removeParents", "pinned", "ocrLanguage", "ocr", "newRevision", "modifiedDateBehavior", "includePermissionsForView", "includeLabels", "enforceSingleParent", "convert", "addParents"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(22 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._use_content_as_indexable_text.as_ref() { params.push("useContentAsIndexableText", value.to_string()); } if let Some(value) = self._update_viewed_date.as_ref() { params.push("updateViewedDate", value.to_string()); } if let Some(value) = self._timed_text_track_name.as_ref() { params.push("timedTextTrackName", value); } if let Some(value) = self._timed_text_language.as_ref() { params.push("timedTextLanguage", value); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._set_modified_date.as_ref() { params.push("setModifiedDate", value.to_string()); } if let Some(value) = self._remove_parents.as_ref() { params.push("removeParents", value); } if let Some(value) = self._pinned.as_ref() { params.push("pinned", value.to_string()); } if let Some(value) = self._ocr_language.as_ref() { params.push("ocrLanguage", value); } if let Some(value) = self._ocr.as_ref() { params.push("ocr", value.to_string()); } if let Some(value) = self._new_revision.as_ref() { params.push("newRevision", value.to_string()); } if let Some(value) = self._modified_date_behavior.as_ref() { params.push("modifiedDateBehavior", value); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } if let Some(value) = self._convert.as_ref() { params.push("convert", value.to_string()); } if let Some(value) = self._add_parents.as_ref() { params.push("addParents", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: File) -> FilePatchCall<'a, S> { self._request = new_value; self } /// The ID of the file to update. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FilePatchCall<'a, S> { self._file_id = new_value.to_string(); self } /// Whether to use the content as indexable text. /// /// Sets the *use content as indexable text* query property to the given value. pub fn use_content_as_indexable_text(mut self, new_value: bool) -> FilePatchCall<'a, S> { self._use_content_as_indexable_text = Some(new_value); self } /// Whether to update the view date after successfully updating the file. /// /// Sets the *update viewed date* query property to the given value. pub fn update_viewed_date(mut self, new_value: bool) -> FilePatchCall<'a, S> { self._update_viewed_date = Some(new_value); self } /// The timed text track name. /// /// Sets the *timed text track name* query property to the given value. pub fn timed_text_track_name(mut self, new_value: &str) -> FilePatchCall<'a, S> { self._timed_text_track_name = Some(new_value.to_string()); self } /// The language of the timed text. /// /// Sets the *timed text language* query property to the given value. pub fn timed_text_language(mut self, new_value: &str) -> FilePatchCall<'a, S> { self._timed_text_language = Some(new_value.to_string()); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FilePatchCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FilePatchCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Whether to set the modified date using the value supplied in the request body. Setting this field to `true` is equivalent to `modifiedDateBehavior=fromBodyOrNow`, and `false` is equivalent to `modifiedDateBehavior=now`. To prevent any changes to the modified date set `modifiedDateBehavior=noChange`. /// /// Sets the *set modified date* query property to the given value. pub fn set_modified_date(mut self, new_value: bool) -> FilePatchCall<'a, S> { self._set_modified_date = Some(new_value); self } /// Comma-separated list of parent IDs to remove. /// /// Sets the *remove parents* query property to the given value. pub fn remove_parents(mut self, new_value: &str) -> FilePatchCall<'a, S> { self._remove_parents = Some(new_value.to_string()); self } /// Whether to pin the new revision. A file can have a maximum of 200 pinned revisions. Note that this field is ignored if there is no payload in the request. /// /// Sets the *pinned* query property to the given value. pub fn pinned(mut self, new_value: bool) -> FilePatchCall<'a, S> { self._pinned = Some(new_value); self } /// If ocr is true, hints at the language to use. Valid values are BCP 47 codes. /// /// Sets the *ocr language* query property to the given value. pub fn ocr_language(mut self, new_value: &str) -> FilePatchCall<'a, S> { self._ocr_language = Some(new_value.to_string()); self } /// Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads. /// /// Sets the *ocr* query property to the given value. pub fn ocr(mut self, new_value: bool) -> FilePatchCall<'a, S> { self._ocr = Some(new_value); self } /// Whether a blob upload should create a new revision. If false, the blob data in the current head revision is replaced. If true or not set, a new blob is created as head revision, and previous unpinned revisions are preserved for a short period of time. Pinned revisions are stored indefinitely, using additional storage quota, up to a maximum of 200 revisions. For details on how revisions are retained, see the [Drive Help Center](https://support.google.com/drive/answer/2409045). Note that this field is ignored if there is no payload in the request. /// /// Sets the *new revision* query property to the given value. pub fn new_revision(mut self, new_value: bool) -> FilePatchCall<'a, S> { self._new_revision = Some(new_value); self } /// Determines the behavior in which `modifiedDate` is updated. This overrides `setModifiedDate`. /// /// Sets the *modified date behavior* query property to the given value. pub fn modified_date_behavior(mut self, new_value: &str) -> FilePatchCall<'a, S> { self._modified_date_behavior = Some(new_value.to_string()); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> FilePatchCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> FilePatchCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// Deprecated: Adding files to multiple folders is no longer supported. Use `shortcuts` instead. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> FilePatchCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// Deprecated: This parameter has no function. /// /// Sets the *convert* query property to the given value. pub fn convert(mut self, new_value: bool) -> FilePatchCall<'a, S> { self._convert = Some(new_value); self } /// Comma-separated list of parent IDs to add. /// /// Sets the *add parents* query property to the given value. pub fn add_parents(mut self, new_value: &str) -> FilePatchCall<'a, S> { self._add_parents = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FilePatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FilePatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FilePatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FilePatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FilePatchCall<'a, S> { self._scopes.clear(); self } } /// Set the file's updated time to the current server time. /// /// A builder for the *touch* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().touch("fileId") /// .supports_team_drives(false) /// .supports_all_drives(false) /// .include_permissions_for_view("nonumy") /// .include_labels("erat") /// .doit().await; /// # } /// ``` pub struct FileTouchCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _supports_team_drives: Option, _supports_all_drives: Option, _include_permissions_for_view: Option, _include_labels: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileTouchCall<'a, S> {} impl<'a, S> FileTouchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, File)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.touch", http_method: hyper::Method::POST }); for &field in ["alt", "fileId", "supportsTeamDrives", "supportsAllDrives", "includePermissionsForView", "includeLabels"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/touch"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file to update. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileTouchCall<'a, S> { self._file_id = new_value.to_string(); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FileTouchCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FileTouchCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> FileTouchCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> FileTouchCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileTouchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileTouchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileTouchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileTouchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileTouchCall<'a, S> { self._scopes.clear(); self } } /// Moves a file to the trash. The currently authenticated user must own the file or be at least a `fileOrganizer` on the parent for shared drive files. /// /// A builder for the *trash* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().trash("fileId") /// .supports_team_drives(true) /// .supports_all_drives(false) /// .include_permissions_for_view("elitr") /// .include_labels("consetetur") /// .doit().await; /// # } /// ``` pub struct FileTrashCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _supports_team_drives: Option, _supports_all_drives: Option, _include_permissions_for_view: Option, _include_labels: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileTrashCall<'a, S> {} impl<'a, S> FileTrashCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, File)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.trash", http_method: hyper::Method::POST }); for &field in ["alt", "fileId", "supportsTeamDrives", "supportsAllDrives", "includePermissionsForView", "includeLabels"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/trash"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file to trash. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileTrashCall<'a, S> { self._file_id = new_value.to_string(); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FileTrashCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FileTrashCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> FileTrashCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> FileTrashCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileTrashCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileTrashCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileTrashCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileTrashCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileTrashCall<'a, S> { self._scopes.clear(); self } } /// Restores a file from the trash. The currently authenticated user must own the file or be at least a `fileOrganizer` on the parent for shared drive files. /// /// A builder for the *untrash* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().untrash("fileId") /// .supports_team_drives(true) /// .supports_all_drives(true) /// .include_permissions_for_view("erat") /// .include_labels("diam") /// .doit().await; /// # } /// ``` pub struct FileUntrashCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _supports_team_drives: Option, _supports_all_drives: Option, _include_permissions_for_view: Option, _include_labels: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileUntrashCall<'a, S> {} impl<'a, S> FileUntrashCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, File)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.untrash", http_method: hyper::Method::POST }); for &field in ["alt", "fileId", "supportsTeamDrives", "supportsAllDrives", "includePermissionsForView", "includeLabels"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/untrash"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file to untrash. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileUntrashCall<'a, S> { self._file_id = new_value.to_string(); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FileUntrashCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FileUntrashCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> FileUntrashCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> FileUntrashCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileUntrashCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileUntrashCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileUntrashCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileUntrashCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileUntrashCall<'a, S> { self._scopes.clear(); self } } /// 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 be changed automatically, such as `modifiedDate`. This method supports patch semantics. This method supports an */upload* URI and accepts uploaded media with the following characteristics: - *Maximum file size:* 5,120 GB - *Accepted Media MIME types:*`*/*` Note: Specify a valid MIME type, rather than the literal `*/*` value. The literal `*/*` is only used to indicate that any valid MIME type can be uploaded. For more information on uploading files, see [Upload file data](https://developers.google.com/drive/api/guides/manage-uploads). /// /// A builder for the *update* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::File; /// use std::fs; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = File::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().update(req, "fileId") /// .use_content_as_indexable_text(false) /// .update_viewed_date(false) /// .timed_text_track_name("diam") /// .timed_text_language("sed") /// .supports_team_drives(false) /// .supports_all_drives(true) /// .set_modified_date(true) /// .remove_parents("At") /// .pinned(true) /// .ocr_language("sit") /// .ocr(false) /// .new_revision(false) /// .modified_date_behavior("elitr") /// .include_permissions_for_view("aliquyam") /// .include_labels("erat") /// .enforce_single_parent(false) /// .convert(true) /// .add_parents("rebum.") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; /// # } /// ``` pub struct FileUpdateCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: File, _file_id: String, _use_content_as_indexable_text: Option, _update_viewed_date: Option, _timed_text_track_name: Option, _timed_text_language: Option, _supports_team_drives: Option, _supports_all_drives: Option, _set_modified_date: Option, _remove_parents: Option, _pinned: Option, _ocr_language: Option, _ocr: Option, _new_revision: Option, _modified_date_behavior: Option, _include_permissions_for_view: Option, _include_labels: Option, _enforce_single_parent: Option, _convert: Option, _add_parents: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileUpdateCall<'a, S> {} impl<'a, S> FileUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// 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 pub async fn doit_without_upload(mut self) -> client::Result<(hyper::Response, File)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.update", http_method: hyper::Method::PUT }); for &field in ["alt", "fileId", "useContentAsIndexableText", "updateViewedDate", "timedTextTrackName", "timedTextLanguage", "supportsTeamDrives", "supportsAllDrives", "setModifiedDate", "removeParents", "pinned", "ocrLanguage", "ocr", "newRevision", "modifiedDateBehavior", "includePermissionsForView", "includeLabels", "enforceSingleParent", "convert", "addParents"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(22 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._use_content_as_indexable_text.as_ref() { params.push("useContentAsIndexableText", value.to_string()); } if let Some(value) = self._update_viewed_date.as_ref() { params.push("updateViewedDate", value.to_string()); } if let Some(value) = self._timed_text_track_name.as_ref() { params.push("timedTextTrackName", value); } if let Some(value) = self._timed_text_language.as_ref() { params.push("timedTextLanguage", value); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._set_modified_date.as_ref() { params.push("setModifiedDate", value.to_string()); } if let Some(value) = self._remove_parents.as_ref() { params.push("removeParents", value); } if let Some(value) = self._pinned.as_ref() { params.push("pinned", value.to_string()); } if let Some(value) = self._ocr_language.as_ref() { params.push("ocrLanguage", value); } if let Some(value) = self._ocr.as_ref() { params.push("ocr", value.to_string()); } if let Some(value) = self._new_revision.as_ref() { params.push("newRevision", value.to_string()); } if let Some(value) = self._modified_date_behavior.as_ref() { params.push("modifiedDateBehavior", value); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } if let Some(value) = self._convert.as_ref() { params.push("convert", value.to_string()); } if let Some(value) = self._add_parents.as_ref() { params.push("addParents", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Perform the operation you have build so far. async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, File)> where RS: client::ReadSeek { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.update", http_method: hyper::Method::PUT }); for &field in ["alt", "fileId", "useContentAsIndexableText", "updateViewedDate", "timedTextTrackName", "timedTextLanguage", "supportsTeamDrives", "supportsAllDrives", "setModifiedDate", "removeParents", "pinned", "ocrLanguage", "ocr", "newRevision", "modifiedDateBehavior", "includePermissionsForView", "includeLabels", "enforceSingleParent", "convert", "addParents"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(22 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._use_content_as_indexable_text.as_ref() { params.push("useContentAsIndexableText", value.to_string()); } if let Some(value) = self._update_viewed_date.as_ref() { params.push("updateViewedDate", value.to_string()); } if let Some(value) = self._timed_text_track_name.as_ref() { params.push("timedTextTrackName", value); } if let Some(value) = self._timed_text_language.as_ref() { params.push("timedTextLanguage", value); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._set_modified_date.as_ref() { params.push("setModifiedDate", value.to_string()); } if let Some(value) = self._remove_parents.as_ref() { params.push("removeParents", value); } if let Some(value) = self._pinned.as_ref() { params.push("pinned", value.to_string()); } if let Some(value) = self._ocr_language.as_ref() { params.push("ocrLanguage", value); } if let Some(value) = self._ocr.as_ref() { params.push("ocr", value.to_string()); } if let Some(value) = self._new_revision.as_ref() { params.push("newRevision", value.to_string()); } if let Some(value) = self._modified_date_behavior.as_ref() { params.push("modifiedDateBehavior", value); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } if let Some(value) = self._convert.as_ref() { params.push("convert", value.to_string()); } if let Some(value) = self._add_parents.as_ref() { params.push("addParents", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let (mut url, upload_type) = if protocol == client::UploadProtocol::Resumable { (self.hub._root_url.clone() + "resumable/upload/drive/v2/files/{fileId}", "resumable") } else if protocol == client::UploadProtocol::Simple { (self.hub._root_url.clone() + "upload/drive/v2/files/{fileId}", "multipart") } else { unreachable!() }; params.push("uploadType", upload_type); if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut should_ask_dlg_for_url = false; let mut upload_url_from_server; let mut upload_url: Option = None; loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; upload_url_from_server = false; Ok(hyper::Response::builder() .status(hyper::StatusCode::OK) .header("Location", upload_url.as_ref().unwrap().clone()) .body(hyper::body::Body::empty()) .unwrap()) } else { let mut mp_reader: client::MultiPartReader = Default::default(); let (mut body_reader, content_type) = match protocol { client::UploadProtocol::Simple => { mp_reader.reserve_exact(2); let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 5497558138880 { return Err(client::Error::UploadSizeLimitExceeded(size, 5497558138880)) } mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) .add_part(&mut reader, size, reader_mime_type.clone()); (&mut mp_reader as &mut (dyn io::Read + Send), client::MultiPartReader::mime_type()) }, _ => (&mut request_value_reader as &mut (dyn io::Read + Send), json_mime_type.clone()), }; let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } upload_url_from_server = true; if protocol == client::UploadProtocol::Resumable { req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); } let mut body_reader_bytes = vec![]; body_reader.read_to_end(&mut body_reader_bytes).unwrap(); let request = req_builder .header(CONTENT_TYPE, content_type.to_string()) .body(hyper::body::Body::from(body_reader_bytes)); client.request(request.unwrap()).await } }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } if protocol == client::UploadProtocol::Resumable { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 5497558138880 { return Err(client::Error::UploadSizeLimitExceeded(size, 5497558138880)) } let upload_result = { let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); if upload_url_from_server { dlg.store_upload_url(Some(url_str)); } client::ResumableUploadHelper { client: &self.hub.client, delegate: dlg, start_at: if upload_url_from_server { Some(0) } else { None }, auth: &self.hub.auth, user_agent: &self.hub._user_agent, // TODO: Check this assumption auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size }.upload().await }; match upload_result { None => { dlg.finished(false); return Err(client::Error::Cancelled) } Some(Err(err)) => { dlg.finished(false); return Err(client::Error::HttpError(err)) } Some(Ok(upload_result)) => { res = upload_result; if !res.status().is_success() { dlg.store_upload_url(None); dlg.finished(false); return Err(client::Error::Failure(res)) } } } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Upload media in a resumable fashion. /// Even if the upload fails or is interrupted, it can be resumed for a /// certain amount of time as the server maintains state temporarily. /// /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using /// `cancel_chunk_upload(...)`. /// /// * *multipart*: yes /// * *max size*: 5497558138880 /// * *valid mime types*: '*/*' pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, File)> where RS: client::ReadSeek { self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await } /// Upload media all at once. /// If the upload fails for whichever reason, all progress is lost. /// /// * *multipart*: yes /// * *max size*: 5497558138880 /// * *valid mime types*: '*/*' pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, File)> where RS: client::ReadSeek { self.doit(stream, mime_type, client::UploadProtocol::Simple).await } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: File) -> FileUpdateCall<'a, S> { self._request = new_value; self } /// The ID of the file to update. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileUpdateCall<'a, S> { self._file_id = new_value.to_string(); self } /// Whether to use the content as indexable text. /// /// Sets the *use content as indexable text* query property to the given value. pub fn use_content_as_indexable_text(mut self, new_value: bool) -> FileUpdateCall<'a, S> { self._use_content_as_indexable_text = Some(new_value); self } /// Whether to update the view date after successfully updating the file. /// /// Sets the *update viewed date* query property to the given value. pub fn update_viewed_date(mut self, new_value: bool) -> FileUpdateCall<'a, S> { self._update_viewed_date = Some(new_value); self } /// The timed text track name. /// /// Sets the *timed text track name* query property to the given value. pub fn timed_text_track_name(mut self, new_value: &str) -> FileUpdateCall<'a, S> { self._timed_text_track_name = Some(new_value.to_string()); self } /// The language of the timed text. /// /// Sets the *timed text language* query property to the given value. pub fn timed_text_language(mut self, new_value: &str) -> FileUpdateCall<'a, S> { self._timed_text_language = Some(new_value.to_string()); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FileUpdateCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FileUpdateCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Whether to set the modified date using the value supplied in the request body. Setting this field to `true` is equivalent to `modifiedDateBehavior=fromBodyOrNow`, and `false` is equivalent to `modifiedDateBehavior=now`. To prevent any changes to the modified date set `modifiedDateBehavior=noChange`. /// /// Sets the *set modified date* query property to the given value. pub fn set_modified_date(mut self, new_value: bool) -> FileUpdateCall<'a, S> { self._set_modified_date = Some(new_value); self } /// Comma-separated list of parent IDs to remove. /// /// Sets the *remove parents* query property to the given value. pub fn remove_parents(mut self, new_value: &str) -> FileUpdateCall<'a, S> { self._remove_parents = Some(new_value.to_string()); self } /// Whether to pin the new revision. A file can have a maximum of 200 pinned revisions. /// /// Sets the *pinned* query property to the given value. pub fn pinned(mut self, new_value: bool) -> FileUpdateCall<'a, S> { self._pinned = Some(new_value); self } /// If ocr is true, hints at the language to use. Valid values are BCP 47 codes. /// /// Sets the *ocr language* query property to the given value. pub fn ocr_language(mut self, new_value: &str) -> FileUpdateCall<'a, S> { self._ocr_language = Some(new_value.to_string()); self } /// Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads. /// /// Sets the *ocr* query property to the given value. pub fn ocr(mut self, new_value: bool) -> FileUpdateCall<'a, S> { self._ocr = Some(new_value); self } /// Whether a blob upload should create a new revision. If false, the blob data in the current head revision is replaced. If true or not set, a new blob is created as head revision, and previous unpinned revisions are preserved for a short period of time. Pinned revisions are stored indefinitely, using additional storage quota, up to a maximum of 200 revisions. For details on how revisions are retained, see the [Drive Help Center](https://support.google.com/drive/answer/2409045). /// /// Sets the *new revision* query property to the given value. pub fn new_revision(mut self, new_value: bool) -> FileUpdateCall<'a, S> { self._new_revision = Some(new_value); self } /// Determines the behavior in which `modifiedDate` is updated. This overrides `setModifiedDate`. /// /// Sets the *modified date behavior* query property to the given value. pub fn modified_date_behavior(mut self, new_value: &str) -> FileUpdateCall<'a, S> { self._modified_date_behavior = Some(new_value.to_string()); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> FileUpdateCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> FileUpdateCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// Deprecated: Adding files to multiple folders is no longer supported. Use `shortcuts` instead. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> FileUpdateCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// Deprecated: This parameter has no function. /// /// Sets the *convert* query property to the given value. pub fn convert(mut self, new_value: bool) -> FileUpdateCall<'a, S> { self._convert = Some(new_value); self } /// Comma-separated list of parent IDs to add. /// /// Sets the *add parents* query property to the given value. pub fn add_parents(mut self, new_value: &str) -> FileUpdateCall<'a, S> { self._add_parents = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileUpdateCall<'a, S> { self._scopes.clear(); self } } /// Subscribes to changes to a file. /// /// A builder for the *watch* method supported by a *file* resource. /// It is not used directly, but through a [`FileMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Channel; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().watch(req, "fileId") /// .update_viewed_date(true) /// .supports_team_drives(false) /// .supports_all_drives(false) /// .revision_id("sit") /// .projection("kasd") /// .include_permissions_for_view("tempor") /// .include_labels("dolor") /// .acknowledge_abuse(false) /// .doit().await; /// # } /// ``` pub struct FileWatchCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Channel, _file_id: String, _update_viewed_date: Option, _supports_team_drives: Option, _supports_all_drives: Option, _revision_id: Option, _projection: Option, _include_permissions_for_view: Option, _include_labels: Option, _acknowledge_abuse: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for FileWatchCall<'a, S> {} impl<'a, S> FileWatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Channel)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.files.watch", http_method: hyper::Method::POST }); for &field in ["alt", "fileId", "updateViewedDate", "supportsTeamDrives", "supportsAllDrives", "revisionId", "projection", "includePermissionsForView", "includeLabels", "acknowledgeAbuse"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(12 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._update_viewed_date.as_ref() { params.push("updateViewedDate", value.to_string()); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._revision_id.as_ref() { params.push("revisionId", value); } if let Some(value) = self._projection.as_ref() { params.push("projection", value); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } if let Some(value) = self._include_labels.as_ref() { params.push("includeLabels", value); } if let Some(value) = self._acknowledge_abuse.as_ref() { params.push("acknowledgeAbuse", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/watch"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Channel) -> FileWatchCall<'a, S> { self._request = new_value; self } /// The ID for the file in question. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileWatchCall<'a, S> { self._file_id = new_value.to_string(); self } /// Deprecated: Use files.update with modifiedDateBehavior=noChange, updateViewedDate=true and an empty request body. /// /// Sets the *update viewed date* query property to the given value. pub fn update_viewed_date(mut self, new_value: bool) -> FileWatchCall<'a, S> { self._update_viewed_date = Some(new_value); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> FileWatchCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> FileWatchCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Specifies the Revision ID that should be downloaded. Ignored unless alt=media is specified. /// /// Sets the *revision id* query property to the given value. pub fn revision_id(mut self, new_value: &str) -> FileWatchCall<'a, S> { self._revision_id = Some(new_value.to_string()); self } /// Deprecated: This parameter has no function. /// /// Sets the *projection* query property to the given value. pub fn projection(mut self, new_value: &str) -> FileWatchCall<'a, S> { self._projection = Some(new_value.to_string()); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> FileWatchCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. /// /// Sets the *include labels* query property to the given value. pub fn include_labels(mut self, new_value: &str) -> FileWatchCall<'a, S> { self._include_labels = Some(new_value.to_string()); self } /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. /// /// Sets the *acknowledge abuse* query property to the given value. pub fn acknowledge_abuse(mut self, new_value: bool) -> FileWatchCall<'a, S> { self._acknowledge_abuse = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileWatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> FileWatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> FileWatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> FileWatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> FileWatchCall<'a, S> { self._scopes.clear(); self } } /// Removes a parent from a file. /// /// A builder for the *delete* method supported by a *parent* resource. /// It is not used directly, but through a [`ParentMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.parents().delete("fileId", "parentId") /// .enforce_single_parent(true) /// .doit().await; /// # } /// ``` pub struct ParentDeleteCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _parent_id: String, _enforce_single_parent: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ParentDeleteCall<'a, S> {} impl<'a, S> ParentDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.parents.delete", http_method: hyper::Method::DELETE }); for &field in ["fileId", "parentId", "enforceSingleParent"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("parentId", self._parent_id); if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "files/{fileId}/parents/{parentId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{parentId}", "parentId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["parentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ParentDeleteCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the parent. /// /// Sets the *parent id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent_id(mut self, new_value: &str) -> ParentDeleteCall<'a, S> { self._parent_id = new_value.to_string(); self } /// Deprecated: If an item is not in a shared drive and its last parent is removed, the item is placed under its owner's root. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> ParentDeleteCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ParentDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ParentDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ParentDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ParentDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ParentDeleteCall<'a, S> { self._scopes.clear(); self } } /// Gets a specific parent reference. /// /// A builder for the *get* method supported by a *parent* resource. /// It is not used directly, but through a [`ParentMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.parents().get("fileId", "parentId") /// .doit().await; /// # } /// ``` pub struct ParentGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _parent_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ParentGetCall<'a, S> {} impl<'a, S> ParentGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ParentReference)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.parents.get", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "parentId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("parentId", self._parent_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/parents/{parentId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{parentId}", "parentId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["parentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ParentGetCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the parent. /// /// Sets the *parent id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent_id(mut self, new_value: &str) -> ParentGetCall<'a, S> { self._parent_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ParentGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ParentGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ParentGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ParentGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ParentGetCall<'a, S> { self._scopes.clear(); self } } /// Adds a parent folder for a file. /// /// A builder for the *insert* method supported by a *parent* resource. /// It is not used directly, but through a [`ParentMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::ParentReference; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ParentReference::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.parents().insert(req, "fileId") /// .supports_team_drives(false) /// .supports_all_drives(false) /// .enforce_single_parent(false) /// .doit().await; /// # } /// ``` pub struct ParentInsertCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: ParentReference, _file_id: String, _supports_team_drives: Option, _supports_all_drives: Option, _enforce_single_parent: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ParentInsertCall<'a, S> {} impl<'a, S> ParentInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ParentReference)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.parents.insert", http_method: hyper::Method::POST }); for &field in ["alt", "fileId", "supportsTeamDrives", "supportsAllDrives", "enforceSingleParent"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/parents"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: ParentReference) -> ParentInsertCall<'a, S> { self._request = new_value; self } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ParentInsertCall<'a, S> { self._file_id = new_value.to_string(); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> ParentInsertCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> ParentInsertCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Deprecated: Adding files to multiple folders is no longer supported. Use `shortcuts` instead. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> ParentInsertCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ParentInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ParentInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ParentInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ParentInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ParentInsertCall<'a, S> { self._scopes.clear(); self } } /// Lists a file's parents. /// /// A builder for the *list* method supported by a *parent* resource. /// It is not used directly, but through a [`ParentMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.parents().list("fileId") /// .doit().await; /// # } /// ``` pub struct ParentListCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ParentListCall<'a, S> {} impl<'a, S> ParentListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ParentList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.parents.list", http_method: hyper::Method::GET }); for &field in ["alt", "fileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("fileId", self._file_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/parents"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ParentListCall<'a, S> { self._file_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ParentListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ParentListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ParentListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ParentListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ParentListCall<'a, S> { self._scopes.clear(); self } } /// Deletes a permission from a file or shared drive. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied. /// /// A builder for the *delete* method supported by a *permission* resource. /// It is not used directly, but through a [`PermissionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().delete("fileId", "permissionId") /// .use_domain_admin_access(true) /// .supports_team_drives(true) /// .supports_all_drives(true) /// .doit().await; /// # } /// ``` pub struct PermissionDeleteCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _permission_id: String, _use_domain_admin_access: Option, _supports_team_drives: Option, _supports_all_drives: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PermissionDeleteCall<'a, S> {} impl<'a, S> PermissionDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.permissions.delete", http_method: hyper::Method::DELETE }); for &field in ["fileId", "permissionId", "useDomainAdminAccess", "supportsTeamDrives", "supportsAllDrives"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("permissionId", self._permission_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["permissionId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID for the file or shared drive. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PermissionDeleteCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID for the permission. /// /// Sets the *permission id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn permission_id(mut self, new_value: &str) -> PermissionDeleteCall<'a, S> { self._permission_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionDeleteCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> PermissionDeleteCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> PermissionDeleteCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PermissionDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PermissionDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PermissionDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PermissionDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PermissionDeleteCall<'a, S> { self._scopes.clear(); self } } /// Gets a permission by ID. /// /// A builder for the *get* method supported by a *permission* resource. /// It is not used directly, but through a [`PermissionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().get("fileId", "permissionId") /// .use_domain_admin_access(true) /// .supports_team_drives(false) /// .supports_all_drives(false) /// .doit().await; /// # } /// ``` pub struct PermissionGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _permission_id: String, _use_domain_admin_access: Option, _supports_team_drives: Option, _supports_all_drives: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PermissionGetCall<'a, S> {} impl<'a, S> PermissionGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Permission)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.permissions.get", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "permissionId", "useDomainAdminAccess", "supportsTeamDrives", "supportsAllDrives"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("permissionId", self._permission_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["permissionId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID for the file or shared drive. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PermissionGetCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID for the permission. /// /// Sets the *permission id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn permission_id(mut self, new_value: &str) -> PermissionGetCall<'a, S> { self._permission_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionGetCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> PermissionGetCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> PermissionGetCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PermissionGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PermissionGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PermissionGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PermissionGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PermissionGetCall<'a, S> { self._scopes.clear(); self } } /// Returns the permission ID for an email address. /// /// A builder for the *getIdForEmail* method supported by a *permission* resource. /// It is not used directly, but through a [`PermissionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().get_id_for_email("email") /// .doit().await; /// # } /// ``` pub struct PermissionGetIdForEmailCall<'a, S> where S: 'a { hub: &'a DriveHub, _email: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PermissionGetIdForEmailCall<'a, S> {} impl<'a, S> PermissionGetIdForEmailCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PermissionId)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.permissions.getIdForEmail", http_method: hyper::Method::GET }); for &field in ["alt", "email"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("email", self._email); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "permissionIds/{email}"; if self._scopes.is_empty() { self._scopes.insert(Scope::AppReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{email}", "email")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["email"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The email address for which to return a permission ID /// /// Sets the *email* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn email(mut self, new_value: &str) -> PermissionGetIdForEmailCall<'a, S> { self._email = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PermissionGetIdForEmailCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PermissionGetIdForEmailCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::AppReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PermissionGetIdForEmailCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PermissionGetIdForEmailCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PermissionGetIdForEmailCall<'a, S> { self._scopes.clear(); self } } /// Inserts a permission for a file or shared drive. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied. /// /// A builder for the *insert* method supported by a *permission* resource. /// It is not used directly, but through a [`PermissionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Permission; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Permission::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().insert(req, "fileId") /// .use_domain_admin_access(false) /// .supports_team_drives(false) /// .supports_all_drives(false) /// .send_notification_emails(true) /// .move_to_new_owners_root(false) /// .enforce_single_parent(false) /// .email_message("accusam") /// .doit().await; /// # } /// ``` pub struct PermissionInsertCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Permission, _file_id: String, _use_domain_admin_access: Option, _supports_team_drives: Option, _supports_all_drives: Option, _send_notification_emails: Option, _move_to_new_owners_root: Option, _enforce_single_parent: Option, _email_message: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PermissionInsertCall<'a, S> {} impl<'a, S> PermissionInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Permission)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.permissions.insert", http_method: hyper::Method::POST }); for &field in ["alt", "fileId", "useDomainAdminAccess", "supportsTeamDrives", "supportsAllDrives", "sendNotificationEmails", "moveToNewOwnersRoot", "enforceSingleParent", "emailMessage"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(11 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._send_notification_emails.as_ref() { params.push("sendNotificationEmails", value.to_string()); } if let Some(value) = self._move_to_new_owners_root.as_ref() { params.push("moveToNewOwnersRoot", value.to_string()); } if let Some(value) = self._enforce_single_parent.as_ref() { params.push("enforceSingleParent", value.to_string()); } if let Some(value) = self._email_message.as_ref() { params.push("emailMessage", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Permission) -> PermissionInsertCall<'a, S> { self._request = new_value; self } /// The ID for the file or shared drive. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PermissionInsertCall<'a, S> { self._file_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionInsertCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> PermissionInsertCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> PermissionInsertCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Whether to send notification emails when sharing to users or groups. This parameter is ignored and an email is sent if the `role` is `owner`. /// /// Sets the *send notification emails* query property to the given value. pub fn send_notification_emails(mut self, new_value: bool) -> PermissionInsertCall<'a, S> { self._send_notification_emails = Some(new_value); self } /// 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. /// /// Sets the *move to new owners root* query property to the given value. pub fn move_to_new_owners_root(mut self, new_value: bool) -> PermissionInsertCall<'a, S> { self._move_to_new_owners_root = Some(new_value); self } /// Deprecated: See `moveToNewOwnersRoot` for details. /// /// Sets the *enforce single parent* query property to the given value. pub fn enforce_single_parent(mut self, new_value: bool) -> PermissionInsertCall<'a, S> { self._enforce_single_parent = Some(new_value); self } /// A plain text custom message to include in notification emails. /// /// Sets the *email message* query property to the given value. pub fn email_message(mut self, new_value: &str) -> PermissionInsertCall<'a, S> { self._email_message = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PermissionInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PermissionInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PermissionInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PermissionInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PermissionInsertCall<'a, S> { self._scopes.clear(); self } } /// Lists a file's or shared drive's permissions. /// /// A builder for the *list* method supported by a *permission* resource. /// It is not used directly, but through a [`PermissionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().list("fileId") /// .use_domain_admin_access(false) /// .supports_team_drives(true) /// .supports_all_drives(false) /// .page_token("amet") /// .max_results(-35) /// .include_permissions_for_view("aliquyam") /// .doit().await; /// # } /// ``` pub struct PermissionListCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _use_domain_admin_access: Option, _supports_team_drives: Option, _supports_all_drives: Option, _page_token: Option, _max_results: Option, _include_permissions_for_view: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PermissionListCall<'a, S> {} impl<'a, S> PermissionListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PermissionList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.permissions.list", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "useDomainAdminAccess", "supportsTeamDrives", "supportsAllDrives", "pageToken", "maxResults", "includePermissionsForView"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(9 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } if let Some(value) = self._include_permissions_for_view.as_ref() { params.push("includePermissionsForView", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID for the file or shared drive. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PermissionListCall<'a, S> { self._file_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionListCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> PermissionListCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> PermissionListCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// 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. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> PermissionListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// 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. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> PermissionListCall<'a, S> { self._max_results = Some(new_value); self } /// Specifies which additional view's permissions to include in the response. Only `published` is supported. /// /// Sets the *include permissions for view* query property to the given value. pub fn include_permissions_for_view(mut self, new_value: &str) -> PermissionListCall<'a, S> { self._include_permissions_for_view = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PermissionListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PermissionListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PermissionListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PermissionListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PermissionListCall<'a, S> { self._scopes.clear(); self } } /// Updates a permission using patch semantics. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied. /// /// A builder for the *patch* method supported by a *permission* resource. /// It is not used directly, but through a [`PermissionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Permission; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Permission::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().patch(req, "fileId", "permissionId") /// .use_domain_admin_access(false) /// .transfer_ownership(true) /// .supports_team_drives(true) /// .supports_all_drives(false) /// .remove_expiration(true) /// .doit().await; /// # } /// ``` pub struct PermissionPatchCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Permission, _file_id: String, _permission_id: String, _use_domain_admin_access: Option, _transfer_ownership: Option, _supports_team_drives: Option, _supports_all_drives: Option, _remove_expiration: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PermissionPatchCall<'a, S> {} impl<'a, S> PermissionPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Permission)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.permissions.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "fileId", "permissionId", "useDomainAdminAccess", "transferOwnership", "supportsTeamDrives", "supportsAllDrives", "removeExpiration"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(10 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("permissionId", self._permission_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } if let Some(value) = self._transfer_ownership.as_ref() { params.push("transferOwnership", value.to_string()); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._remove_expiration.as_ref() { params.push("removeExpiration", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["permissionId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Permission) -> PermissionPatchCall<'a, S> { self._request = new_value; self } /// The ID for the file or shared drive. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PermissionPatchCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID for the permission. /// /// Sets the *permission id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn permission_id(mut self, new_value: &str) -> PermissionPatchCall<'a, S> { self._permission_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionPatchCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// Whether changing a role to `owner` downgrades the current owners to writers. Does nothing if the specified role is not `owner`. /// /// Sets the *transfer ownership* query property to the given value. pub fn transfer_ownership(mut self, new_value: bool) -> PermissionPatchCall<'a, S> { self._transfer_ownership = Some(new_value); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> PermissionPatchCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> PermissionPatchCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Whether to remove the expiration date. /// /// Sets the *remove expiration* query property to the given value. pub fn remove_expiration(mut self, new_value: bool) -> PermissionPatchCall<'a, S> { self._remove_expiration = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PermissionPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PermissionPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PermissionPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PermissionPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PermissionPatchCall<'a, S> { self._scopes.clear(); self } } /// Updates a permission. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied. /// /// A builder for the *update* method supported by a *permission* resource. /// It is not used directly, but through a [`PermissionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Permission; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Permission::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().update(req, "fileId", "permissionId") /// .use_domain_admin_access(false) /// .transfer_ownership(true) /// .supports_team_drives(true) /// .supports_all_drives(false) /// .remove_expiration(false) /// .doit().await; /// # } /// ``` pub struct PermissionUpdateCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Permission, _file_id: String, _permission_id: String, _use_domain_admin_access: Option, _transfer_ownership: Option, _supports_team_drives: Option, _supports_all_drives: Option, _remove_expiration: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PermissionUpdateCall<'a, S> {} impl<'a, S> PermissionUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Permission)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.permissions.update", http_method: hyper::Method::PUT }); for &field in ["alt", "fileId", "permissionId", "useDomainAdminAccess", "transferOwnership", "supportsTeamDrives", "supportsAllDrives", "removeExpiration"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(10 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("permissionId", self._permission_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } if let Some(value) = self._transfer_ownership.as_ref() { params.push("transferOwnership", value.to_string()); } if let Some(value) = self._supports_team_drives.as_ref() { params.push("supportsTeamDrives", value.to_string()); } if let Some(value) = self._supports_all_drives.as_ref() { params.push("supportsAllDrives", value.to_string()); } if let Some(value) = self._remove_expiration.as_ref() { params.push("removeExpiration", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["permissionId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Permission) -> PermissionUpdateCall<'a, S> { self._request = new_value; self } /// The ID for the file or shared drive. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PermissionUpdateCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID for the permission. /// /// Sets the *permission id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn permission_id(mut self, new_value: &str) -> PermissionUpdateCall<'a, S> { self._permission_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionUpdateCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// Whether changing a role to `owner` downgrades the current owners to writers. Does nothing if the specified role is not `owner`. /// /// Sets the *transfer ownership* query property to the given value. pub fn transfer_ownership(mut self, new_value: bool) -> PermissionUpdateCall<'a, S> { self._transfer_ownership = Some(new_value); self } /// Deprecated: Use `supportsAllDrives` instead. /// /// Sets the *supports team drives* query property to the given value. pub fn supports_team_drives(mut self, new_value: bool) -> PermissionUpdateCall<'a, S> { self._supports_team_drives = Some(new_value); self } /// Whether the requesting application supports both My Drives and shared drives. /// /// Sets the *supports all drives* query property to the given value. pub fn supports_all_drives(mut self, new_value: bool) -> PermissionUpdateCall<'a, S> { self._supports_all_drives = Some(new_value); self } /// Whether to remove the expiration date. /// /// Sets the *remove expiration* query property to the given value. pub fn remove_expiration(mut self, new_value: bool) -> PermissionUpdateCall<'a, S> { self._remove_expiration = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PermissionUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PermissionUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PermissionUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PermissionUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PermissionUpdateCall<'a, S> { self._scopes.clear(); self } } /// Deletes a property. /// /// A builder for the *delete* method supported by a *property* resource. /// It is not used directly, but through a [`PropertyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().delete("fileId", "propertyKey") /// .visibility("gubergren") /// .doit().await; /// # } /// ``` pub struct PropertyDeleteCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _property_key: String, _visibility: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PropertyDeleteCall<'a, S> {} impl<'a, S> PropertyDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.properties.delete", http_method: hyper::Method::DELETE }); for &field in ["fileId", "propertyKey", "visibility"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("propertyKey", self._property_key); if let Some(value) = self._visibility.as_ref() { params.push("visibility", value); } params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "files/{fileId}/properties/{propertyKey}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{propertyKey}", "propertyKey")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["propertyKey", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PropertyDeleteCall<'a, S> { self._file_id = new_value.to_string(); self } /// The key of the property. /// /// Sets the *property key* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn property_key(mut self, new_value: &str) -> PropertyDeleteCall<'a, S> { self._property_key = new_value.to_string(); self } /// The visibility of the property. /// /// Sets the *visibility* query property to the given value. pub fn visibility(mut self, new_value: &str) -> PropertyDeleteCall<'a, S> { self._visibility = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PropertyDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PropertyDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PropertyDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PropertyDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PropertyDeleteCall<'a, S> { self._scopes.clear(); self } } /// Gets a property by its key. /// /// A builder for the *get* method supported by a *property* resource. /// It is not used directly, but through a [`PropertyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().get("fileId", "propertyKey") /// .visibility("kasd") /// .doit().await; /// # } /// ``` pub struct PropertyGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _property_key: String, _visibility: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PropertyGetCall<'a, S> {} impl<'a, S> PropertyGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Property)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.properties.get", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "propertyKey", "visibility"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("propertyKey", self._property_key); if let Some(value) = self._visibility.as_ref() { params.push("visibility", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/properties/{propertyKey}"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{propertyKey}", "propertyKey")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["propertyKey", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PropertyGetCall<'a, S> { self._file_id = new_value.to_string(); self } /// The key of the property. /// /// Sets the *property key* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn property_key(mut self, new_value: &str) -> PropertyGetCall<'a, S> { self._property_key = new_value.to_string(); self } /// The visibility of the property. /// /// Sets the *visibility* query property to the given value. pub fn visibility(mut self, new_value: &str) -> PropertyGetCall<'a, S> { self._visibility = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PropertyGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PropertyGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PropertyGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PropertyGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PropertyGetCall<'a, S> { self._scopes.clear(); self } } /// Adds a property to a file, or updates it if it already exists. /// /// A builder for the *insert* method supported by a *property* resource. /// It is not used directly, but through a [`PropertyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Property; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Property::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().insert(req, "fileId") /// .doit().await; /// # } /// ``` pub struct PropertyInsertCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Property, _file_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PropertyInsertCall<'a, S> {} impl<'a, S> PropertyInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Property)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.properties.insert", http_method: hyper::Method::POST }); for &field in ["alt", "fileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("fileId", self._file_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/properties"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Property) -> PropertyInsertCall<'a, S> { self._request = new_value; self } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PropertyInsertCall<'a, S> { self._file_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PropertyInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PropertyInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PropertyInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PropertyInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PropertyInsertCall<'a, S> { self._scopes.clear(); self } } /// Lists a file's properties. /// /// A builder for the *list* method supported by a *property* resource. /// It is not used directly, but through a [`PropertyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().list("fileId") /// .doit().await; /// # } /// ``` pub struct PropertyListCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PropertyListCall<'a, S> {} impl<'a, S> PropertyListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PropertyList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.properties.list", http_method: hyper::Method::GET }); for &field in ["alt", "fileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("fileId", self._file_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/properties"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PropertyListCall<'a, S> { self._file_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PropertyListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PropertyListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PropertyListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PropertyListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PropertyListCall<'a, S> { self._scopes.clear(); self } } /// Updates a property. /// /// A builder for the *patch* method supported by a *property* resource. /// It is not used directly, but through a [`PropertyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Property; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Property::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().patch(req, "fileId", "propertyKey") /// .visibility("Lorem") /// .doit().await; /// # } /// ``` pub struct PropertyPatchCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Property, _file_id: String, _property_key: String, _visibility: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PropertyPatchCall<'a, S> {} impl<'a, S> PropertyPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Property)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.properties.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "fileId", "propertyKey", "visibility"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("propertyKey", self._property_key); if let Some(value) = self._visibility.as_ref() { params.push("visibility", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/properties/{propertyKey}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{propertyKey}", "propertyKey")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["propertyKey", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Property) -> PropertyPatchCall<'a, S> { self._request = new_value; self } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PropertyPatchCall<'a, S> { self._file_id = new_value.to_string(); self } /// The key of the property. /// /// Sets the *property key* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn property_key(mut self, new_value: &str) -> PropertyPatchCall<'a, S> { self._property_key = new_value.to_string(); self } /// The visibility of the property. Allowed values are PRIVATE and PUBLIC. (Default: PRIVATE) /// /// Sets the *visibility* query property to the given value. pub fn visibility(mut self, new_value: &str) -> PropertyPatchCall<'a, S> { self._visibility = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PropertyPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PropertyPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PropertyPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PropertyPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PropertyPatchCall<'a, S> { self._scopes.clear(); self } } /// Updates a property. /// /// A builder for the *update* method supported by a *property* resource. /// It is not used directly, but through a [`PropertyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Property; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Property::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().update(req, "fileId", "propertyKey") /// .visibility("Stet") /// .doit().await; /// # } /// ``` pub struct PropertyUpdateCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Property, _file_id: String, _property_key: String, _visibility: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for PropertyUpdateCall<'a, S> {} impl<'a, S> PropertyUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Property)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.properties.update", http_method: hyper::Method::PUT }); for &field in ["alt", "fileId", "propertyKey", "visibility"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("propertyKey", self._property_key); if let Some(value) = self._visibility.as_ref() { params.push("visibility", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/properties/{propertyKey}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{propertyKey}", "propertyKey")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["propertyKey", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Property) -> PropertyUpdateCall<'a, S> { self._request = new_value; self } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> PropertyUpdateCall<'a, S> { self._file_id = new_value.to_string(); self } /// The key of the property. /// /// Sets the *property key* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn property_key(mut self, new_value: &str) -> PropertyUpdateCall<'a, S> { self._property_key = new_value.to_string(); self } /// The visibility of the property. Allowed values are PRIVATE and PUBLIC. (Default: PRIVATE) /// /// Sets the *visibility* query property to the given value. pub fn visibility(mut self, new_value: &str) -> PropertyUpdateCall<'a, S> { self._visibility = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PropertyUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PropertyUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PropertyUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PropertyUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PropertyUpdateCall<'a, S> { self._scopes.clear(); self } } /// Deletes a reply. /// /// A builder for the *delete* method supported by a *reply* resource. /// It is not used directly, but through a [`ReplyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.replies().delete("fileId", "commentId", "replyId") /// .doit().await; /// # } /// ``` pub struct ReplyDeleteCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _comment_id: String, _reply_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ReplyDeleteCall<'a, S> {} impl<'a, S> ReplyDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.replies.delete", http_method: hyper::Method::DELETE }); for &field in ["fileId", "commentId", "replyId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("commentId", self._comment_id); params.push("replyId", self._reply_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{commentId}", "commentId"), ("{replyId}", "replyId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["replyId", "commentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the comment. /// /// Sets the *comment id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn comment_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, S> { self._comment_id = new_value.to_string(); self } /// The ID of the reply. /// /// Sets the *reply id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn reply_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, S> { self._reply_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ReplyDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ReplyDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ReplyDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ReplyDeleteCall<'a, S> { self._scopes.clear(); self } } /// Gets a reply. /// /// A builder for the *get* method supported by a *reply* resource. /// It is not used directly, but through a [`ReplyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.replies().get("fileId", "commentId", "replyId") /// .include_deleted(true) /// .doit().await; /// # } /// ``` pub struct ReplyGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _comment_id: String, _reply_id: String, _include_deleted: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ReplyGetCall<'a, S> {} impl<'a, S> ReplyGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CommentReply)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.replies.get", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "commentId", "replyId", "includeDeleted"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("commentId", self._comment_id); params.push("replyId", self._reply_id); if let Some(value) = self._include_deleted.as_ref() { params.push("includeDeleted", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{commentId}", "commentId"), ("{replyId}", "replyId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["replyId", "commentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ReplyGetCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the comment. /// /// Sets the *comment id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn comment_id(mut self, new_value: &str) -> ReplyGetCall<'a, S> { self._comment_id = new_value.to_string(); self } /// The ID of the reply. /// /// Sets the *reply id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn reply_id(mut self, new_value: &str) -> ReplyGetCall<'a, S> { self._reply_id = new_value.to_string(); self } /// If set, this will succeed when retrieving a deleted reply. /// /// Sets the *include deleted* query property to the given value. pub fn include_deleted(mut self, new_value: bool) -> ReplyGetCall<'a, S> { self._include_deleted = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ReplyGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ReplyGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ReplyGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ReplyGetCall<'a, S> { self._scopes.clear(); self } } /// Creates a new reply to the given comment. /// /// A builder for the *insert* method supported by a *reply* resource. /// It is not used directly, but through a [`ReplyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::CommentReply; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CommentReply::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.replies().insert(req, "fileId", "commentId") /// .doit().await; /// # } /// ``` pub struct ReplyInsertCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: CommentReply, _file_id: String, _comment_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ReplyInsertCall<'a, S> {} impl<'a, S> ReplyInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CommentReply)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.replies.insert", http_method: hyper::Method::POST }); for &field in ["alt", "fileId", "commentId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("commentId", self._comment_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["commentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CommentReply) -> ReplyInsertCall<'a, S> { self._request = new_value; self } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ReplyInsertCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the comment. /// /// Sets the *comment id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn comment_id(mut self, new_value: &str) -> ReplyInsertCall<'a, S> { self._comment_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ReplyInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ReplyInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ReplyInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ReplyInsertCall<'a, S> { self._scopes.clear(); self } } /// Lists all of the replies to a comment. /// /// A builder for the *list* method supported by a *reply* resource. /// It is not used directly, but through a [`ReplyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.replies().list("fileId", "commentId") /// .page_token("sed") /// .max_results(-27) /// .include_deleted(true) /// .doit().await; /// # } /// ``` pub struct ReplyListCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _comment_id: String, _page_token: Option, _max_results: Option, _include_deleted: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ReplyListCall<'a, S> {} impl<'a, S> ReplyListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CommentReplyList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.replies.list", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "commentId", "pageToken", "maxResults", "includeDeleted"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("commentId", self._comment_id); if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } if let Some(value) = self._include_deleted.as_ref() { params.push("includeDeleted", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["commentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ReplyListCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the comment. /// /// Sets the *comment id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn comment_id(mut self, new_value: &str) -> ReplyListCall<'a, S> { self._comment_id = new_value.to_string(); self } /// The continuation token, used to page through large result sets. To get the next page of results, set this parameter to the value of "nextPageToken" from the previous response. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ReplyListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// The maximum number of replies to include in the response, used for paging. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> ReplyListCall<'a, S> { self._max_results = Some(new_value); self } /// If set, all replies, including deleted replies (with content stripped) will be returned. /// /// Sets the *include deleted* query property to the given value. pub fn include_deleted(mut self, new_value: bool) -> ReplyListCall<'a, S> { self._include_deleted = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ReplyListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ReplyListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ReplyListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ReplyListCall<'a, S> { self._scopes.clear(); self } } /// Updates an existing reply. /// /// A builder for the *patch* method supported by a *reply* resource. /// It is not used directly, but through a [`ReplyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::CommentReply; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CommentReply::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.replies().patch(req, "fileId", "commentId", "replyId") /// .doit().await; /// # } /// ``` pub struct ReplyPatchCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: CommentReply, _file_id: String, _comment_id: String, _reply_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ReplyPatchCall<'a, S> {} impl<'a, S> ReplyPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CommentReply)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.replies.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "fileId", "commentId", "replyId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("commentId", self._comment_id); params.push("replyId", self._reply_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{commentId}", "commentId"), ("{replyId}", "replyId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["replyId", "commentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CommentReply) -> ReplyPatchCall<'a, S> { self._request = new_value; self } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ReplyPatchCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the comment. /// /// Sets the *comment id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn comment_id(mut self, new_value: &str) -> ReplyPatchCall<'a, S> { self._comment_id = new_value.to_string(); self } /// The ID of the reply. /// /// Sets the *reply id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn reply_id(mut self, new_value: &str) -> ReplyPatchCall<'a, S> { self._reply_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ReplyPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ReplyPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ReplyPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ReplyPatchCall<'a, S> { self._scopes.clear(); self } } /// Updates an existing reply. /// /// A builder for the *update* method supported by a *reply* resource. /// It is not used directly, but through a [`ReplyMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::CommentReply; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CommentReply::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.replies().update(req, "fileId", "commentId", "replyId") /// .doit().await; /// # } /// ``` pub struct ReplyUpdateCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: CommentReply, _file_id: String, _comment_id: String, _reply_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for ReplyUpdateCall<'a, S> {} impl<'a, S> ReplyUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CommentReply)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.replies.update", http_method: hyper::Method::PUT }); for &field in ["alt", "fileId", "commentId", "replyId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("commentId", self._comment_id); params.push("replyId", self._reply_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{commentId}", "commentId"), ("{replyId}", "replyId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["replyId", "commentId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CommentReply) -> ReplyUpdateCall<'a, S> { self._request = new_value; self } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the comment. /// /// Sets the *comment id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn comment_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, S> { self._comment_id = new_value.to_string(); self } /// The ID of the reply. /// /// Sets the *reply id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn reply_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, S> { self._reply_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ReplyUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ReplyUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ReplyUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ReplyUpdateCall<'a, S> { self._scopes.clear(); self } } /// Permanently deletes a file version. You can only delete revisions for files with binary content, like images or videos. Revisions for other files, like Google Docs or Sheets, and the last remaining file version can't be deleted. /// /// A builder for the *delete* method supported by a *revision* resource. /// It is not used directly, but through a [`RevisionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.revisions().delete("fileId", "revisionId") /// .doit().await; /// # } /// ``` pub struct RevisionDeleteCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _revision_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for RevisionDeleteCall<'a, S> {} impl<'a, S> RevisionDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.revisions.delete", http_method: hyper::Method::DELETE }); for &field in ["fileId", "revisionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("revisionId", self._revision_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["revisionId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> RevisionDeleteCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the revision. /// /// Sets the *revision id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn revision_id(mut self, new_value: &str) -> RevisionDeleteCall<'a, S> { self._revision_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RevisionDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> RevisionDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> RevisionDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> RevisionDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> RevisionDeleteCall<'a, S> { self._scopes.clear(); self } } /// Gets a specific revision. /// /// A builder for the *get* method supported by a *revision* resource. /// It is not used directly, but through a [`RevisionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.revisions().get("fileId", "revisionId") /// .doit().await; /// # } /// ``` pub struct RevisionGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _revision_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for RevisionGetCall<'a, S> {} impl<'a, S> RevisionGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Revision)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.revisions.get", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "revisionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("revisionId", self._revision_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["revisionId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> RevisionGetCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID of the revision. /// /// Sets the *revision id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn revision_id(mut self, new_value: &str) -> RevisionGetCall<'a, S> { self._revision_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RevisionGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> RevisionGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> RevisionGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> RevisionGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> RevisionGetCall<'a, S> { self._scopes.clear(); self } } /// Lists a file's revisions. /// /// A builder for the *list* method supported by a *revision* resource. /// It is not used directly, but through a [`RevisionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.revisions().list("fileId") /// .page_token("vero") /// .max_results(-17) /// .doit().await; /// # } /// ``` pub struct RevisionListCall<'a, S> where S: 'a { hub: &'a DriveHub, _file_id: String, _page_token: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for RevisionListCall<'a, S> {} impl<'a, S> RevisionListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, RevisionList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.revisions.list", http_method: hyper::Method::GET }); for &field in ["alt", "fileId", "pageToken", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("fileId", self._file_id); if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions"; if self._scopes.is_empty() { self._scopes.insert(Scope::MetadataReadonly.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> RevisionListCall<'a, S> { self._file_id = new_value.to_string(); self } /// Page token for revisions. To get the next page of results, set this parameter to the value of "nextPageToken" from the previous response. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> RevisionListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of revisions to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> RevisionListCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RevisionListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> RevisionListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::MetadataReadonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> RevisionListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> RevisionListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> RevisionListCall<'a, S> { self._scopes.clear(); self } } /// Updates a revision. /// /// A builder for the *patch* method supported by a *revision* resource. /// It is not used directly, but through a [`RevisionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Revision; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Revision::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.revisions().patch(req, "fileId", "revisionId") /// .doit().await; /// # } /// ``` pub struct RevisionPatchCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Revision, _file_id: String, _revision_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for RevisionPatchCall<'a, S> {} impl<'a, S> RevisionPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Revision)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.revisions.patch", http_method: hyper::Method::PATCH }); for &field in ["alt", "fileId", "revisionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("revisionId", self._revision_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["revisionId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Revision) -> RevisionPatchCall<'a, S> { self._request = new_value; self } /// The ID for the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> RevisionPatchCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID for the revision. /// /// Sets the *revision id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn revision_id(mut self, new_value: &str) -> RevisionPatchCall<'a, S> { self._revision_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RevisionPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> RevisionPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> RevisionPatchCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> RevisionPatchCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> RevisionPatchCall<'a, S> { self._scopes.clear(); self } } /// Updates a revision. /// /// A builder for the *update* method supported by a *revision* resource. /// It is not used directly, but through a [`RevisionMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::Revision; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Revision::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.revisions().update(req, "fileId", "revisionId") /// .doit().await; /// # } /// ``` pub struct RevisionUpdateCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: Revision, _file_id: String, _revision_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for RevisionUpdateCall<'a, S> {} impl<'a, S> RevisionUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Revision)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.revisions.update", http_method: hyper::Method::PUT }); for &field in ["alt", "fileId", "revisionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("fileId", self._file_id); params.push("revisionId", self._revision_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["revisionId", "fileId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Revision) -> RevisionUpdateCall<'a, S> { self._request = new_value; self } /// The ID for the file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> RevisionUpdateCall<'a, S> { self._file_id = new_value.to_string(); self } /// The ID for the revision. /// /// Sets the *revision id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn revision_id(mut self, new_value: &str) -> RevisionUpdateCall<'a, S> { self._revision_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RevisionUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> RevisionUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> RevisionUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> RevisionUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> RevisionUpdateCall<'a, S> { self._scopes.clear(); self } } /// Deprecated: Use `drives.delete` instead. /// /// A builder for the *delete* method supported by a *teamdrive* resource. /// It is not used directly, but through a [`TeamdriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.teamdrives().delete("teamDriveId") /// .doit().await; /// # } /// ``` pub struct TeamdriveDeleteCall<'a, S> where S: 'a { hub: &'a DriveHub, _team_drive_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for TeamdriveDeleteCall<'a, S> {} impl<'a, S> TeamdriveDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.teamdrives.delete", http_method: hyper::Method::DELETE }); for &field in ["teamDriveId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(2 + self._additional_params.len()); params.push("teamDriveId", self._team_drive_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["teamDriveId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the Team Drive /// /// Sets the *team drive id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveDeleteCall<'a, S> { self._team_drive_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TeamdriveDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> TeamdriveDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> TeamdriveDeleteCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> TeamdriveDeleteCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> TeamdriveDeleteCall<'a, S> { self._scopes.clear(); self } } /// Deprecated: Use `drives.get` instead. /// /// A builder for the *get* method supported by a *teamdrive* resource. /// It is not used directly, but through a [`TeamdriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.teamdrives().get("teamDriveId") /// .use_domain_admin_access(false) /// .doit().await; /// # } /// ``` pub struct TeamdriveGetCall<'a, S> where S: 'a { hub: &'a DriveHub, _team_drive_id: String, _use_domain_admin_access: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for TeamdriveGetCall<'a, S> {} impl<'a, S> TeamdriveGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TeamDrive)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.teamdrives.get", http_method: hyper::Method::GET }); for &field in ["alt", "teamDriveId", "useDomainAdminAccess"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("teamDriveId", self._team_drive_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["teamDriveId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the Team Drive /// /// Sets the *team drive id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveGetCall<'a, S> { self._team_drive_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveGetCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TeamdriveGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> TeamdriveGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> TeamdriveGetCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> TeamdriveGetCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> TeamdriveGetCall<'a, S> { self._scopes.clear(); self } } /// Deprecated: Use `drives.insert` instead. /// /// A builder for the *insert* method supported by a *teamdrive* resource. /// It is not used directly, but through a [`TeamdriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::TeamDrive; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = TeamDrive::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.teamdrives().insert(req, "requestId") /// .doit().await; /// # } /// ``` pub struct TeamdriveInsertCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: TeamDrive, _request_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for TeamdriveInsertCall<'a, S> {} impl<'a, S> TeamdriveInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TeamDrive)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.teamdrives.insert", http_method: hyper::Method::POST }); for &field in ["alt", "requestId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("requestId", self._request_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "teamdrives"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: TeamDrive) -> TeamdriveInsertCall<'a, S> { self._request = new_value; self } /// Required. 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. /// /// Sets the *request id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request_id(mut self, new_value: &str) -> TeamdriveInsertCall<'a, S> { self._request_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TeamdriveInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> TeamdriveInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> TeamdriveInsertCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> TeamdriveInsertCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> TeamdriveInsertCall<'a, S> { self._scopes.clear(); self } } /// Deprecated: Use `drives.list` instead. /// /// A builder for the *list* method supported by a *teamdrive* resource. /// It is not used directly, but through a [`TeamdriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.teamdrives().list() /// .use_domain_admin_access(true) /// .q("ea") /// .page_token("aliquyam") /// .max_results(-91) /// .doit().await; /// # } /// ``` pub struct TeamdriveListCall<'a, S> where S: 'a { hub: &'a DriveHub, _use_domain_admin_access: Option, _q: Option, _page_token: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for TeamdriveListCall<'a, S> {} impl<'a, S> TeamdriveListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TeamDriveList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.teamdrives.list", http_method: hyper::Method::GET }); for &field in ["alt", "useDomainAdminAccess", "q", "pageToken", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } if let Some(value) = self._q.as_ref() { params.push("q", value); } if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._max_results.as_ref() { params.push("maxResults", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "teamdrives"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } let url = params.parse_with_url(&url); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveListCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// Query string for searching Team Drives. /// /// Sets the *q* query property to the given value. pub fn q(mut self, new_value: &str) -> TeamdriveListCall<'a, S> { self._q = Some(new_value.to_string()); self } /// Page token for Team Drives. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> TeamdriveListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of Team Drives to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> TeamdriveListCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TeamdriveListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> TeamdriveListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> TeamdriveListCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> TeamdriveListCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> TeamdriveListCall<'a, S> { self._scopes.clear(); self } } /// Deprecated: Use `drives.update` instead. /// /// A builder for the *update* method supported by a *teamdrive* resource. /// It is not used directly, but through a [`TeamdriveMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_drive2 as drive2; /// use drive2::api::TeamDrive; /// # async fn dox() { /// # use std::default::Default; /// # use drive2::{DriveHub, oauth2, hyper, hyper_rustls, chrono, FieldMask}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = TeamDrive::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.teamdrives().update(req, "teamDriveId") /// .use_domain_admin_access(true) /// .doit().await; /// # } /// ``` pub struct TeamdriveUpdateCall<'a, S> where S: 'a { hub: &'a DriveHub, _request: TeamDrive, _team_drive_id: String, _use_domain_admin_access: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeSet } impl<'a, S> client::CallBuilder for TeamdriveUpdateCall<'a, S> {} impl<'a, S> TeamdriveUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TeamDrive)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::{ToParts, url::Params}; use std::borrow::Cow; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(client::MethodInfo { id: "drive.teamdrives.update", http_method: hyper::Method::PUT }); for &field in ["alt", "teamDriveId", "useDomainAdminAccess"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("teamDriveId", self._team_drive_id); if let Some(value) = self._use_domain_admin_access.as_ref() { params.push("useDomainAdminAccess", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Full.as_ref().to_string()); } for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["teamDriveId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { Ok(token) => token, Err(e) => { match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(client::Error::MissingToken(e)); } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d).await; continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: TeamDrive) -> TeamdriveUpdateCall<'a, S> { self._request = new_value; self } /// The ID of the Team Drive /// /// Sets the *team drive id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveUpdateCall<'a, S> { self._team_drive_id = new_value.to_string(); self } /// 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. /// /// Sets the *use domain admin access* query property to the given value. pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveUpdateCall<'a, S> { self._use_domain_admin_access = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TeamdriveUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> TeamdriveUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Full`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> TeamdriveUpdateCall<'a, S> where St: AsRef { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> TeamdriveUpdateCall<'a, S> where I: IntoIterator, St: AsRef { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> TeamdriveUpdateCall<'a, S> { self._scopes.clear(); self } }