google_drive2/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, create, and delete all of your Google Drive files
17 Full,
18
19 /// See, create, and delete its own configuration data in your Google Drive
20 Appdata,
21
22 /// View your Google Drive apps
23 AppReadonly,
24
25 /// See, edit, create, and delete only the specific Google Drive files you use with this app
26 File,
27
28 /// See and download your Google Drive files that were created or edited by Google Meet.
29 MeetReadonly,
30
31 /// View and manage metadata of files in your Google Drive
32 Metadata,
33
34 /// See information about your Google Drive files
35 MetadataReadonly,
36
37 /// View the photos, videos and albums in your Google Photos
38 PhotoReadonly,
39
40 /// See and download all your Google Drive files
41 Readonly,
42
43 /// Modify your Google Apps Script scripts' behavior
44 Script,
45}
46
47impl AsRef<str> for Scope {
48 fn as_ref(&self) -> &str {
49 match *self {
50 Scope::Full => "https://www.googleapis.com/auth/drive",
51 Scope::Appdata => "https://www.googleapis.com/auth/drive.appdata",
52 Scope::AppReadonly => "https://www.googleapis.com/auth/drive.apps.readonly",
53 Scope::File => "https://www.googleapis.com/auth/drive.file",
54 Scope::MeetReadonly => "https://www.googleapis.com/auth/drive.meet.readonly",
55 Scope::Metadata => "https://www.googleapis.com/auth/drive.metadata",
56 Scope::MetadataReadonly => "https://www.googleapis.com/auth/drive.metadata.readonly",
57 Scope::PhotoReadonly => "https://www.googleapis.com/auth/drive.photos.readonly",
58 Scope::Readonly => "https://www.googleapis.com/auth/drive.readonly",
59 Scope::Script => "https://www.googleapis.com/auth/drive.scripts",
60 }
61 }
62}
63
64#[allow(clippy::derivable_impls)]
65impl Default for Scope {
66 fn default() -> Scope {
67 Scope::AppReadonly
68 }
69}
70
71// ########
72// HUB ###
73// ######
74
75/// Central instance to access all DriveHub related resource activities
76///
77/// # Examples
78///
79/// Instantiate a new hub
80///
81/// ```test_harness,no_run
82/// extern crate hyper;
83/// extern crate hyper_rustls;
84/// extern crate google_drive2 as drive2;
85/// use drive2::api::File;
86/// use drive2::{Result, Error};
87/// # async fn dox() {
88/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
89///
90/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
91/// // `client_secret`, among other things.
92/// let secret: yup_oauth2::ApplicationSecret = Default::default();
93/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
94/// // unless you replace `None` with the desired Flow.
95/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
96/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
97/// // retrieve them from storage.
98/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
99/// .with_native_roots()
100/// .unwrap()
101/// .https_only()
102/// .enable_http2()
103/// .build();
104///
105/// let executor = hyper_util::rt::TokioExecutor::new();
106/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
107/// secret,
108/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
109/// yup_oauth2::client::CustomHyperClientBuilder::from(
110/// hyper_util::client::legacy::Client::builder(executor).build(connector),
111/// ),
112/// ).build().await.unwrap();
113///
114/// let client = hyper_util::client::legacy::Client::builder(
115/// hyper_util::rt::TokioExecutor::new()
116/// )
117/// .build(
118/// hyper_rustls::HttpsConnectorBuilder::new()
119/// .with_native_roots()
120/// .unwrap()
121/// .https_or_http()
122/// .enable_http2()
123/// .build()
124/// );
125/// let mut hub = DriveHub::new(client, auth);
126/// // As the method needs a request, you would usually fill it with the desired information
127/// // into the respective structure. Some of the parts shown here might not be applicable !
128/// // Values shown here are possibly random and not representative !
129/// let mut req = File::default();
130///
131/// // You can configure optional parameters by calling the respective setters at will, and
132/// // execute the final call using `doit()`.
133/// // Values shown here are possibly random and not representative !
134/// let result = hub.files().patch(req, "fileId")
135/// .use_content_as_indexable_text(false)
136/// .update_viewed_date(false)
137/// .timed_text_track_name("duo")
138/// .timed_text_language("vero")
139/// .supports_team_drives(false)
140/// .supports_all_drives(false)
141/// .set_modified_date(true)
142/// .remove_parents("vero")
143/// .pinned(true)
144/// .ocr_language("Lorem")
145/// .ocr(true)
146/// .new_revision(false)
147/// .modified_date_behavior("accusam")
148/// .include_permissions_for_view("takimata")
149/// .include_labels("consetetur")
150/// .enforce_single_parent(false)
151/// .convert(false)
152/// .add_parents("amet.")
153/// .doit().await;
154///
155/// match result {
156/// Err(e) => match e {
157/// // The Error enum provides details about what exactly happened.
158/// // You can also just use its `Debug`, `Display` or `Error` traits
159/// Error::HttpError(_)
160/// |Error::Io(_)
161/// |Error::MissingAPIKey
162/// |Error::MissingToken(_)
163/// |Error::Cancelled
164/// |Error::UploadSizeLimitExceeded(_, _)
165/// |Error::Failure(_)
166/// |Error::BadRequest(_)
167/// |Error::FieldClash(_)
168/// |Error::JsonDecodeError(_, _) => println!("{}", e),
169/// },
170/// Ok(res) => println!("Success: {:?}", res),
171/// }
172/// # }
173/// ```
174#[derive(Clone)]
175pub struct DriveHub<C> {
176 pub client: common::Client<C>,
177 pub auth: Box<dyn common::GetToken>,
178 _user_agent: String,
179 _base_url: String,
180 _root_url: String,
181}
182
183impl<C> common::Hub for DriveHub<C> {}
184
185impl<'a, C> DriveHub<C> {
186 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> DriveHub<C> {
187 DriveHub {
188 client,
189 auth: Box::new(auth),
190 _user_agent: "google-api-rust-client/7.0.0".to_string(),
191 _base_url: "https://www.googleapis.com/drive/v2/".to_string(),
192 _root_url: "https://www.googleapis.com/".to_string(),
193 }
194 }
195
196 pub fn about(&'a self) -> AboutMethods<'a, C> {
197 AboutMethods { hub: self }
198 }
199 pub fn apps(&'a self) -> AppMethods<'a, C> {
200 AppMethods { hub: self }
201 }
202 pub fn changes(&'a self) -> ChangeMethods<'a, C> {
203 ChangeMethods { hub: self }
204 }
205 pub fn channels(&'a self) -> ChannelMethods<'a, C> {
206 ChannelMethods { hub: self }
207 }
208 pub fn children(&'a self) -> ChildMethods<'a, C> {
209 ChildMethods { hub: self }
210 }
211 pub fn comments(&'a self) -> CommentMethods<'a, C> {
212 CommentMethods { hub: self }
213 }
214 pub fn drives(&'a self) -> DriveMethods<'a, C> {
215 DriveMethods { hub: self }
216 }
217 pub fn files(&'a self) -> FileMethods<'a, C> {
218 FileMethods { hub: self }
219 }
220 pub fn parents(&'a self) -> ParentMethods<'a, C> {
221 ParentMethods { hub: self }
222 }
223 pub fn permissions(&'a self) -> PermissionMethods<'a, C> {
224 PermissionMethods { hub: self }
225 }
226 pub fn properties(&'a self) -> PropertyMethods<'a, C> {
227 PropertyMethods { hub: self }
228 }
229 pub fn replies(&'a self) -> ReplyMethods<'a, C> {
230 ReplyMethods { hub: self }
231 }
232 pub fn revisions(&'a self) -> RevisionMethods<'a, C> {
233 RevisionMethods { hub: self }
234 }
235 pub fn teamdrives(&'a self) -> TeamdriveMethods<'a, C> {
236 TeamdriveMethods { hub: self }
237 }
238
239 /// Set the user-agent header field to use in all requests to the server.
240 /// It defaults to `google-api-rust-client/7.0.0`.
241 ///
242 /// Returns the previously set user-agent.
243 pub fn user_agent(&mut self, agent_name: String) -> String {
244 std::mem::replace(&mut self._user_agent, agent_name)
245 }
246
247 /// Set the base url to use in all requests to the server.
248 /// It defaults to `https://www.googleapis.com/drive/v2/`.
249 ///
250 /// Returns the previously set base url.
251 pub fn base_url(&mut self, new_base_url: String) -> String {
252 std::mem::replace(&mut self._base_url, new_base_url)
253 }
254
255 /// Set the root url to use in all requests to the server.
256 /// It defaults to `https://www.googleapis.com/`.
257 ///
258 /// Returns the previously set root url.
259 pub fn root_url(&mut self, new_root_url: String) -> String {
260 std::mem::replace(&mut self._root_url, new_root_url)
261 }
262}
263
264// ############
265// SCHEMAS ###
266// ##########
267/// An item with user information and settings.
268///
269/// # Activities
270///
271/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
272/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
273///
274/// * [get about](AboutGetCall) (response)
275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
276#[serde_with::serde_as]
277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
278pub struct About {
279 /// Information about supported additional roles per file type. The most specific type takes precedence.
280 #[serde(rename = "additionalRoleInfo")]
281 pub additional_role_info: Option<Vec<AboutAdditionalRoleInfo>>,
282 /// Whether the user can create shared drives.
283 #[serde(rename = "canCreateDrives")]
284 pub can_create_drives: Option<bool>,
285 /// Deprecated: Use `canCreateDrives` instead.
286 #[serde(rename = "canCreateTeamDrives")]
287 pub can_create_team_drives: Option<bool>,
288 /// The domain sharing policy for the current user. Possible values are: * `allowed` * `allowedWithWarning` * `incomingOnly` * `disallowed`
289 #[serde(rename = "domainSharingPolicy")]
290 pub domain_sharing_policy: Option<String>,
291 /// A list of themes that are supported for shared drives.
292 #[serde(rename = "driveThemes")]
293 pub drive_themes: Option<Vec<AboutDriveThemes>>,
294 /// The ETag of the item.
295 pub etag: Option<String>,
296 /// The allowable export formats.
297 #[serde(rename = "exportFormats")]
298 pub export_formats: Option<Vec<AboutExportFormats>>,
299 /// List of additional features enabled on this account.
300 pub features: Option<Vec<AboutFeatures>>,
301 /// The palette of allowable folder colors as RGB hex strings.
302 #[serde(rename = "folderColorPalette")]
303 pub folder_color_palette: Option<Vec<String>>,
304 /// The allowable import formats.
305 #[serde(rename = "importFormats")]
306 pub import_formats: Option<Vec<AboutImportFormats>>,
307 /// A boolean indicating whether the authenticated app is installed by the authenticated user.
308 #[serde(rename = "isCurrentAppInstalled")]
309 pub is_current_app_installed: Option<bool>,
310 /// This is always `drive#about`.
311 pub kind: Option<String>,
312 /// 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/).
313 #[serde(rename = "languageCode")]
314 pub language_code: Option<String>,
315 /// The largest change id.
316 #[serde(rename = "largestChangeId")]
317 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
318 pub largest_change_id: Option<i64>,
319 /// List of max upload sizes for each file type. The most specific type takes precedence.
320 #[serde(rename = "maxUploadSizes")]
321 pub max_upload_sizes: Option<Vec<AboutMaxUploadSizes>>,
322 /// The name of the current user.
323 pub name: Option<String>,
324 /// The current user's ID as visible in the permissions collection.
325 #[serde(rename = "permissionId")]
326 pub permission_id: Option<String>,
327 /// The amount of storage quota used by different Google services.
328 #[serde(rename = "quotaBytesByService")]
329 pub quota_bytes_by_service: Option<Vec<AboutQuotaBytesByService>>,
330 /// The total number of quota bytes. This is only relevant when quotaType is LIMITED.
331 #[serde(rename = "quotaBytesTotal")]
332 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
333 pub quota_bytes_total: Option<i64>,
334 /// The number of quota bytes used by Google Drive.
335 #[serde(rename = "quotaBytesUsed")]
336 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
337 pub quota_bytes_used: Option<i64>,
338 /// The number of quota bytes used by all Google apps (Drive, Picasa, etc.).
339 #[serde(rename = "quotaBytesUsedAggregate")]
340 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
341 pub quota_bytes_used_aggregate: Option<i64>,
342 /// The number of quota bytes used by trashed items.
343 #[serde(rename = "quotaBytesUsedInTrash")]
344 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
345 pub quota_bytes_used_in_trash: Option<i64>,
346 /// The type of the user's storage quota. Possible values are: * `LIMITED` * `UNLIMITED`
347 #[serde(rename = "quotaType")]
348 pub quota_type: Option<String>,
349 /// The number of remaining change ids, limited to no more than 2500.
350 #[serde(rename = "remainingChangeIds")]
351 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
352 pub remaining_change_ids: Option<i64>,
353 /// The id of the root folder.
354 #[serde(rename = "rootFolderId")]
355 pub root_folder_id: Option<String>,
356 /// A link back to this item.
357 #[serde(rename = "selfLink")]
358 pub self_link: Option<String>,
359 /// Deprecated: Use `driveThemes` instead.
360 #[serde(rename = "teamDriveThemes")]
361 pub team_drive_themes: Option<Vec<AboutTeamDriveThemes>>,
362 /// The authenticated user.
363 pub user: Option<User>,
364}
365
366impl common::ResponseResult for About {}
367
368/// 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.
369///
370/// # Activities
371///
372/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
373/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
374///
375/// * [get apps](AppGetCall) (response)
376/// * [list apps](AppListCall) (none)
377#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
378#[serde_with::serde_as]
379#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
380pub struct App {
381 /// Whether the app is authorized to access data on the user's Drive.
382 pub authorized: Option<bool>,
383 /// 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.
384 #[serde(rename = "createInFolderTemplate")]
385 pub create_in_folder_template: Option<String>,
386 /// The url to create a new file with this app.
387 #[serde(rename = "createUrl")]
388 pub create_url: Option<String>,
389 /// Whether the app has drive-wide scope. An app with drive-wide scope can access all files in the user's drive.
390 #[serde(rename = "hasDriveWideScope")]
391 pub has_drive_wide_scope: Option<bool>,
392 /// The various icons for the app.
393 pub icons: Option<Vec<AppIcons>>,
394 /// The ID of the app.
395 pub id: Option<String>,
396 /// Whether the app is installed.
397 pub installed: Option<bool>,
398 /// This is always `drive#app`.
399 pub kind: Option<String>,
400 /// A long description of the app.
401 #[serde(rename = "longDescription")]
402 pub long_description: Option<String>,
403 /// The name of the app.
404 pub name: Option<String>,
405 /// The type of object this app creates (e.g. Chart). If empty, the app name should be used instead.
406 #[serde(rename = "objectType")]
407 pub object_type: Option<String>,
408 /// 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.
409 #[serde(rename = "openUrlTemplate")]
410 pub open_url_template: Option<String>,
411 /// The list of primary file extensions.
412 #[serde(rename = "primaryFileExtensions")]
413 pub primary_file_extensions: Option<Vec<String>>,
414 /// The list of primary mime types.
415 #[serde(rename = "primaryMimeTypes")]
416 pub primary_mime_types: Option<Vec<String>>,
417 /// The ID of the product listing for this app.
418 #[serde(rename = "productId")]
419 pub product_id: Option<String>,
420 /// A link to the product listing for this app.
421 #[serde(rename = "productUrl")]
422 pub product_url: Option<String>,
423 /// The list of secondary file extensions.
424 #[serde(rename = "secondaryFileExtensions")]
425 pub secondary_file_extensions: Option<Vec<String>>,
426 /// The list of secondary mime types.
427 #[serde(rename = "secondaryMimeTypes")]
428 pub secondary_mime_types: Option<Vec<String>>,
429 /// A short description of the app.
430 #[serde(rename = "shortDescription")]
431 pub short_description: Option<String>,
432 /// Whether this app supports creating new objects.
433 #[serde(rename = "supportsCreate")]
434 pub supports_create: Option<bool>,
435 /// Whether this app supports importing from Docs Editors.
436 #[serde(rename = "supportsImport")]
437 pub supports_import: Option<bool>,
438 /// Whether this app supports opening more than one file.
439 #[serde(rename = "supportsMultiOpen")]
440 pub supports_multi_open: Option<bool>,
441 /// Whether this app supports creating new files when offline.
442 #[serde(rename = "supportsOfflineCreate")]
443 pub supports_offline_create: Option<bool>,
444 /// Whether the app is selected as the default handler for the types it supports.
445 #[serde(rename = "useByDefault")]
446 pub use_by_default: Option<bool>,
447}
448
449impl common::Resource for App {}
450impl common::ResponseResult for App {}
451
452/// A list of third-party applications which the user has installed or given access to Google Drive.
453///
454/// # Activities
455///
456/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
457/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
458///
459/// * [list apps](AppListCall) (response)
460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
461#[serde_with::serde_as]
462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
463pub struct AppList {
464 /// List of app IDs that the user has specified to use by default. The list is in reverse-priority order (lowest to highest).
465 #[serde(rename = "defaultAppIds")]
466 pub default_app_ids: Option<Vec<String>>,
467 /// The ETag of the list.
468 pub etag: Option<String>,
469 /// The list of apps.
470 pub items: Option<Vec<App>>,
471 /// This is always `drive#appList`.
472 pub kind: Option<String>,
473 /// A link back to this list.
474 #[serde(rename = "selfLink")]
475 pub self_link: Option<String>,
476}
477
478impl common::ResponseResult for AppList {}
479
480/// Representation of a change to a file or shared drive.
481///
482/// # Activities
483///
484/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
485/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
486///
487/// * [get changes](ChangeGetCall) (response)
488/// * [get start page token changes](ChangeGetStartPageTokenCall) (none)
489/// * [list changes](ChangeListCall) (none)
490/// * [watch changes](ChangeWatchCall) (none)
491#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
492#[serde_with::serde_as]
493#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
494pub struct Change {
495 /// The type of the change. Possible values are `file` and `drive`.
496 #[serde(rename = "changeType")]
497 pub change_type: Option<String>,
498 /// Whether the file or shared drive has been removed from this list of changes, for example by deletion or loss of access.
499 pub deleted: Option<bool>,
500 /// 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.
501 pub drive: Option<Drive>,
502 /// The ID of the shared drive associated with this change.
503 #[serde(rename = "driveId")]
504 pub drive_id: Option<String>,
505 /// The updated state of the file. Present if the type is file and the file has not been removed from this list of changes.
506 pub file: Option<File>,
507 /// The ID of the file associated with this change.
508 #[serde(rename = "fileId")]
509 pub file_id: Option<String>,
510 /// The ID of the change.
511 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
512 pub id: Option<i64>,
513 /// This is always `drive#change`.
514 pub kind: Option<String>,
515 /// The time of this modification.
516 #[serde(rename = "modificationDate")]
517 pub modification_date: Option<chrono::DateTime<chrono::offset::Utc>>,
518 /// A link back to this change.
519 #[serde(rename = "selfLink")]
520 pub self_link: Option<String>,
521 /// Deprecated: Use `drive` instead.
522 #[serde(rename = "teamDrive")]
523 pub team_drive: Option<TeamDrive>,
524 /// Deprecated: Use `driveId` instead.
525 #[serde(rename = "teamDriveId")]
526 pub team_drive_id: Option<String>,
527 /// Deprecated: Use `changeType` instead.
528 #[serde(rename = "type")]
529 pub type_: Option<String>,
530}
531
532impl common::Resource for Change {}
533impl common::ResponseResult for Change {}
534
535/// A list of changes for a user.
536///
537/// # Activities
538///
539/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
540/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
541///
542/// * [list changes](ChangeListCall) (response)
543#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
544#[serde_with::serde_as]
545#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
546pub struct ChangeList {
547 /// The ETag of the list.
548 pub etag: Option<String>,
549 /// The list of changes. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
550 pub items: Option<Vec<Change>>,
551 /// This is always `drive#changeList`.
552 pub kind: Option<String>,
553 /// The current largest change ID.
554 #[serde(rename = "largestChangeId")]
555 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
556 pub largest_change_id: Option<i64>,
557 /// The starting page token for future changes. This will be present only if the end of the current changes list has been reached.
558 #[serde(rename = "newStartPageToken")]
559 pub new_start_page_token: Option<String>,
560 /// A link to the next page of changes.
561 #[serde(rename = "nextLink")]
562 pub next_link: Option<String>,
563 /// 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.
564 #[serde(rename = "nextPageToken")]
565 pub next_page_token: Option<String>,
566 /// A link back to this list.
567 #[serde(rename = "selfLink")]
568 pub self_link: Option<String>,
569}
570
571impl common::ResponseResult for ChangeList {}
572
573/// A notification channel used to watch for resource changes.
574///
575/// # Activities
576///
577/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
578/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
579///
580/// * [watch changes](ChangeWatchCall) (request|response)
581/// * [stop channels](ChannelStopCall) (request)
582/// * [watch files](FileWatchCall) (request|response)
583#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
584#[serde_with::serde_as]
585#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
586pub struct Channel {
587 /// The address where notifications are delivered for this channel.
588 pub address: Option<String>,
589 /// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.
590 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
591 pub expiration: Option<i64>,
592 /// A UUID or similar unique string that identifies this channel.
593 pub id: Option<String>,
594 /// Identifies this as a notification channel used to watch for changes to a resource, which is `api#channel`.
595 pub kind: Option<String>,
596 /// Additional parameters controlling delivery channel behavior. Optional.
597 pub params: Option<HashMap<String, String>>,
598 /// A Boolean value to indicate whether payload is wanted. Optional.
599 pub payload: Option<bool>,
600 /// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.
601 #[serde(rename = "resourceId")]
602 pub resource_id: Option<String>,
603 /// A version-specific identifier for the watched resource.
604 #[serde(rename = "resourceUri")]
605 pub resource_uri: Option<String>,
606 /// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.
607 pub token: Option<String>,
608 /// The type of delivery mechanism used for this channel. Valid values are "web_hook" or "webhook".
609 #[serde(rename = "type")]
610 pub type_: Option<String>,
611}
612
613impl common::RequestValue for Channel {}
614impl common::Resource for Channel {}
615impl common::ResponseResult for Channel {}
616
617/// A list of children of a file.
618///
619/// # Activities
620///
621/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
622/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
623///
624/// * [list children](ChildListCall) (response)
625#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
626#[serde_with::serde_as]
627#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
628pub struct ChildList {
629 /// The ETag of the list.
630 pub etag: Option<String>,
631 /// The list of children. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
632 pub items: Option<Vec<ChildReference>>,
633 /// This is always `drive#childList`.
634 pub kind: Option<String>,
635 /// A link to the next page of children.
636 #[serde(rename = "nextLink")]
637 pub next_link: Option<String>,
638 /// 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.
639 #[serde(rename = "nextPageToken")]
640 pub next_page_token: Option<String>,
641 /// A link back to this list.
642 #[serde(rename = "selfLink")]
643 pub self_link: Option<String>,
644}
645
646impl common::ResponseResult for ChildList {}
647
648/// 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.
649///
650/// # Activities
651///
652/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
653/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
654///
655/// * [get children](ChildGetCall) (response)
656/// * [insert children](ChildInsertCall) (request|response)
657#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
658#[serde_with::serde_as]
659#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
660pub struct ChildReference {
661 /// Output only. A link to the child.
662 #[serde(rename = "childLink")]
663 pub child_link: Option<String>,
664 /// The ID of the child.
665 pub id: Option<String>,
666 /// Output only. This is always `drive#childReference`.
667 pub kind: Option<String>,
668 /// Output only. A link back to this reference.
669 #[serde(rename = "selfLink")]
670 pub self_link: Option<String>,
671}
672
673impl common::RequestValue for ChildReference {}
674impl common::ResponseResult for ChildReference {}
675
676/// A comment on a file in Google Drive.
677///
678/// # Activities
679///
680/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
681/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
682///
683/// * [delete comments](CommentDeleteCall) (none)
684/// * [get comments](CommentGetCall) (response)
685/// * [insert comments](CommentInsertCall) (request|response)
686/// * [list comments](CommentListCall) (none)
687/// * [patch comments](CommentPatchCall) (request|response)
688/// * [update comments](CommentUpdateCall) (request|response)
689#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
690#[serde_with::serde_as]
691#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
692pub struct Comment {
693 /// A region of the document represented as a JSON string. For details on defining anchor properties, refer to [Manage comments and replies](https://developers.google.com/workspace/drive/api/v3/manage-comments).
694 pub anchor: Option<String>,
695 /// The user who wrote this comment.
696 pub author: Option<User>,
697 /// The ID of the comment.
698 #[serde(rename = "commentId")]
699 pub comment_id: Option<String>,
700 /// 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.
701 pub content: Option<String>,
702 /// Context of a file which is being commented on.
703 pub context: Option<CommentContext>,
704 /// The date when this comment was first created.
705 #[serde(rename = "createdDate")]
706 pub created_date: Option<chrono::DateTime<chrono::offset::Utc>>,
707 /// 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.
708 pub deleted: Option<bool>,
709 /// The file which this comment is addressing.
710 #[serde(rename = "fileId")]
711 pub file_id: Option<String>,
712 /// The title of the file which this comment is addressing.
713 #[serde(rename = "fileTitle")]
714 pub file_title: Option<String>,
715 /// HTML formatted content for this comment.
716 #[serde(rename = "htmlContent")]
717 pub html_content: Option<String>,
718 /// This is always drive#comment.
719 pub kind: Option<String>,
720 /// The date when this comment or any of its replies were last modified.
721 #[serde(rename = "modifiedDate")]
722 pub modified_date: Option<chrono::DateTime<chrono::offset::Utc>>,
723 /// Replies to this post.
724 pub replies: Option<Vec<CommentReply>>,
725 /// A link back to this comment.
726 #[serde(rename = "selfLink")]
727 pub self_link: Option<String>,
728 /// The status of this comment. Status can be changed by posting a reply to a comment with the desired status. Possible values are: * `open` - The comment is still open. * `resolved` - The comment has been resolved by one of its replies.
729 pub status: Option<String>,
730}
731
732impl common::RequestValue for Comment {}
733impl common::Resource for Comment {}
734impl common::ResponseResult for Comment {}
735
736/// A list of comments on a file in Google Drive.
737///
738/// # Activities
739///
740/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
741/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
742///
743/// * [list comments](CommentListCall) (response)
744#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
745#[serde_with::serde_as]
746#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
747pub struct CommentList {
748 /// The list of comments. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
749 pub items: Option<Vec<Comment>>,
750 /// This is always drive#commentList.
751 pub kind: Option<String>,
752 /// A link to the next page of comments.
753 #[serde(rename = "nextLink")]
754 pub next_link: Option<String>,
755 /// 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.
756 #[serde(rename = "nextPageToken")]
757 pub next_page_token: Option<String>,
758 /// A link back to this list.
759 #[serde(rename = "selfLink")]
760 pub self_link: Option<String>,
761}
762
763impl common::ResponseResult for CommentList {}
764
765/// A reply to a comment on a file in Google Drive.
766///
767/// # Activities
768///
769/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
770/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
771///
772/// * [get replies](ReplyGetCall) (response)
773/// * [insert replies](ReplyInsertCall) (request|response)
774/// * [patch replies](ReplyPatchCall) (request|response)
775/// * [update replies](ReplyUpdateCall) (request|response)
776#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
777#[serde_with::serde_as]
778#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
779pub struct CommentReply {
780 /// The user who wrote this reply.
781 pub author: Option<User>,
782 /// 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).
783 pub content: Option<String>,
784 /// The date when this reply was first created.
785 #[serde(rename = "createdDate")]
786 pub created_date: Option<chrono::DateTime<chrono::offset::Utc>>,
787 /// 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.
788 pub deleted: Option<bool>,
789 /// HTML formatted content for this reply.
790 #[serde(rename = "htmlContent")]
791 pub html_content: Option<String>,
792 /// This is always drive#commentReply.
793 pub kind: Option<String>,
794 /// The date when this reply was last modified.
795 #[serde(rename = "modifiedDate")]
796 pub modified_date: Option<chrono::DateTime<chrono::offset::Utc>>,
797 /// The ID of the reply.
798 #[serde(rename = "replyId")]
799 pub reply_id: Option<String>,
800 /// The action this reply performed to the parent comment. When creating a new reply this is the action to be perform tSo the parent comment. Possible values are: * `resolve` - To resolve a comment. * `reopen` - To reopen (un-resolve) a comment.
801 pub verb: Option<String>,
802}
803
804impl common::RequestValue for CommentReply {}
805impl common::ResponseResult for CommentReply {}
806
807/// A list of replies to a comment on a file in Google Drive.
808///
809/// # Activities
810///
811/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
812/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
813///
814/// * [list replies](ReplyListCall) (response)
815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
816#[serde_with::serde_as]
817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
818pub struct CommentReplyList {
819 /// The list of replies. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
820 pub items: Option<Vec<CommentReply>>,
821 /// This is always `drive#commentReplyList`.
822 pub kind: Option<String>,
823 /// A link to the next page of replies.
824 #[serde(rename = "nextLink")]
825 pub next_link: Option<String>,
826 /// 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.
827 #[serde(rename = "nextPageToken")]
828 pub next_page_token: Option<String>,
829 /// A link back to this list.
830 #[serde(rename = "selfLink")]
831 pub self_link: Option<String>,
832}
833
834impl common::ResponseResult for CommentReplyList {}
835
836/// A restriction for accessing the content of the file.
837///
838/// This type is not used in any activity, and only used as *part* of another schema.
839///
840#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
841#[serde_with::serde_as]
842#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
843pub struct ContentRestriction {
844 /// 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.
845 #[serde(rename = "ownerRestricted")]
846 pub owner_restricted: Option<bool>,
847 /// 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.
848 #[serde(rename = "readOnly")]
849 pub read_only: Option<bool>,
850 /// Reason for why the content of the file is restricted. This is only mutable on requests that also set `readOnly=true`.
851 pub reason: Option<String>,
852 /// Output only. The user who set the content restriction. Only populated if `readOnly` is true.
853 #[serde(rename = "restrictingUser")]
854 pub restricting_user: Option<User>,
855 /// The time at which the content restriction was set (formatted RFC 3339 timestamp). Only populated if readOnly is true.
856 #[serde(rename = "restrictionDate")]
857 pub restriction_date: Option<chrono::DateTime<chrono::offset::Utc>>,
858 /// 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.
859 #[serde(rename = "systemRestricted")]
860 pub system_restricted: Option<bool>,
861 /// Output only. The type of the content restriction. Currently the only possible value is `globalContentRestriction`.
862 #[serde(rename = "type")]
863 pub type_: Option<String>,
864}
865
866impl common::Part for ContentRestriction {}
867
868/// 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.
869///
870/// # Activities
871///
872/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
873/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
874///
875/// * [delete drives](DriveDeleteCall) (none)
876/// * [get drives](DriveGetCall) (response)
877/// * [hide drives](DriveHideCall) (response)
878/// * [insert drives](DriveInsertCall) (request|response)
879/// * [list drives](DriveListCall) (none)
880/// * [unhide drives](DriveUnhideCall) (response)
881/// * [update drives](DriveUpdateCall) (request|response)
882#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
883#[serde_with::serde_as]
884#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
885pub struct Drive {
886 /// 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.
887 #[serde(rename = "backgroundImageFile")]
888 pub background_image_file: Option<DriveBackgroundImageFile>,
889 /// Output only. A short-lived link to this shared drive's background image.
890 #[serde(rename = "backgroundImageLink")]
891 pub background_image_link: Option<String>,
892 /// Output only. Capabilities the current user has on this shared drive.
893 pub capabilities: Option<DriveCapabilities>,
894 /// 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`.
895 #[serde(rename = "colorRgb")]
896 pub color_rgb: Option<String>,
897 /// The time at which the shared drive was created (RFC 3339 date-time).
898 #[serde(rename = "createdDate")]
899 pub created_date: Option<chrono::DateTime<chrono::offset::Utc>>,
900 /// Whether the shared drive is hidden from default view.
901 pub hidden: Option<bool>,
902 /// Output only. The ID of this shared drive which is also the ID of the top level folder of this shared drive.
903 pub id: Option<String>,
904 /// Output only. This is always `drive#drive`
905 pub kind: Option<String>,
906 /// The name of this shared drive.
907 pub name: Option<String>,
908 /// 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`.
909 #[serde(rename = "orgUnitId")]
910 pub org_unit_id: Option<String>,
911 /// A set of restrictions that apply to this shared drive or items inside this shared drive.
912 pub restrictions: Option<DriveRestrictions>,
913 /// 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`.
914 #[serde(rename = "themeId")]
915 pub theme_id: Option<String>,
916}
917
918impl common::RequestValue for Drive {}
919impl common::Resource for Drive {}
920impl common::ResponseResult for Drive {}
921
922/// A list of shared drives.
923///
924/// # Activities
925///
926/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
927/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
928///
929/// * [list drives](DriveListCall) (response)
930#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
931#[serde_with::serde_as]
932#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
933pub struct DriveList {
934 /// The list of shared drives. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
935 pub items: Option<Vec<Drive>>,
936 /// This is always `drive#driveList`
937 pub kind: Option<String>,
938 /// 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.
939 #[serde(rename = "nextPageToken")]
940 pub next_page_token: Option<String>,
941}
942
943impl common::ResponseResult for DriveList {}
944
945/// 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.
946///
947/// # Activities
948///
949/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
950/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
951///
952/// * [copy files](FileCopyCall) (request|response)
953/// * [delete files](FileDeleteCall) (none)
954/// * [empty trash files](FileEmptyTrashCall) (none)
955/// * [export files](FileExportCall) (none)
956/// * [generate ids files](FileGenerateIdCall) (none)
957/// * [get files](FileGetCall) (response)
958/// * [insert files](FileInsertCall) (request|response)
959/// * [list files](FileListCall) (none)
960/// * [list labels files](FileListLabelCall) (none)
961/// * [modify labels files](FileModifyLabelCall) (none)
962/// * [patch files](FilePatchCall) (request|response)
963/// * [touch files](FileTouchCall) (response)
964/// * [trash files](FileTrashCall) (response)
965/// * [untrash files](FileUntrashCall) (response)
966/// * [update files](FileUpdateCall) (request|response)
967/// * [watch files](FileWatchCall) (none)
968#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
969#[serde_with::serde_as]
970#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
971pub struct File {
972 /// Output only. A link for opening the file in a relevant Google editor or viewer.
973 #[serde(rename = "alternateLink")]
974 pub alternate_link: Option<String>,
975 /// Output only. Whether this file is in the Application Data folder.
976 #[serde(rename = "appDataContents")]
977 pub app_data_contents: Option<bool>,
978 /// Output only. Deprecated: Use `capabilities/canComment` instead.
979 #[serde(rename = "canComment")]
980 pub can_comment: Option<bool>,
981 /// Output only. Deprecated: Use `capabilities/canReadRevisions` instead.
982 #[serde(rename = "canReadRevisions")]
983 pub can_read_revisions: Option<bool>,
984 /// Output only. Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take.
985 pub capabilities: Option<FileCapabilities>,
986 /// Restrictions for accessing the content of the file. Only populated if such a restriction exists.
987 #[serde(rename = "contentRestrictions")]
988 pub content_restrictions: Option<Vec<ContentRestriction>>,
989 /// Whether the options to copy, print, or download this file, should be disabled for readers and commenters.
990 #[serde(rename = "copyRequiresWriterPermission")]
991 pub copy_requires_writer_permission: Option<bool>,
992 /// Output only. Deprecated: Use `capabilities/canCopy` instead.
993 pub copyable: Option<bool>,
994 /// Create time for this file (formatted RFC 3339 timestamp).
995 #[serde(rename = "createdDate")]
996 pub created_date: Option<chrono::DateTime<chrono::offset::Utc>>,
997 /// 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.
998 #[serde(rename = "defaultOpenWithLink")]
999 pub default_open_with_link: Option<String>,
1000 /// A short description of the file.
1001 pub description: Option<String>,
1002 /// 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.
1003 #[serde(rename = "downloadUrl")]
1004 pub download_url: Option<String>,
1005 /// Output only. ID of the shared drive the file resides in. Only populated for items in shared drives.
1006 #[serde(rename = "driveId")]
1007 pub drive_id: Option<String>,
1008 /// Output only. Deprecated: Use `capabilities/canEdit` instead.
1009 pub editable: Option<bool>,
1010 /// Output only. A link for embedding the file.
1011 #[serde(rename = "embedLink")]
1012 pub embed_link: Option<String>,
1013 /// Output only. ETag of the file.
1014 pub etag: Option<String>,
1015 /// Output only. Whether this file has been explicitly trashed, as opposed to recursively trashed.
1016 #[serde(rename = "explicitlyTrashed")]
1017 pub explicitly_trashed: Option<bool>,
1018 /// Output only. Links for exporting Docs Editors files to specific formats.
1019 #[serde(rename = "exportLinks")]
1020 pub export_links: Option<HashMap<String, String>>,
1021 /// 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.
1022 #[serde(rename = "fileExtension")]
1023 pub file_extension: Option<String>,
1024 /// 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.
1025 #[serde(rename = "fileSize")]
1026 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1027 pub file_size: Option<i64>,
1028 /// 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.
1029 #[serde(rename = "folderColorRgb")]
1030 pub folder_color_rgb: Option<String>,
1031 /// 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.
1032 #[serde(rename = "fullFileExtension")]
1033 pub full_file_extension: Option<String>,
1034 /// Output only. Whether there are permissions directly on this file. This field is only populated for items in shared drives.
1035 #[serde(rename = "hasAugmentedPermissions")]
1036 pub has_augmented_permissions: Option<bool>,
1037 /// 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.
1038 #[serde(rename = "hasThumbnail")]
1039 pub has_thumbnail: Option<bool>,
1040 /// 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.
1041 #[serde(rename = "headRevisionId")]
1042 pub head_revision_id: Option<String>,
1043 /// Output only. A link to the file's icon.
1044 #[serde(rename = "iconLink")]
1045 pub icon_link: Option<String>,
1046 /// The ID of the file.
1047 pub id: Option<String>,
1048 /// 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.
1049 #[serde(rename = "imageMediaMetadata")]
1050 pub image_media_metadata: Option<FileImageMediaMetadata>,
1051 /// Indexable text attributes for the file (can only be written)
1052 #[serde(rename = "indexableText")]
1053 pub indexable_text: Option<FileIndexableText>,
1054 /// Whether this file has inherited permissions disabled. Inherited permissions are enabled by default.
1055 #[serde(rename = "inheritedPermissionsDisabled")]
1056 pub inherited_permissions_disabled: Option<bool>,
1057 /// Output only. Whether the file was created or opened by the requesting app.
1058 #[serde(rename = "isAppAuthorized")]
1059 pub is_app_authorized: Option<bool>,
1060 /// Output only. The type of file. This is always `drive#file`.
1061 pub kind: Option<String>,
1062 /// Output only. An overview of the labels on the file.
1063 #[serde(rename = "labelInfo")]
1064 pub label_info: Option<FileLabelInfo>,
1065 /// A group of labels for the file.
1066 pub labels: Option<FileLabels>,
1067 /// Output only. The last user to modify this file. This field is only populated when the last modification was performed by a signed-in user.
1068 #[serde(rename = "lastModifyingUser")]
1069 pub last_modifying_user: Option<User>,
1070 /// Output only. Name of the last user to modify this file.
1071 #[serde(rename = "lastModifyingUserName")]
1072 pub last_modifying_user_name: Option<String>,
1073 /// Last time this file was viewed by the user (formatted RFC 3339 timestamp).
1074 #[serde(rename = "lastViewedByMeDate")]
1075 pub last_viewed_by_me_date: Option<chrono::DateTime<chrono::offset::Utc>>,
1076 /// Contains details about the link URLs that clients are using to refer to this item.
1077 #[serde(rename = "linkShareMetadata")]
1078 pub link_share_metadata: Option<FileLinkShareMetadata>,
1079 /// Deprecated.
1080 #[serde(rename = "markedViewedByMeDate")]
1081 pub marked_viewed_by_me_date: Option<chrono::DateTime<chrono::offset::Utc>>,
1082 /// 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.
1083 #[serde(rename = "md5Checksum")]
1084 pub md5_checksum: Option<String>,
1085 /// 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.
1086 #[serde(rename = "mimeType")]
1087 pub mime_type: Option<String>,
1088 /// 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.
1089 #[serde(rename = "modifiedByMeDate")]
1090 pub modified_by_me_date: Option<chrono::DateTime<chrono::offset::Utc>>,
1091 /// Last time this file was modified by anyone (formatted RFC 3339 timestamp). This is only mutable on update when the setModifiedDate parameter is set.
1092 #[serde(rename = "modifiedDate")]
1093 pub modified_date: Option<chrono::DateTime<chrono::offset::Utc>>,
1094 /// 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.
1095 #[serde(rename = "openWithLinks")]
1096 pub open_with_links: Option<HashMap<String, String>>,
1097 /// 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.
1098 #[serde(rename = "originalFilename")]
1099 pub original_filename: Option<String>,
1100 /// Output only. Whether the file is owned by the current user. Not populated for items in shared drives.
1101 #[serde(rename = "ownedByMe")]
1102 pub owned_by_me: Option<bool>,
1103 /// Output only. Name(s) of the owner(s) of this file. Not populated for items in shared drives.
1104 #[serde(rename = "ownerNames")]
1105 pub owner_names: Option<Vec<String>>,
1106 /// 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.
1107 pub owners: Option<Vec<User>>,
1108 /// The ID of the parent folder containing the file. A file can only have one parent folder; specifying multiple parents isn't supported. If not specified as part of an insert request, the file is placed directly in the user's My Drive folder. If not specified as part of a copy request, the file inherits any discoverable parent of the source file. Update requests must use the `addParents` and `removeParents` parameters to modify the parents list.
1109 pub parents: Option<Vec<ParentReference>>,
1110 /// Output only. List of permission IDs for users with access to this file.
1111 #[serde(rename = "permissionIds")]
1112 pub permission_ids: Option<Vec<String>>,
1113 /// Output only. The list of permissions for users with access to this file. Not populated for items in shared drives.
1114 pub permissions: Option<Vec<Permission>>,
1115 /// The list of properties.
1116 pub properties: Option<Vec<Property>>,
1117 /// Output only. The number of quota bytes used by this file.
1118 #[serde(rename = "quotaBytesUsed")]
1119 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1120 pub quota_bytes_used: Option<i64>,
1121 /// Output only. A key needed to access the item via a shared link.
1122 #[serde(rename = "resourceKey")]
1123 pub resource_key: Option<String>,
1124 /// Output only. A link back to this file.
1125 #[serde(rename = "selfLink")]
1126 pub self_link: Option<String>,
1127 /// 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.
1128 #[serde(rename = "sha1Checksum")]
1129 pub sha1_checksum: Option<String>,
1130 /// 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.
1131 #[serde(rename = "sha256Checksum")]
1132 pub sha256_checksum: Option<String>,
1133 /// Output only. Deprecated: Use `capabilities/canShare` instead.
1134 pub shareable: Option<bool>,
1135 /// Output only. Whether the file has been shared. Not populated for items in shared drives.
1136 pub shared: Option<bool>,
1137 /// Time at which this file was shared with the user (formatted RFC 3339 timestamp).
1138 #[serde(rename = "sharedWithMeDate")]
1139 pub shared_with_me_date: Option<chrono::DateTime<chrono::offset::Utc>>,
1140 /// Output only. User that shared the item with the current user, if available.
1141 #[serde(rename = "sharingUser")]
1142 pub sharing_user: Option<User>,
1143 /// Shortcut file details. Only populated for shortcut files, which have the mimeType field set to `application/vnd.google-apps.shortcut`. Can only be set on `files.insert` requests.
1144 #[serde(rename = "shortcutDetails")]
1145 pub shortcut_details: Option<FileShortcutDetails>,
1146 /// Output only. The list of spaces which contain the file. Supported values are `drive`, `appDataFolder` and `photos`.
1147 pub spaces: Option<Vec<String>>,
1148 /// Output only. Deprecated: Use `driveId` instead.
1149 #[serde(rename = "teamDriveId")]
1150 pub team_drive_id: Option<String>,
1151 /// A thumbnail for the file. This will only be used if a standard thumbnail cannot be generated.
1152 pub thumbnail: Option<FileThumbnail>,
1153 /// Output only. A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours. Not intended for direct usage on web applications due to [Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), consider using a proxy server. 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.
1154 #[serde(rename = "thumbnailLink")]
1155 pub thumbnail_link: Option<String>,
1156 /// Output only. The thumbnail version for use in thumbnail cache invalidation.
1157 #[serde(rename = "thumbnailVersion")]
1158 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1159 pub thumbnail_version: Option<i64>,
1160 /// 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.
1161 pub title: Option<String>,
1162 /// The time that the item was trashed (formatted RFC 3339 timestamp). Only populated for items in shared drives.
1163 #[serde(rename = "trashedDate")]
1164 pub trashed_date: Option<chrono::DateTime<chrono::offset::Utc>>,
1165 /// Output only. If the file has been explicitly trashed, the user who trashed it. Only populated for items in shared drives.
1166 #[serde(rename = "trashingUser")]
1167 pub trashing_user: Option<User>,
1168 /// Output only. The permissions for the authenticated user on this file.
1169 #[serde(rename = "userPermission")]
1170 pub user_permission: Option<Permission>,
1171 /// 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.
1172 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1173 pub version: Option<i64>,
1174 /// Output only. Metadata about video media. This will only be present for video types.
1175 #[serde(rename = "videoMediaMetadata")]
1176 pub video_media_metadata: Option<FileVideoMediaMetadata>,
1177 /// 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.
1178 #[serde(rename = "webContentLink")]
1179 pub web_content_link: Option<String>,
1180 /// 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.
1181 #[serde(rename = "webViewLink")]
1182 pub web_view_link: Option<String>,
1183 /// Whether writers can share the document with other users. Not populated for items in shared drives.
1184 #[serde(rename = "writersCanShare")]
1185 pub writers_can_share: Option<bool>,
1186}
1187
1188impl common::RequestValue for File {}
1189impl common::Resource for File {}
1190impl common::ResponseResult for File {}
1191
1192/// A list of files.
1193///
1194/// # Activities
1195///
1196/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1197/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1198///
1199/// * [list files](FileListCall) (response)
1200#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1201#[serde_with::serde_as]
1202#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1203pub struct FileList {
1204 /// The ETag of the list.
1205 pub etag: Option<String>,
1206 /// 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".
1207 #[serde(rename = "incompleteSearch")]
1208 pub incomplete_search: Option<bool>,
1209 /// The list of files. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
1210 pub items: Option<Vec<File>>,
1211 /// This is always `drive#fileList`.
1212 pub kind: Option<String>,
1213 /// A link to the next page of files.
1214 #[serde(rename = "nextLink")]
1215 pub next_link: Option<String>,
1216 /// 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.
1217 #[serde(rename = "nextPageToken")]
1218 pub next_page_token: Option<String>,
1219 /// A link back to this list.
1220 #[serde(rename = "selfLink")]
1221 pub self_link: Option<String>,
1222}
1223
1224impl common::ResponseResult for FileList {}
1225
1226/// A list of generated IDs which can be provided in insert requests
1227///
1228/// # Activities
1229///
1230/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1231/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1232///
1233/// * [generate ids files](FileGenerateIdCall) (response)
1234#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1235#[serde_with::serde_as]
1236#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1237pub struct GeneratedIds {
1238 /// The IDs generated for the requesting user in the specified space.
1239 pub ids: Option<Vec<String>>,
1240 /// This is always `drive#generatedIds`
1241 pub kind: Option<String>,
1242 /// The type of file that can be created with these IDs.
1243 pub space: Option<String>,
1244}
1245
1246impl common::ResponseResult for GeneratedIds {}
1247
1248/// Representation of a label and label fields.
1249///
1250/// This type is not used in any activity, and only used as *part* of another schema.
1251///
1252#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1253#[serde_with::serde_as]
1254#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1255pub struct Label {
1256 /// A map of the fields on the label, keyed by the field's ID.
1257 pub fields: Option<HashMap<String, LabelField>>,
1258 /// The ID of the label.
1259 pub id: Option<String>,
1260 /// This is always `drive#label`
1261 pub kind: Option<String>,
1262 /// The revision ID of the label.
1263 #[serde(rename = "revisionId")]
1264 pub revision_id: Option<String>,
1265}
1266
1267impl common::Part for Label {}
1268
1269/// Representation of field, which is a typed key-value pair.
1270///
1271/// This type is not used in any activity, and only used as *part* of another schema.
1272///
1273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1274#[serde_with::serde_as]
1275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1276pub struct LabelField {
1277 /// Only present if valueType is dateString. RFC 3339 formatted date: YYYY-MM-DD.
1278 #[serde(rename = "dateString")]
1279 pub date_string: Option<Vec<chrono::NaiveDate>>,
1280 /// The identifier of this label field.
1281 pub id: Option<String>,
1282 /// Only present if `valueType` is `integer`.
1283 #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
1284 pub integer: Option<Vec<i64>>,
1285 /// This is always `drive#labelField`.
1286 pub kind: Option<String>,
1287 /// Only present if `valueType` is `selection`
1288 pub selection: Option<Vec<String>>,
1289 /// Only present if `valueType` is `text`.
1290 pub text: Option<Vec<String>>,
1291 /// Only present if `valueType` is `user`.
1292 pub user: Option<Vec<User>>,
1293 /// The field type. While new values may be supported in the future, the following are currently allowed: * `dateString` * `integer` * `selection` * `text` * `user`
1294 #[serde(rename = "valueType")]
1295 pub value_type: Option<String>,
1296}
1297
1298impl common::Part for LabelField {}
1299
1300/// A modification to a label's field.
1301///
1302/// This type is not used in any activity, and only used as *part* of another schema.
1303///
1304#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1305#[serde_with::serde_as]
1306#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1307pub struct LabelFieldModification {
1308 /// The ID of the field to be modified.
1309 #[serde(rename = "fieldId")]
1310 pub field_id: Option<String>,
1311 /// This is always `drive#labelFieldModification`.
1312 pub kind: Option<String>,
1313 /// 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.
1314 #[serde(rename = "setDateValues")]
1315 pub set_date_values: Option<Vec<chrono::NaiveDate>>,
1316 /// Replaces the value of an `integer` field with these new values.
1317 #[serde(rename = "setIntegerValues")]
1318 #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
1319 pub set_integer_values: Option<Vec<i64>>,
1320 /// Replaces a `selection` field with these new values.
1321 #[serde(rename = "setSelectionValues")]
1322 pub set_selection_values: Option<Vec<String>>,
1323 /// Sets the value of a `text` field.
1324 #[serde(rename = "setTextValues")]
1325 pub set_text_values: Option<Vec<String>>,
1326 /// Replaces a `user` field with these new values. The values must be valid email addresses.
1327 #[serde(rename = "setUserValues")]
1328 pub set_user_values: Option<Vec<String>>,
1329 /// Unsets the values for this field.
1330 #[serde(rename = "unsetValues")]
1331 pub unset_values: Option<bool>,
1332}
1333
1334impl common::Part for LabelFieldModification {}
1335
1336/// A list of labels applied to a file.
1337///
1338/// # Activities
1339///
1340/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1341/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1342///
1343/// * [list labels files](FileListLabelCall) (response)
1344#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1345#[serde_with::serde_as]
1346#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1347pub struct LabelList {
1348 /// The list of labels.
1349 pub items: Option<Vec<Label>>,
1350 /// This is always `drive#labelList`
1351 pub kind: Option<String>,
1352 /// 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.
1353 #[serde(rename = "nextPageToken")]
1354 pub next_page_token: Option<String>,
1355}
1356
1357impl common::ResponseResult for LabelList {}
1358
1359/// 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.
1360///
1361/// This type is not used in any activity, and only used as *part* of another schema.
1362///
1363#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1364#[serde_with::serde_as]
1365#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1366pub struct LabelModification {
1367 /// The list of modifications to this label's fields.
1368 #[serde(rename = "fieldModifications")]
1369 pub field_modifications: Option<Vec<LabelFieldModification>>,
1370 /// This is always `drive#labelModification`.
1371 pub kind: Option<String>,
1372 /// The ID of the label to modify.
1373 #[serde(rename = "labelId")]
1374 pub label_id: Option<String>,
1375 /// If true, the label will be removed from the file.
1376 #[serde(rename = "removeLabel")]
1377 pub remove_label: Option<bool>,
1378}
1379
1380impl common::Part for LabelModification {}
1381
1382/// 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.
1383///
1384/// # Activities
1385///
1386/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1387/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1388///
1389/// * [modify labels files](FileModifyLabelCall) (request)
1390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1391#[serde_with::serde_as]
1392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1393pub struct ModifyLabelsRequest {
1394 /// This is always `drive#modifyLabelsRequest`.
1395 pub kind: Option<String>,
1396 /// The list of modifications to apply to the labels on the file.
1397 #[serde(rename = "labelModifications")]
1398 pub label_modifications: Option<Vec<LabelModification>>,
1399}
1400
1401impl common::RequestValue for ModifyLabelsRequest {}
1402
1403/// Response to a ModifyLabels request. This contains only those labels which were added or updated by the request.
1404///
1405/// # Activities
1406///
1407/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1408/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1409///
1410/// * [modify labels files](FileModifyLabelCall) (response)
1411#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1412#[serde_with::serde_as]
1413#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1414pub struct ModifyLabelsResponse {
1415 /// This is always `drive#modifyLabelsResponse`
1416 pub kind: Option<String>,
1417 /// The list of labels which were added or updated by the request.
1418 #[serde(rename = "modifiedLabels")]
1419 pub modified_labels: Option<Vec<Label>>,
1420}
1421
1422impl common::ResponseResult for ModifyLabelsResponse {}
1423
1424/// A list of a file’s parents.
1425///
1426/// # Activities
1427///
1428/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1429/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1430///
1431/// * [list parents](ParentListCall) (response)
1432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1433#[serde_with::serde_as]
1434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1435pub struct ParentList {
1436 /// The ETag of the list.
1437 pub etag: Option<String>,
1438 /// The list of parents.
1439 pub items: Option<Vec<ParentReference>>,
1440 /// This is always `drive#parentList`.
1441 pub kind: Option<String>,
1442 /// A link back to this list.
1443 #[serde(rename = "selfLink")]
1444 pub self_link: Option<String>,
1445}
1446
1447impl common::ResponseResult for ParentList {}
1448
1449/// A reference to a file’s parent. A file can only have one parent folder; specifying multiple parents isn’t supported. Some resource methods (such as `parents.get`) require a `parentId`. Use the `parents.list` method to retrieve the ID for a parent.
1450///
1451/// # Activities
1452///
1453/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1454/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1455///
1456/// * [get parents](ParentGetCall) (response)
1457/// * [insert parents](ParentInsertCall) (request|response)
1458#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1459#[serde_with::serde_as]
1460#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1461pub struct ParentReference {
1462 /// The ID of the parent.
1463 pub id: Option<String>,
1464 /// Output only. Whether or not the parent is the root folder.
1465 #[serde(rename = "isRoot")]
1466 pub is_root: Option<bool>,
1467 /// Output only. This is always `drive#parentReference`.
1468 pub kind: Option<String>,
1469 /// Output only. A link to the parent.
1470 #[serde(rename = "parentLink")]
1471 pub parent_link: Option<String>,
1472 /// Output only. A link back to this reference.
1473 #[serde(rename = "selfLink")]
1474 pub self_link: Option<String>,
1475}
1476
1477impl common::RequestValue for ParentReference {}
1478impl common::ResponseResult for ParentReference {}
1479
1480/// 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.
1481///
1482/// # Activities
1483///
1484/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1485/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1486///
1487/// * [delete permissions](PermissionDeleteCall) (none)
1488/// * [get permissions](PermissionGetCall) (response)
1489/// * [get id for email permissions](PermissionGetIdForEmailCall) (none)
1490/// * [insert permissions](PermissionInsertCall) (request|response)
1491/// * [list permissions](PermissionListCall) (none)
1492/// * [patch permissions](PermissionPatchCall) (request|response)
1493/// * [update permissions](PermissionUpdateCall) (request|response)
1494#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1495#[serde_with::serde_as]
1496#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1497pub struct Permission {
1498 /// Additional roles for this user. Only `commenter` is currently allowed, though more may be supported in the future.
1499 #[serde(rename = "additionalRoles")]
1500 pub additional_roles: Option<Vec<String>>,
1501 /// Output only. Deprecated.
1502 #[serde(rename = "authKey")]
1503 pub auth_key: Option<String>,
1504 /// Output only. Whether the account associated with this permission has been deleted. This field only pertains to user and group permissions.
1505 pub deleted: Option<bool>,
1506 /// 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`.
1507 pub domain: Option<String>,
1508 /// 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`.
1509 #[serde(rename = "emailAddress")]
1510 pub email_address: Option<String>,
1511 /// Output only. The ETag of the permission.
1512 pub etag: Option<String>,
1513 /// 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
1514 #[serde(rename = "expirationDate")]
1515 pub expiration_date: Option<chrono::DateTime<chrono::offset::Utc>>,
1516 /// 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.
1517 pub id: Option<String>,
1518 /// When true, only organizers, owners, and users with permissions added directly on the item can access it.
1519 #[serde(rename = "inheritedPermissionsDisabled")]
1520 pub inherited_permissions_disabled: Option<bool>,
1521 /// Output only. This is always `drive#permission`.
1522 pub kind: Option<String>,
1523 /// Output only. The name for this permission.
1524 pub name: Option<String>,
1525 /// 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.
1526 #[serde(rename = "pendingOwner")]
1527 pub pending_owner: Option<bool>,
1528 /// Output only. Details of whether the permissions on this item are inherited or directly on this item.
1529 #[serde(rename = "permissionDetails")]
1530 pub permission_details: Option<Vec<PermissionPermissionDetails>>,
1531 /// Output only. A link to the profile photo, if available.
1532 #[serde(rename = "photoLink")]
1533 pub photo_link: Option<String>,
1534 /// 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`
1535 pub role: Option<String>,
1536 /// Output only. A link back to this permission.
1537 #[serde(rename = "selfLink")]
1538 pub self_link: Option<String>,
1539 /// Output only. Deprecated: Use `permissionDetails` instead.
1540 #[serde(rename = "teamDrivePermissionDetails")]
1541 pub team_drive_permission_details: Option<Vec<PermissionTeamDrivePermissionDetails>>,
1542 /// The account type. Allowed values are: * `user` * `group` * `domain` * `anyone`
1543 #[serde(rename = "type")]
1544 pub type_: Option<String>,
1545 /// 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.
1546 pub value: Option<String>,
1547 /// Indicates the view for this permission. Only populated for permissions that belong to a view. published and metadata are the only supported values. - published: The permission's role is published_reader. - metadata: The item is only visible to the metadata view because the item has limited access and the scope has at least read access to the parent. Note: The metadata view is currently only supported on folders.
1548 pub view: Option<String>,
1549 /// Whether the link is required for this permission.
1550 #[serde(rename = "withLink")]
1551 pub with_link: Option<bool>,
1552}
1553
1554impl common::RequestValue for Permission {}
1555impl common::Resource for Permission {}
1556impl common::ResponseResult for Permission {}
1557
1558/// An ID for a user or group as seen in Permission items.
1559///
1560/// # Activities
1561///
1562/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1563/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1564///
1565/// * [get id for email permissions](PermissionGetIdForEmailCall) (response)
1566#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1567#[serde_with::serde_as]
1568#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1569pub struct PermissionId {
1570 /// The permission ID.
1571 pub id: Option<String>,
1572 /// This is always `drive#permissionId`.
1573 pub kind: Option<String>,
1574}
1575
1576impl common::ResponseResult for PermissionId {}
1577
1578/// A list of permissions associated with a file.
1579///
1580/// # Activities
1581///
1582/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1583/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1584///
1585/// * [list permissions](PermissionListCall) (response)
1586#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1587#[serde_with::serde_as]
1588#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1589pub struct PermissionList {
1590 /// The ETag of the list.
1591 pub etag: Option<String>,
1592 /// The list of permissions.
1593 pub items: Option<Vec<Permission>>,
1594 /// This is always `drive#permissionList`.
1595 pub kind: Option<String>,
1596 /// 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.
1597 #[serde(rename = "nextPageToken")]
1598 pub next_page_token: Option<String>,
1599 /// A link back to this list.
1600 #[serde(rename = "selfLink")]
1601 pub self_link: Option<String>,
1602}
1603
1604impl common::ResponseResult for PermissionList {}
1605
1606/// 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.
1607///
1608/// # Activities
1609///
1610/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1611/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1612///
1613/// * [get properties](PropertyGetCall) (response)
1614/// * [insert properties](PropertyInsertCall) (request|response)
1615/// * [patch properties](PropertyPatchCall) (request|response)
1616/// * [update properties](PropertyUpdateCall) (request|response)
1617#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1618#[serde_with::serde_as]
1619#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1620pub struct Property {
1621 /// Output only. ETag of the property.
1622 pub etag: Option<String>,
1623 /// The key of this property.
1624 pub key: Option<String>,
1625 /// Output only. This is always `drive#property`.
1626 pub kind: Option<String>,
1627 /// Output only. The link back to this property.
1628 #[serde(rename = "selfLink")]
1629 pub self_link: Option<String>,
1630 /// The value of this property.
1631 pub value: Option<String>,
1632 /// 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.
1633 pub visibility: Option<String>,
1634}
1635
1636impl common::RequestValue for Property {}
1637impl common::ResponseResult for Property {}
1638
1639/// A collection of properties, key-value pairs that are either public or private to an application.
1640///
1641/// # Activities
1642///
1643/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1644/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1645///
1646/// * [list properties](PropertyListCall) (response)
1647#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1648#[serde_with::serde_as]
1649#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1650pub struct PropertyList {
1651 /// The ETag of the list.
1652 pub etag: Option<String>,
1653 /// The list of properties.
1654 pub items: Option<Vec<Property>>,
1655 /// This is always `drive#propertyList`.
1656 pub kind: Option<String>,
1657 /// The link back to this list.
1658 #[serde(rename = "selfLink")]
1659 pub self_link: Option<String>,
1660}
1661
1662impl common::ResponseResult for PropertyList {}
1663
1664/// 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.
1665///
1666/// # Activities
1667///
1668/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1669/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1670///
1671/// * [delete revisions](RevisionDeleteCall) (none)
1672/// * [get revisions](RevisionGetCall) (response)
1673/// * [list revisions](RevisionListCall) (none)
1674/// * [patch revisions](RevisionPatchCall) (request|response)
1675/// * [update revisions](RevisionUpdateCall) (request|response)
1676#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1677#[serde_with::serde_as]
1678#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1679pub struct Revision {
1680 /// Output only. Short term download URL for the file. This will only be populated on files with content stored in Drive.
1681 #[serde(rename = "downloadUrl")]
1682 pub download_url: Option<String>,
1683 /// Output only. The ETag of the revision.
1684 pub etag: Option<String>,
1685 /// Output only. Links for exporting Docs Editors files to specific formats.
1686 #[serde(rename = "exportLinks")]
1687 pub export_links: Option<HashMap<String, String>>,
1688 /// Output only. The size of the revision in bytes. This will only be populated on files with content stored in Drive.
1689 #[serde(rename = "fileSize")]
1690 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1691 pub file_size: Option<i64>,
1692 /// Output only. The ID of the revision.
1693 pub id: Option<String>,
1694 /// Output only. This is always `drive#revision`.
1695 pub kind: Option<String>,
1696 /// Output only. The last user to modify this revision. This field is only populated when the last modification was performed by a signed-in user.
1697 #[serde(rename = "lastModifyingUser")]
1698 pub last_modifying_user: Option<User>,
1699 /// Output only. Name of the last user to modify this revision.
1700 #[serde(rename = "lastModifyingUserName")]
1701 pub last_modifying_user_name: Option<String>,
1702 /// Output only. An MD5 checksum for the content of this revision. This will only be populated on files with content stored in Drive.
1703 #[serde(rename = "md5Checksum")]
1704 pub md5_checksum: Option<String>,
1705 /// Output only. The MIME type of the revision.
1706 #[serde(rename = "mimeType")]
1707 pub mime_type: Option<String>,
1708 /// Last time this revision was modified (formatted RFC 3339 timestamp).
1709 #[serde(rename = "modifiedDate")]
1710 pub modified_date: Option<chrono::DateTime<chrono::offset::Utc>>,
1711 /// Output only. The original filename when this revision was created. This will only be populated on files with content stored in Drive.
1712 #[serde(rename = "originalFilename")]
1713 pub original_filename: Option<String>,
1714 /// 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.
1715 pub pinned: Option<bool>,
1716 /// Whether subsequent revisions will be automatically republished. This is only populated and can only be modified for Docs Editors files.
1717 #[serde(rename = "publishAuto")]
1718 pub publish_auto: Option<bool>,
1719 /// Whether this revision is published. This is only populated and can only be modified for Docs Editors files.
1720 pub published: Option<bool>,
1721 /// Output only. A link to the published revision. This is only populated for Docs Editors files.
1722 #[serde(rename = "publishedLink")]
1723 pub published_link: Option<String>,
1724 /// Whether this revision is published outside the domain. This is only populated and can only be modified for Docs Editors files.
1725 #[serde(rename = "publishedOutsideDomain")]
1726 pub published_outside_domain: Option<bool>,
1727 /// Output only. A link back to this revision.
1728 #[serde(rename = "selfLink")]
1729 pub self_link: Option<String>,
1730}
1731
1732impl common::RequestValue for Revision {}
1733impl common::Resource for Revision {}
1734impl common::ResponseResult for Revision {}
1735
1736/// A list of revisions of a file.
1737///
1738/// # Activities
1739///
1740/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1741/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1742///
1743/// * [list revisions](RevisionListCall) (response)
1744#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1745#[serde_with::serde_as]
1746#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1747pub struct RevisionList {
1748 /// The ETag of the list.
1749 pub etag: Option<String>,
1750 /// The list of revisions. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
1751 pub items: Option<Vec<Revision>>,
1752 /// This is always `drive#revisionList`.
1753 pub kind: Option<String>,
1754 /// 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.
1755 #[serde(rename = "nextPageToken")]
1756 pub next_page_token: Option<String>,
1757 /// A link back to this list.
1758 #[serde(rename = "selfLink")]
1759 pub self_link: Option<String>,
1760}
1761
1762impl common::ResponseResult for RevisionList {}
1763
1764/// There is no detailed description.
1765///
1766/// # Activities
1767///
1768/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1769/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1770///
1771/// * [get start page token changes](ChangeGetStartPageTokenCall) (response)
1772#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1773#[serde_with::serde_as]
1774#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1775pub struct StartPageToken {
1776 /// Identifies what kind of resource this is. Value: the fixed string `"drive#startPageToken"`.
1777 pub kind: Option<String>,
1778 /// The starting page token for listing changes.
1779 #[serde(rename = "startPageToken")]
1780 pub start_page_token: Option<String>,
1781}
1782
1783impl common::ResponseResult for StartPageToken {}
1784
1785/// Deprecated: Use the `drive` collection instead.
1786///
1787/// # Activities
1788///
1789/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1790/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1791///
1792/// * [get teamdrives](TeamdriveGetCall) (response)
1793/// * [insert teamdrives](TeamdriveInsertCall) (request|response)
1794/// * [update teamdrives](TeamdriveUpdateCall) (request|response)
1795#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1796#[serde_with::serde_as]
1797#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1798pub struct TeamDrive {
1799 /// 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.
1800 #[serde(rename = "backgroundImageFile")]
1801 pub background_image_file: Option<TeamDriveBackgroundImageFile>,
1802 /// A short-lived link to this Team Drive's background image.
1803 #[serde(rename = "backgroundImageLink")]
1804 pub background_image_link: Option<String>,
1805 /// Capabilities the current user has on this Team Drive.
1806 pub capabilities: Option<TeamDriveCapabilities>,
1807 /// 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`.
1808 #[serde(rename = "colorRgb")]
1809 pub color_rgb: Option<String>,
1810 /// The time at which the Team Drive was created (RFC 3339 date-time).
1811 #[serde(rename = "createdDate")]
1812 pub created_date: Option<chrono::DateTime<chrono::offset::Utc>>,
1813 /// The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
1814 pub id: Option<String>,
1815 /// This is always `drive#teamDrive`
1816 pub kind: Option<String>,
1817 /// The name of this Team Drive.
1818 pub name: Option<String>,
1819 /// The organizational unit of this shared drive. This field is only populated on `drives.list` responses when the `useDomainAdminAccess` parameter is set to `true`.
1820 #[serde(rename = "orgUnitId")]
1821 pub org_unit_id: Option<String>,
1822 /// A set of restrictions that apply to this Team Drive or items inside this Team Drive.
1823 pub restrictions: Option<TeamDriveRestrictions>,
1824 /// 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`.
1825 #[serde(rename = "themeId")]
1826 pub theme_id: Option<String>,
1827}
1828
1829impl common::RequestValue for TeamDrive {}
1830impl common::Resource for TeamDrive {}
1831impl common::ResponseResult for TeamDrive {}
1832
1833/// A list of Team Drives.
1834///
1835/// # Activities
1836///
1837/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1838/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1839///
1840/// * [list teamdrives](TeamdriveListCall) (response)
1841#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1842#[serde_with::serde_as]
1843#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1844pub struct TeamDriveList {
1845 /// The list of Team Drives.
1846 pub items: Option<Vec<TeamDrive>>,
1847 /// This is always `drive#teamDriveList`
1848 pub kind: Option<String>,
1849 /// The page token for the next page of Team Drives.
1850 #[serde(rename = "nextPageToken")]
1851 pub next_page_token: Option<String>,
1852}
1853
1854impl common::ResponseResult for TeamDriveList {}
1855
1856/// Information about a Drive user.
1857///
1858/// This type is not used in any activity, and only used as *part* of another schema.
1859///
1860#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1861#[serde_with::serde_as]
1862#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1863pub struct User {
1864 /// Output only. A plain text displayable name for this user.
1865 #[serde(rename = "displayName")]
1866 pub display_name: Option<String>,
1867 /// Output only. The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.
1868 #[serde(rename = "emailAddress")]
1869 pub email_address: Option<String>,
1870 /// Output only. Whether this user is the same as the authenticated user for whom the request was made.
1871 #[serde(rename = "isAuthenticatedUser")]
1872 pub is_authenticated_user: Option<bool>,
1873 /// Output only. Identifies what kind of resource this is. Value: the fixed string `drive#user`.
1874 pub kind: Option<String>,
1875 /// Output only. The user's ID as visible in Permission resources.
1876 #[serde(rename = "permissionId")]
1877 pub permission_id: Option<String>,
1878 /// Output only. The user's profile picture.
1879 pub picture: Option<UserPicture>,
1880}
1881
1882impl common::Part for User {}
1883
1884/// Information about supported additional roles per file type. The most specific type takes precedence.
1885///
1886/// This type is not used in any activity, and only used as *part* of another schema.
1887///
1888#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1889#[serde_with::serde_as]
1890#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1891pub struct AboutAdditionalRoleInfo {
1892 /// The supported additional roles per primary role.
1893 #[serde(rename = "roleSets")]
1894 pub role_sets: Option<Vec<AboutAdditionalRoleInfoRoleSets>>,
1895 /// The content type that this additional role info applies to.
1896 #[serde(rename = "type")]
1897 pub type_: Option<String>,
1898}
1899
1900impl common::NestedType for AboutAdditionalRoleInfo {}
1901impl common::Part for AboutAdditionalRoleInfo {}
1902
1903/// The supported additional roles per primary role.
1904///
1905/// This type is not used in any activity, and only used as *part* of another schema.
1906///
1907#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1908#[serde_with::serde_as]
1909#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1910pub struct AboutAdditionalRoleInfoRoleSets {
1911 /// The supported additional roles with the primary role.
1912 #[serde(rename = "additionalRoles")]
1913 pub additional_roles: Option<Vec<String>>,
1914 /// A primary permission role.
1915 #[serde(rename = "primaryRole")]
1916 pub primary_role: Option<String>,
1917}
1918
1919impl common::NestedType for AboutAdditionalRoleInfoRoleSets {}
1920impl common::Part for AboutAdditionalRoleInfoRoleSets {}
1921
1922/// A list of themes that are supported for shared drives.
1923///
1924/// This type is not used in any activity, and only used as *part* of another schema.
1925///
1926#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1927#[serde_with::serde_as]
1928#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1929pub struct AboutDriveThemes {
1930 /// A link to this theme's background image.
1931 #[serde(rename = "backgroundImageLink")]
1932 pub background_image_link: Option<String>,
1933 /// The color of this theme as an RGB hex string.
1934 #[serde(rename = "colorRgb")]
1935 pub color_rgb: Option<String>,
1936 /// The ID of the theme.
1937 pub id: Option<String>,
1938}
1939
1940impl common::NestedType for AboutDriveThemes {}
1941impl common::Part for AboutDriveThemes {}
1942
1943/// The allowable export formats.
1944///
1945/// This type is not used in any activity, and only used as *part* of another schema.
1946///
1947#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1948#[serde_with::serde_as]
1949#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1950pub struct AboutExportFormats {
1951 /// The content type to convert from.
1952 pub source: Option<String>,
1953 /// The possible content types to convert to.
1954 pub targets: Option<Vec<String>>,
1955}
1956
1957impl common::NestedType for AboutExportFormats {}
1958impl common::Part for AboutExportFormats {}
1959
1960/// List of additional features enabled on this account.
1961///
1962/// This type is not used in any activity, and only used as *part* of another schema.
1963///
1964#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1965#[serde_with::serde_as]
1966#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1967pub struct AboutFeatures {
1968 /// The name of the feature.
1969 #[serde(rename = "featureName")]
1970 pub feature_name: Option<String>,
1971 /// The request limit rate for this feature, in queries per second.
1972 #[serde(rename = "featureRate")]
1973 pub feature_rate: Option<f64>,
1974}
1975
1976impl common::NestedType for AboutFeatures {}
1977impl common::Part for AboutFeatures {}
1978
1979/// The allowable import formats.
1980///
1981/// This type is not used in any activity, and only used as *part* of another schema.
1982///
1983#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1984#[serde_with::serde_as]
1985#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1986pub struct AboutImportFormats {
1987 /// The imported file's content type to convert from.
1988 pub source: Option<String>,
1989 /// The possible content types to convert to.
1990 pub targets: Option<Vec<String>>,
1991}
1992
1993impl common::NestedType for AboutImportFormats {}
1994impl common::Part for AboutImportFormats {}
1995
1996/// List of max upload sizes for each file type. The most specific type takes precedence.
1997///
1998/// This type is not used in any activity, and only used as *part* of another schema.
1999///
2000#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2001#[serde_with::serde_as]
2002#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2003pub struct AboutMaxUploadSizes {
2004 /// The max upload size for this type.
2005 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2006 pub size: Option<i64>,
2007 /// The file type.
2008 #[serde(rename = "type")]
2009 pub type_: Option<String>,
2010}
2011
2012impl common::NestedType for AboutMaxUploadSizes {}
2013impl common::Part for AboutMaxUploadSizes {}
2014
2015/// The amount of storage quota used by different Google services.
2016///
2017/// This type is not used in any activity, and only used as *part* of another schema.
2018///
2019#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2020#[serde_with::serde_as]
2021#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2022pub struct AboutQuotaBytesByService {
2023 /// The storage quota bytes used by the service.
2024 #[serde(rename = "bytesUsed")]
2025 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2026 pub bytes_used: Option<i64>,
2027 /// The service's name, e.g. DRIVE, GMAIL, or PHOTOS.
2028 #[serde(rename = "serviceName")]
2029 pub service_name: Option<String>,
2030}
2031
2032impl common::NestedType for AboutQuotaBytesByService {}
2033impl common::Part for AboutQuotaBytesByService {}
2034
2035/// Deprecated: Use `driveThemes` instead.
2036///
2037/// This type is not used in any activity, and only used as *part* of another schema.
2038///
2039#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2040#[serde_with::serde_as]
2041#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2042pub struct AboutTeamDriveThemes {
2043 /// Deprecated: Use `driveThemes/backgroundImageLink` instead.
2044 #[serde(rename = "backgroundImageLink")]
2045 pub background_image_link: Option<String>,
2046 /// Deprecated: Use `driveThemes/colorRgb` instead.
2047 #[serde(rename = "colorRgb")]
2048 pub color_rgb: Option<String>,
2049 /// Deprecated: Use `driveThemes/id` instead.
2050 pub id: Option<String>,
2051}
2052
2053impl common::NestedType for AboutTeamDriveThemes {}
2054impl common::Part for AboutTeamDriveThemes {}
2055
2056/// The various icons for the app.
2057///
2058/// This type is not used in any activity, and only used as *part* of another schema.
2059///
2060#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2061#[serde_with::serde_as]
2062#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2063pub struct AppIcons {
2064 /// 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
2065 pub category: Option<String>,
2066 /// URL for the icon.
2067 #[serde(rename = "iconUrl")]
2068 pub icon_url: Option<String>,
2069 /// Size of the icon. Represented as the maximum of the width and height.
2070 pub size: Option<i32>,
2071}
2072
2073impl common::NestedType for AppIcons {}
2074impl common::Part for AppIcons {}
2075
2076/// Context of a file which is being commented on.
2077///
2078/// This type is not used in any activity, and only used as *part* of another schema.
2079///
2080#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2081#[serde_with::serde_as]
2082#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2083pub struct CommentContext {
2084 /// The MIME type of the context snippet.
2085 #[serde(rename = "type")]
2086 pub type_: Option<String>,
2087 /// 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.
2088 pub value: Option<String>,
2089}
2090
2091impl common::NestedType for CommentContext {}
2092impl common::Part for CommentContext {}
2093
2094/// 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.
2095///
2096/// This type is not used in any activity, and only used as *part* of another schema.
2097///
2098#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2099#[serde_with::serde_as]
2100#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2101pub struct DriveBackgroundImageFile {
2102 /// The ID of an image file in Google Drive to use for the background image.
2103 pub id: Option<String>,
2104 /// 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.
2105 pub width: Option<f32>,
2106 /// 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.
2107 #[serde(rename = "xCoordinate")]
2108 pub x_coordinate: Option<f32>,
2109 /// 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.
2110 #[serde(rename = "yCoordinate")]
2111 pub y_coordinate: Option<f32>,
2112}
2113
2114impl common::NestedType for DriveBackgroundImageFile {}
2115impl common::Part for DriveBackgroundImageFile {}
2116
2117/// Output only. Capabilities the current user has on this shared drive.
2118///
2119/// This type is not used in any activity, and only used as *part* of another schema.
2120///
2121#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2122#[serde_with::serde_as]
2123#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2124pub struct DriveCapabilities {
2125 /// Output only. Whether the current user can add children to folders in this shared drive.
2126 #[serde(rename = "canAddChildren")]
2127 pub can_add_children: Option<bool>,
2128 /// Output only. Whether the current user can change the `copyRequiresWriterPermission` restriction of this shared drive.
2129 #[serde(rename = "canChangeCopyRequiresWriterPermissionRestriction")]
2130 pub can_change_copy_requires_writer_permission_restriction: Option<bool>,
2131 /// Output only. Whether the current user can change the `domainUsersOnly` restriction of this shared drive.
2132 #[serde(rename = "canChangeDomainUsersOnlyRestriction")]
2133 pub can_change_domain_users_only_restriction: Option<bool>,
2134 /// Output only. Whether the current user can change the background of this shared drive.
2135 #[serde(rename = "canChangeDriveBackground")]
2136 pub can_change_drive_background: Option<bool>,
2137 /// Output only. Whether the current user can change the `driveMembersOnly` restriction of this shared drive.
2138 #[serde(rename = "canChangeDriveMembersOnlyRestriction")]
2139 pub can_change_drive_members_only_restriction: Option<bool>,
2140 /// Output only. Whether the current user can change the `sharingFoldersRequiresOrganizerPermission` restriction of this shared drive.
2141 #[serde(rename = "canChangeSharingFoldersRequiresOrganizerPermissionRestriction")]
2142 pub can_change_sharing_folders_requires_organizer_permission_restriction: Option<bool>,
2143 /// Output only. Whether the current user can comment on files in this shared drive.
2144 #[serde(rename = "canComment")]
2145 pub can_comment: Option<bool>,
2146 /// Output only. Whether the current user can copy files in this shared drive.
2147 #[serde(rename = "canCopy")]
2148 pub can_copy: Option<bool>,
2149 /// Output only. Whether the current user can delete children from folders in this shared drive.
2150 #[serde(rename = "canDeleteChildren")]
2151 pub can_delete_children: Option<bool>,
2152 /// 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.
2153 #[serde(rename = "canDeleteDrive")]
2154 pub can_delete_drive: Option<bool>,
2155 /// Output only. Whether the current user can download files in this shared drive.
2156 #[serde(rename = "canDownload")]
2157 pub can_download: Option<bool>,
2158 /// Output only. Whether the current user can edit files in this shared drive
2159 #[serde(rename = "canEdit")]
2160 pub can_edit: Option<bool>,
2161 /// Output only. Whether the current user can list the children of folders in this shared drive.
2162 #[serde(rename = "canListChildren")]
2163 pub can_list_children: Option<bool>,
2164 /// Output only. Whether the current user can add members to this shared drive or remove them or change their role.
2165 #[serde(rename = "canManageMembers")]
2166 pub can_manage_members: Option<bool>,
2167 /// Output only. Whether the current user can read the revisions resource of files in this shared drive.
2168 #[serde(rename = "canReadRevisions")]
2169 pub can_read_revisions: Option<bool>,
2170 /// Output only. Whether the current user can rename files or folders in this shared drive.
2171 #[serde(rename = "canRename")]
2172 pub can_rename: Option<bool>,
2173 /// Output only. Whether the current user can rename this shared drive.
2174 #[serde(rename = "canRenameDrive")]
2175 pub can_rename_drive: Option<bool>,
2176 /// Output only. Whether the current user can reset the shared drive restrictions to defaults.
2177 #[serde(rename = "canResetDriveRestrictions")]
2178 pub can_reset_drive_restrictions: Option<bool>,
2179 /// Output only. Whether the current user can share files or folders in this shared drive.
2180 #[serde(rename = "canShare")]
2181 pub can_share: Option<bool>,
2182 /// Output only. Whether the current user can trash children from folders in this shared drive.
2183 #[serde(rename = "canTrashChildren")]
2184 pub can_trash_children: Option<bool>,
2185}
2186
2187impl common::NestedType for DriveCapabilities {}
2188impl common::Part for DriveCapabilities {}
2189
2190/// A set of restrictions that apply to this shared drive or items inside this shared drive.
2191///
2192/// This type is not used in any activity, and only used as *part* of another schema.
2193///
2194#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2195#[serde_with::serde_as]
2196#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2197pub struct DriveRestrictions {
2198 /// Whether administrative privileges on this shared drive are required to modify restrictions.
2199 #[serde(rename = "adminManagedRestrictions")]
2200 pub admin_managed_restrictions: Option<bool>,
2201 /// 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.
2202 #[serde(rename = "copyRequiresWriterPermission")]
2203 pub copy_requires_writer_permission: Option<bool>,
2204 /// 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.
2205 #[serde(rename = "domainUsersOnly")]
2206 pub domain_users_only: Option<bool>,
2207 /// Whether access to items inside this shared drive is restricted to its members.
2208 #[serde(rename = "driveMembersOnly")]
2209 pub drive_members_only: Option<bool>,
2210 /// 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.
2211 #[serde(rename = "sharingFoldersRequiresOrganizerPermission")]
2212 pub sharing_folders_requires_organizer_permission: Option<bool>,
2213}
2214
2215impl common::NestedType for DriveRestrictions {}
2216impl common::Part for DriveRestrictions {}
2217
2218/// Output only. Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take.
2219///
2220/// This type is not used in any activity, and only used as *part* of another schema.
2221///
2222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2223#[serde_with::serde_as]
2224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2225pub struct FileCapabilities {
2226 /// Output only. Whether the current user is the pending owner of the file. Not populated for shared drive files.
2227 #[serde(rename = "canAcceptOwnership")]
2228 pub can_accept_ownership: Option<bool>,
2229 /// Output only. Whether the current user can add children to this folder. This is always false when the item is not a folder.
2230 #[serde(rename = "canAddChildren")]
2231 pub can_add_children: Option<bool>,
2232 /// 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.
2233 #[serde(rename = "canAddFolderFromAnotherDrive")]
2234 pub can_add_folder_from_another_drive: Option<bool>,
2235 /// 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.
2236 #[serde(rename = "canAddMyDriveParent")]
2237 pub can_add_my_drive_parent: Option<bool>,
2238 /// Output only. Whether the current user can change the `copyRequiresWriterPermission` restriction of this file.
2239 #[serde(rename = "canChangeCopyRequiresWriterPermission")]
2240 pub can_change_copy_requires_writer_permission: Option<bool>,
2241 /// Output only. Deprecated.
2242 #[serde(rename = "canChangeRestrictedDownload")]
2243 pub can_change_restricted_download: Option<bool>,
2244 /// Output only. Whether the current user can change the securityUpdateEnabled field on link share metadata.
2245 #[serde(rename = "canChangeSecurityUpdateEnabled")]
2246 pub can_change_security_update_enabled: Option<bool>,
2247 /// Output only. Whether the current user can comment on this file.
2248 #[serde(rename = "canComment")]
2249 pub can_comment: Option<bool>,
2250 /// 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.
2251 #[serde(rename = "canCopy")]
2252 pub can_copy: Option<bool>,
2253 /// Output only. Whether the current user can delete this file.
2254 #[serde(rename = "canDelete")]
2255 pub can_delete: Option<bool>,
2256 /// 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.
2257 #[serde(rename = "canDeleteChildren")]
2258 pub can_delete_children: Option<bool>,
2259 /// Output only. Whether a user can disable inherited permissions.
2260 #[serde(rename = "canDisableInheritedPermissions")]
2261 pub can_disable_inherited_permissions: Option<bool>,
2262 /// Output only. Whether the current user can download this file.
2263 #[serde(rename = "canDownload")]
2264 pub can_download: Option<bool>,
2265 /// 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`.
2266 #[serde(rename = "canEdit")]
2267 pub can_edit: Option<bool>,
2268 /// Output only. Whether a user can re-enable inherited permissions.
2269 #[serde(rename = "canEnableInheritedPermissions")]
2270 pub can_enable_inherited_permissions: Option<bool>,
2271 /// Output only. Whether the current user can list the children of this folder. This is always false when the item is not a folder.
2272 #[serde(rename = "canListChildren")]
2273 pub can_list_children: Option<bool>,
2274 /// Output only. Whether the current user can modify the content of this file.
2275 #[serde(rename = "canModifyContent")]
2276 pub can_modify_content: Option<bool>,
2277 /// Deprecated: Output only. Use one of `canModifyEditorContentRestriction`, `canModifyOwnerContentRestriction` or `canRemoveContentRestriction`.
2278 #[serde(rename = "canModifyContentRestriction")]
2279 pub can_modify_content_restriction: Option<bool>,
2280 /// Output only. Whether the current user can add or modify content restrictions on the file which are editor restricted.
2281 #[serde(rename = "canModifyEditorContentRestriction")]
2282 pub can_modify_editor_content_restriction: Option<bool>,
2283 /// Output only. Whether the current user can modify the labels on the file.
2284 #[serde(rename = "canModifyLabels")]
2285 pub can_modify_labels: Option<bool>,
2286 /// Output only. Whether the current user can add or modify content restrictions which are owner restricted.
2287 #[serde(rename = "canModifyOwnerContentRestriction")]
2288 pub can_modify_owner_content_restriction: Option<bool>,
2289 /// 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.
2290 #[serde(rename = "canMoveChildrenOutOfDrive")]
2291 pub can_move_children_out_of_drive: Option<bool>,
2292 /// Output only. Deprecated: Use `canMoveChildrenOutOfDrive` instead.
2293 #[serde(rename = "canMoveChildrenOutOfTeamDrive")]
2294 pub can_move_children_out_of_team_drive: Option<bool>,
2295 /// 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.
2296 #[serde(rename = "canMoveChildrenWithinDrive")]
2297 pub can_move_children_within_drive: Option<bool>,
2298 /// Output only. Deprecated: Use `canMoveChildrenWithinDrive` instead.
2299 #[serde(rename = "canMoveChildrenWithinTeamDrive")]
2300 pub can_move_children_within_team_drive: Option<bool>,
2301 /// Output only. Deprecated: Use `canMoveItemOutOfDrive` instead.
2302 #[serde(rename = "canMoveItemIntoTeamDrive")]
2303 pub can_move_item_into_team_drive: Option<bool>,
2304 /// 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.
2305 #[serde(rename = "canMoveItemOutOfDrive")]
2306 pub can_move_item_out_of_drive: Option<bool>,
2307 /// Output only. Deprecated: Use `canMoveItemOutOfDrive` instead.
2308 #[serde(rename = "canMoveItemOutOfTeamDrive")]
2309 pub can_move_item_out_of_team_drive: Option<bool>,
2310 /// 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.
2311 #[serde(rename = "canMoveItemWithinDrive")]
2312 pub can_move_item_within_drive: Option<bool>,
2313 /// Output only. Deprecated: Use `canMoveItemWithinDrive` instead.
2314 #[serde(rename = "canMoveItemWithinTeamDrive")]
2315 pub can_move_item_within_team_drive: Option<bool>,
2316 /// Output only. Deprecated: Use `canMoveItemWithinDrive` or `canMoveItemOutOfDrive` instead.
2317 #[serde(rename = "canMoveTeamDriveItem")]
2318 pub can_move_team_drive_item: Option<bool>,
2319 /// Output only. Whether the current user can read the shared drive to which this file belongs. Only populated for items in shared drives.
2320 #[serde(rename = "canReadDrive")]
2321 pub can_read_drive: Option<bool>,
2322 /// Output only. Whether the current user can read the labels on the file.
2323 #[serde(rename = "canReadLabels")]
2324 pub can_read_labels: Option<bool>,
2325 /// 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.
2326 #[serde(rename = "canReadRevisions")]
2327 pub can_read_revisions: Option<bool>,
2328 /// Output only. Deprecated: Use `canReadDrive` instead.
2329 #[serde(rename = "canReadTeamDrive")]
2330 pub can_read_team_drive: Option<bool>,
2331 /// 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.
2332 #[serde(rename = "canRemoveChildren")]
2333 pub can_remove_children: Option<bool>,
2334 /// Output only. Whether there is a content restriction on the file that can be removed by the current user.
2335 #[serde(rename = "canRemoveContentRestriction")]
2336 pub can_remove_content_restriction: Option<bool>,
2337 /// 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.
2338 #[serde(rename = "canRemoveMyDriveParent")]
2339 pub can_remove_my_drive_parent: Option<bool>,
2340 /// Output only. Whether the current user can rename this file.
2341 #[serde(rename = "canRename")]
2342 pub can_rename: Option<bool>,
2343 /// Output only. Whether the current user can modify the sharing settings for this file.
2344 #[serde(rename = "canShare")]
2345 pub can_share: Option<bool>,
2346 /// Output only. Whether the current user can move this file to trash.
2347 #[serde(rename = "canTrash")]
2348 pub can_trash: Option<bool>,
2349 /// 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.
2350 #[serde(rename = "canTrashChildren")]
2351 pub can_trash_children: Option<bool>,
2352 /// Output only. Whether the current user can restore this file from trash.
2353 #[serde(rename = "canUntrash")]
2354 pub can_untrash: Option<bool>,
2355}
2356
2357impl common::NestedType for FileCapabilities {}
2358impl common::Part for FileCapabilities {}
2359
2360/// 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.
2361///
2362/// This type is not used in any activity, and only used as *part* of another schema.
2363///
2364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2365#[serde_with::serde_as]
2366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2367pub struct FileImageMediaMetadata {
2368 /// Output only. The aperture used to create the photo (f-number).
2369 pub aperture: Option<f32>,
2370 /// Output only. The make of the camera used to create the photo.
2371 #[serde(rename = "cameraMake")]
2372 pub camera_make: Option<String>,
2373 /// Output only. The model of the camera used to create the photo.
2374 #[serde(rename = "cameraModel")]
2375 pub camera_model: Option<String>,
2376 /// Output only. The color space of the photo.
2377 #[serde(rename = "colorSpace")]
2378 pub color_space: Option<String>,
2379 /// Output only. The date and time the photo was taken (EXIF format timestamp).
2380 pub date: Option<String>,
2381 /// Output only. The exposure bias of the photo (APEX value).
2382 #[serde(rename = "exposureBias")]
2383 pub exposure_bias: Option<f32>,
2384 /// Output only. The exposure mode used to create the photo.
2385 #[serde(rename = "exposureMode")]
2386 pub exposure_mode: Option<String>,
2387 /// Output only. The length of the exposure, in seconds.
2388 #[serde(rename = "exposureTime")]
2389 pub exposure_time: Option<f32>,
2390 /// Output only. Whether a flash was used to create the photo.
2391 #[serde(rename = "flashUsed")]
2392 pub flash_used: Option<bool>,
2393 /// Output only. The focal length used to create the photo, in millimeters.
2394 #[serde(rename = "focalLength")]
2395 pub focal_length: Option<f32>,
2396 /// Output only. The height of the image in pixels.
2397 pub height: Option<i32>,
2398 /// Output only. The ISO speed used to create the photo.
2399 #[serde(rename = "isoSpeed")]
2400 pub iso_speed: Option<i32>,
2401 /// Output only. The lens used to create the photo.
2402 pub lens: Option<String>,
2403 /// Output only. Geographic location information stored in the image.
2404 pub location: Option<FileImageMediaMetadataLocation>,
2405 /// Output only. The smallest f-number of the lens at the focal length used to create the photo (APEX value).
2406 #[serde(rename = "maxApertureValue")]
2407 pub max_aperture_value: Option<f32>,
2408 /// Output only. The metering mode used to create the photo.
2409 #[serde(rename = "meteringMode")]
2410 pub metering_mode: Option<String>,
2411 /// Output only. The number of clockwise 90 degree rotations applied from the image's original orientation.
2412 pub rotation: Option<i32>,
2413 /// Output only. The type of sensor used to create the photo.
2414 pub sensor: Option<String>,
2415 /// Output only. The distance to the subject of the photo, in meters.
2416 #[serde(rename = "subjectDistance")]
2417 pub subject_distance: Option<i32>,
2418 /// Output only. The white balance mode used to create the photo.
2419 #[serde(rename = "whiteBalance")]
2420 pub white_balance: Option<String>,
2421 /// Output only. The width of the image in pixels.
2422 pub width: Option<i32>,
2423}
2424
2425impl common::NestedType for FileImageMediaMetadata {}
2426impl common::Part for FileImageMediaMetadata {}
2427
2428/// Output only. Geographic location information stored in the image.
2429///
2430/// This type is not used in any activity, and only used as *part* of another schema.
2431///
2432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2433#[serde_with::serde_as]
2434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2435pub struct FileImageMediaMetadataLocation {
2436 /// Output only. The altitude stored in the image.
2437 pub altitude: Option<f64>,
2438 /// Output only. The latitude stored in the image.
2439 pub latitude: Option<f64>,
2440 /// Output only. The longitude stored in the image.
2441 pub longitude: Option<f64>,
2442}
2443
2444impl common::NestedType for FileImageMediaMetadataLocation {}
2445impl common::Part for FileImageMediaMetadataLocation {}
2446
2447/// Indexable text attributes for the file (can only be written)
2448///
2449/// This type is not used in any activity, and only used as *part* of another schema.
2450///
2451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2452#[serde_with::serde_as]
2453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2454pub struct FileIndexableText {
2455 /// The text to be indexed for this file.
2456 pub text: Option<String>,
2457}
2458
2459impl common::NestedType for FileIndexableText {}
2460impl common::Part for FileIndexableText {}
2461
2462/// Output only. An overview of the labels on the file.
2463///
2464/// This type is not used in any activity, and only used as *part* of another schema.
2465///
2466#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2467#[serde_with::serde_as]
2468#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2469pub struct FileLabelInfo {
2470 /// 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.
2471 pub labels: Option<Vec<Label>>,
2472}
2473
2474impl common::NestedType for FileLabelInfo {}
2475impl common::Part for FileLabelInfo {}
2476
2477/// A group of labels for the file.
2478///
2479/// This type is not used in any activity, and only used as *part* of another schema.
2480///
2481#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2482#[serde_with::serde_as]
2483#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2484pub struct FileLabels {
2485 /// Output only. Deprecated.
2486 pub hidden: Option<bool>,
2487 /// Output only. Whether the file has been modified by this user.
2488 pub modified: Option<bool>,
2489 /// Output only. Deprecated: Use `copyRequiresWriterPermission` instead.
2490 pub restricted: Option<bool>,
2491 /// Whether this file is starred by the user.
2492 pub starred: Option<bool>,
2493 /// 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.
2494 pub trashed: Option<bool>,
2495 /// Whether this file has been viewed by this user.
2496 pub viewed: Option<bool>,
2497}
2498
2499impl common::NestedType for FileLabels {}
2500impl common::Part for FileLabels {}
2501
2502/// Contains details about the link URLs that clients are using to refer to this item.
2503///
2504/// This type is not used in any activity, and only used as *part* of another schema.
2505///
2506#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2507#[serde_with::serde_as]
2508#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2509pub struct FileLinkShareMetadata {
2510 /// Output only. Whether the file is eligible for security update.
2511 #[serde(rename = "securityUpdateEligible")]
2512 pub security_update_eligible: Option<bool>,
2513 /// Output only. Whether the security update is enabled for this file.
2514 #[serde(rename = "securityUpdateEnabled")]
2515 pub security_update_enabled: Option<bool>,
2516}
2517
2518impl common::NestedType for FileLinkShareMetadata {}
2519impl common::Part for FileLinkShareMetadata {}
2520
2521/// Shortcut file details. Only populated for shortcut files, which have the mimeType field set to `application/vnd.google-apps.shortcut`. Can only be set on `files.insert` requests.
2522///
2523/// This type is not used in any activity, and only used as *part* of another schema.
2524///
2525#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2526#[serde_with::serde_as]
2527#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2528pub struct FileShortcutDetails {
2529 /// The ID of the file that this shortcut points to. Can only be set on `files.insert` requests.
2530 #[serde(rename = "targetId")]
2531 pub target_id: Option<String>,
2532 /// 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.
2533 #[serde(rename = "targetMimeType")]
2534 pub target_mime_type: Option<String>,
2535 /// Output only. The ResourceKey for the target file.
2536 #[serde(rename = "targetResourceKey")]
2537 pub target_resource_key: Option<String>,
2538}
2539
2540impl common::NestedType for FileShortcutDetails {}
2541impl common::Part for FileShortcutDetails {}
2542
2543/// A thumbnail for the file. This will only be used if a standard thumbnail cannot be generated.
2544///
2545/// This type is not used in any activity, and only used as *part* of another schema.
2546///
2547#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2548#[serde_with::serde_as]
2549#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2550pub struct FileThumbnail {
2551 /// The URL-safe Base64 encoded bytes of the thumbnail image. It should conform to RFC 4648 section 5.
2552 #[serde_as(as = "Option<common::serde::urlsafe_base64::Wrapper>")]
2553 pub image: Option<Vec<u8>>,
2554 /// The MIME type of the thumbnail.
2555 #[serde(rename = "mimeType")]
2556 pub mime_type: Option<String>,
2557}
2558
2559impl common::NestedType for FileThumbnail {}
2560impl common::Part for FileThumbnail {}
2561
2562/// Output only. Metadata about video media. This will only be present for video types.
2563///
2564/// This type is not used in any activity, and only used as *part* of another schema.
2565///
2566#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2567#[serde_with::serde_as]
2568#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2569pub struct FileVideoMediaMetadata {
2570 /// Output only. The duration of the video in milliseconds.
2571 #[serde(rename = "durationMillis")]
2572 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2573 pub duration_millis: Option<i64>,
2574 /// Output only. The height of the video in pixels.
2575 pub height: Option<i32>,
2576 /// Output only. The width of the video in pixels.
2577 pub width: Option<i32>,
2578}
2579
2580impl common::NestedType for FileVideoMediaMetadata {}
2581impl common::Part for FileVideoMediaMetadata {}
2582
2583/// Output only. Details of whether the permissions on this item are inherited or directly on this item.
2584///
2585/// This type is not used in any activity, and only used as *part* of another schema.
2586///
2587#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2588#[serde_with::serde_as]
2589#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2590pub struct PermissionPermissionDetails {
2591 /// Output only. Additional roles for this user. Only `commenter` is currently possible, though more may be supported in the future.
2592 #[serde(rename = "additionalRoles")]
2593 pub additional_roles: Option<Vec<String>>,
2594 /// Output only. Whether this permission is inherited. This field is always populated.
2595 pub inherited: Option<bool>,
2596 /// Output only. The ID of the item from which this permission is inherited. This is only populated for items in shared drives.
2597 #[serde(rename = "inheritedFrom")]
2598 pub inherited_from: Option<String>,
2599 /// Output only. The permission type for this user. While new values may be added in future, the following are currently possible: * `file` * `member`
2600 #[serde(rename = "permissionType")]
2601 pub permission_type: Option<String>,
2602 /// 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`
2603 pub role: Option<String>,
2604}
2605
2606impl common::NestedType for PermissionPermissionDetails {}
2607impl common::Part for PermissionPermissionDetails {}
2608
2609/// Output only. Deprecated: Use `permissionDetails` instead.
2610///
2611/// This type is not used in any activity, and only used as *part* of another schema.
2612///
2613#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2614#[serde_with::serde_as]
2615#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2616pub struct PermissionTeamDrivePermissionDetails {
2617 /// Output only. Deprecated: Use `permissionDetails/additionalRoles` instead.
2618 #[serde(rename = "additionalRoles")]
2619 pub additional_roles: Option<Vec<String>>,
2620 /// Output only. Deprecated: Use `permissionDetails/inherited` instead.
2621 pub inherited: Option<bool>,
2622 /// Output only. Deprecated: Use `permissionDetails/inheritedFrom` instead.
2623 #[serde(rename = "inheritedFrom")]
2624 pub inherited_from: Option<String>,
2625 /// Output only. Deprecated: Use `permissionDetails/role` instead.
2626 pub role: Option<String>,
2627 /// Output only. Deprecated: Use `permissionDetails/permissionType` instead.
2628 #[serde(rename = "teamDrivePermissionType")]
2629 pub team_drive_permission_type: Option<String>,
2630}
2631
2632impl common::NestedType for PermissionTeamDrivePermissionDetails {}
2633impl common::Part for PermissionTeamDrivePermissionDetails {}
2634
2635/// 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.
2636///
2637/// This type is not used in any activity, and only used as *part* of another schema.
2638///
2639#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2640#[serde_with::serde_as]
2641#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2642pub struct TeamDriveBackgroundImageFile {
2643 /// The ID of an image file in Drive to use for the background image.
2644 pub id: Option<String>,
2645 /// 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.
2646 pub width: Option<f32>,
2647 /// 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.
2648 #[serde(rename = "xCoordinate")]
2649 pub x_coordinate: Option<f32>,
2650 /// 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.
2651 #[serde(rename = "yCoordinate")]
2652 pub y_coordinate: Option<f32>,
2653}
2654
2655impl common::NestedType for TeamDriveBackgroundImageFile {}
2656impl common::Part for TeamDriveBackgroundImageFile {}
2657
2658/// Capabilities the current user has on this Team Drive.
2659///
2660/// This type is not used in any activity, and only used as *part* of another schema.
2661///
2662#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2663#[serde_with::serde_as]
2664#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2665pub struct TeamDriveCapabilities {
2666 /// Whether the current user can add children to folders in this Team Drive.
2667 #[serde(rename = "canAddChildren")]
2668 pub can_add_children: Option<bool>,
2669 /// Whether the current user can change the `copyRequiresWriterPermission` restriction of this Team Drive.
2670 #[serde(rename = "canChangeCopyRequiresWriterPermissionRestriction")]
2671 pub can_change_copy_requires_writer_permission_restriction: Option<bool>,
2672 /// Whether the current user can change the `domainUsersOnly` restriction of this Team Drive.
2673 #[serde(rename = "canChangeDomainUsersOnlyRestriction")]
2674 pub can_change_domain_users_only_restriction: Option<bool>,
2675 /// Whether the current user can change the `sharingFoldersRequiresOrganizerPermission` restriction of this Team Drive.
2676 #[serde(rename = "canChangeSharingFoldersRequiresOrganizerPermissionRestriction")]
2677 pub can_change_sharing_folders_requires_organizer_permission_restriction: Option<bool>,
2678 /// Whether the current user can change the background of this Team Drive.
2679 #[serde(rename = "canChangeTeamDriveBackground")]
2680 pub can_change_team_drive_background: Option<bool>,
2681 /// Whether the current user can change the `teamMembersOnly` restriction of this Team Drive.
2682 #[serde(rename = "canChangeTeamMembersOnlyRestriction")]
2683 pub can_change_team_members_only_restriction: Option<bool>,
2684 /// Whether the current user can comment on files in this Team Drive.
2685 #[serde(rename = "canComment")]
2686 pub can_comment: Option<bool>,
2687 /// Whether the current user can copy files in this Team Drive.
2688 #[serde(rename = "canCopy")]
2689 pub can_copy: Option<bool>,
2690 /// Whether the current user can delete children from folders in this Team Drive.
2691 #[serde(rename = "canDeleteChildren")]
2692 pub can_delete_children: Option<bool>,
2693 /// 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.
2694 #[serde(rename = "canDeleteTeamDrive")]
2695 pub can_delete_team_drive: Option<bool>,
2696 /// Whether the current user can download files in this Team Drive.
2697 #[serde(rename = "canDownload")]
2698 pub can_download: Option<bool>,
2699 /// Whether the current user can edit files in this Team Drive
2700 #[serde(rename = "canEdit")]
2701 pub can_edit: Option<bool>,
2702 /// Whether the current user can list the children of folders in this Team Drive.
2703 #[serde(rename = "canListChildren")]
2704 pub can_list_children: Option<bool>,
2705 /// Whether the current user can add members to this Team Drive or remove them or change their role.
2706 #[serde(rename = "canManageMembers")]
2707 pub can_manage_members: Option<bool>,
2708 /// Whether the current user can read the revisions resource of files in this Team Drive.
2709 #[serde(rename = "canReadRevisions")]
2710 pub can_read_revisions: Option<bool>,
2711 /// Deprecated: Use `canDeleteChildren` or `canTrashChildren` instead.
2712 #[serde(rename = "canRemoveChildren")]
2713 pub can_remove_children: Option<bool>,
2714 /// Whether the current user can rename files or folders in this Team Drive.
2715 #[serde(rename = "canRename")]
2716 pub can_rename: Option<bool>,
2717 /// Whether the current user can rename this Team Drive.
2718 #[serde(rename = "canRenameTeamDrive")]
2719 pub can_rename_team_drive: Option<bool>,
2720 /// Whether the current user can reset the Team Drive restrictions to defaults.
2721 #[serde(rename = "canResetTeamDriveRestrictions")]
2722 pub can_reset_team_drive_restrictions: Option<bool>,
2723 /// Whether the current user can share files or folders in this Team Drive.
2724 #[serde(rename = "canShare")]
2725 pub can_share: Option<bool>,
2726 /// Whether the current user can trash children from folders in this Team Drive.
2727 #[serde(rename = "canTrashChildren")]
2728 pub can_trash_children: Option<bool>,
2729}
2730
2731impl common::NestedType for TeamDriveCapabilities {}
2732impl common::Part for TeamDriveCapabilities {}
2733
2734/// A set of restrictions that apply to this Team Drive or items inside this Team Drive.
2735///
2736/// This type is not used in any activity, and only used as *part* of another schema.
2737///
2738#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2739#[serde_with::serde_as]
2740#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2741pub struct TeamDriveRestrictions {
2742 /// Whether administrative privileges on this Team Drive are required to modify restrictions.
2743 #[serde(rename = "adminManagedRestrictions")]
2744 pub admin_managed_restrictions: Option<bool>,
2745 /// 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.
2746 #[serde(rename = "copyRequiresWriterPermission")]
2747 pub copy_requires_writer_permission: Option<bool>,
2748 /// 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.
2749 #[serde(rename = "domainUsersOnly")]
2750 pub domain_users_only: Option<bool>,
2751 /// 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.
2752 #[serde(rename = "sharingFoldersRequiresOrganizerPermission")]
2753 pub sharing_folders_requires_organizer_permission: Option<bool>,
2754 /// Whether access to items inside this Team Drive is restricted to members of this Team Drive.
2755 #[serde(rename = "teamMembersOnly")]
2756 pub team_members_only: Option<bool>,
2757}
2758
2759impl common::NestedType for TeamDriveRestrictions {}
2760impl common::Part for TeamDriveRestrictions {}
2761
2762/// Output only. The user's profile picture.
2763///
2764/// This type is not used in any activity, and only used as *part* of another schema.
2765///
2766#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2767#[serde_with::serde_as]
2768#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2769pub struct UserPicture {
2770 /// Output only. A URL that points to a profile picture of this user.
2771 pub url: Option<String>,
2772}
2773
2774impl common::NestedType for UserPicture {}
2775impl common::Part for UserPicture {}
2776
2777// ###################
2778// MethodBuilders ###
2779// #################
2780
2781/// A builder providing access to all methods supported on *about* resources.
2782/// It is not used directly, but through the [`DriveHub`] hub.
2783///
2784/// # Example
2785///
2786/// Instantiate a resource builder
2787///
2788/// ```test_harness,no_run
2789/// extern crate hyper;
2790/// extern crate hyper_rustls;
2791/// extern crate google_drive2 as drive2;
2792///
2793/// # async fn dox() {
2794/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2795///
2796/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2797/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2798/// .with_native_roots()
2799/// .unwrap()
2800/// .https_only()
2801/// .enable_http2()
2802/// .build();
2803///
2804/// let executor = hyper_util::rt::TokioExecutor::new();
2805/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2806/// secret,
2807/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2808/// yup_oauth2::client::CustomHyperClientBuilder::from(
2809/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2810/// ),
2811/// ).build().await.unwrap();
2812///
2813/// let client = hyper_util::client::legacy::Client::builder(
2814/// hyper_util::rt::TokioExecutor::new()
2815/// )
2816/// .build(
2817/// hyper_rustls::HttpsConnectorBuilder::new()
2818/// .with_native_roots()
2819/// .unwrap()
2820/// .https_or_http()
2821/// .enable_http2()
2822/// .build()
2823/// );
2824/// let mut hub = DriveHub::new(client, auth);
2825/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2826/// // like `get(...)`
2827/// // to build up your call.
2828/// let rb = hub.about();
2829/// # }
2830/// ```
2831pub struct AboutMethods<'a, C>
2832where
2833 C: 'a,
2834{
2835 hub: &'a DriveHub<C>,
2836}
2837
2838impl<'a, C> common::MethodsBuilder for AboutMethods<'a, C> {}
2839
2840impl<'a, C> AboutMethods<'a, C> {
2841 /// Create a builder to help you perform the following task:
2842 ///
2843 /// Gets the information about the current user along with Drive API settings
2844 pub fn get(&self) -> AboutGetCall<'a, C> {
2845 AboutGetCall {
2846 hub: self.hub,
2847 _start_change_id: Default::default(),
2848 _max_change_id_count: Default::default(),
2849 _include_subscribed: Default::default(),
2850 _delegate: Default::default(),
2851 _additional_params: Default::default(),
2852 _scopes: Default::default(),
2853 }
2854 }
2855}
2856
2857/// A builder providing access to all methods supported on *app* resources.
2858/// It is not used directly, but through the [`DriveHub`] hub.
2859///
2860/// # Example
2861///
2862/// Instantiate a resource builder
2863///
2864/// ```test_harness,no_run
2865/// extern crate hyper;
2866/// extern crate hyper_rustls;
2867/// extern crate google_drive2 as drive2;
2868///
2869/// # async fn dox() {
2870/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2871///
2872/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2873/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2874/// .with_native_roots()
2875/// .unwrap()
2876/// .https_only()
2877/// .enable_http2()
2878/// .build();
2879///
2880/// let executor = hyper_util::rt::TokioExecutor::new();
2881/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2882/// secret,
2883/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2884/// yup_oauth2::client::CustomHyperClientBuilder::from(
2885/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2886/// ),
2887/// ).build().await.unwrap();
2888///
2889/// let client = hyper_util::client::legacy::Client::builder(
2890/// hyper_util::rt::TokioExecutor::new()
2891/// )
2892/// .build(
2893/// hyper_rustls::HttpsConnectorBuilder::new()
2894/// .with_native_roots()
2895/// .unwrap()
2896/// .https_or_http()
2897/// .enable_http2()
2898/// .build()
2899/// );
2900/// let mut hub = DriveHub::new(client, auth);
2901/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2902/// // like `get(...)` and `list(...)`
2903/// // to build up your call.
2904/// let rb = hub.apps();
2905/// # }
2906/// ```
2907pub struct AppMethods<'a, C>
2908where
2909 C: 'a,
2910{
2911 hub: &'a DriveHub<C>,
2912}
2913
2914impl<'a, C> common::MethodsBuilder for AppMethods<'a, C> {}
2915
2916impl<'a, C> AppMethods<'a, C> {
2917 /// Create a builder to help you perform the following task:
2918 ///
2919 /// Gets a specific app.
2920 ///
2921 /// # Arguments
2922 ///
2923 /// * `appId` - The ID of the app.
2924 pub fn get(&self, app_id: &str) -> AppGetCall<'a, C> {
2925 AppGetCall {
2926 hub: self.hub,
2927 _app_id: app_id.to_string(),
2928 _delegate: Default::default(),
2929 _additional_params: Default::default(),
2930 _scopes: Default::default(),
2931 }
2932 }
2933
2934 /// Create a builder to help you perform the following task:
2935 ///
2936 /// Lists a user's installed apps.
2937 pub fn list(&self) -> AppListCall<'a, C> {
2938 AppListCall {
2939 hub: self.hub,
2940 _language_code: Default::default(),
2941 _app_filter_mime_types: Default::default(),
2942 _app_filter_extensions: Default::default(),
2943 _delegate: Default::default(),
2944 _additional_params: Default::default(),
2945 _scopes: Default::default(),
2946 }
2947 }
2948}
2949
2950/// A builder providing access to all methods supported on *change* resources.
2951/// It is not used directly, but through the [`DriveHub`] hub.
2952///
2953/// # Example
2954///
2955/// Instantiate a resource builder
2956///
2957/// ```test_harness,no_run
2958/// extern crate hyper;
2959/// extern crate hyper_rustls;
2960/// extern crate google_drive2 as drive2;
2961///
2962/// # async fn dox() {
2963/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2964///
2965/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2966/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2967/// .with_native_roots()
2968/// .unwrap()
2969/// .https_only()
2970/// .enable_http2()
2971/// .build();
2972///
2973/// let executor = hyper_util::rt::TokioExecutor::new();
2974/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2975/// secret,
2976/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2977/// yup_oauth2::client::CustomHyperClientBuilder::from(
2978/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2979/// ),
2980/// ).build().await.unwrap();
2981///
2982/// let client = hyper_util::client::legacy::Client::builder(
2983/// hyper_util::rt::TokioExecutor::new()
2984/// )
2985/// .build(
2986/// hyper_rustls::HttpsConnectorBuilder::new()
2987/// .with_native_roots()
2988/// .unwrap()
2989/// .https_or_http()
2990/// .enable_http2()
2991/// .build()
2992/// );
2993/// let mut hub = DriveHub::new(client, auth);
2994/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2995/// // like `get(...)`, `get_start_page_token(...)`, `list(...)` and `watch(...)`
2996/// // to build up your call.
2997/// let rb = hub.changes();
2998/// # }
2999/// ```
3000pub struct ChangeMethods<'a, C>
3001where
3002 C: 'a,
3003{
3004 hub: &'a DriveHub<C>,
3005}
3006
3007impl<'a, C> common::MethodsBuilder for ChangeMethods<'a, C> {}
3008
3009impl<'a, C> ChangeMethods<'a, C> {
3010 /// Create a builder to help you perform the following task:
3011 ///
3012 /// Deprecated: Use `changes.getStartPageToken` and `changes.list` to retrieve recent changes.
3013 ///
3014 /// # Arguments
3015 ///
3016 /// * `changeId` - The ID of the change.
3017 pub fn get(&self, change_id: &str) -> ChangeGetCall<'a, C> {
3018 ChangeGetCall {
3019 hub: self.hub,
3020 _change_id: change_id.to_string(),
3021 _team_drive_id: Default::default(),
3022 _supports_team_drives: Default::default(),
3023 _supports_all_drives: Default::default(),
3024 _drive_id: Default::default(),
3025 _delegate: Default::default(),
3026 _additional_params: Default::default(),
3027 _scopes: Default::default(),
3028 }
3029 }
3030
3031 /// Create a builder to help you perform the following task:
3032 ///
3033 /// Gets the starting pageToken for listing future changes.
3034 pub fn get_start_page_token(&self) -> ChangeGetStartPageTokenCall<'a, C> {
3035 ChangeGetStartPageTokenCall {
3036 hub: self.hub,
3037 _team_drive_id: Default::default(),
3038 _supports_team_drives: Default::default(),
3039 _supports_all_drives: Default::default(),
3040 _drive_id: Default::default(),
3041 _delegate: Default::default(),
3042 _additional_params: Default::default(),
3043 _scopes: Default::default(),
3044 }
3045 }
3046
3047 /// Create a builder to help you perform the following task:
3048 ///
3049 /// Lists the changes for a user or shared drive.
3050 pub fn list(&self) -> ChangeListCall<'a, C> {
3051 ChangeListCall {
3052 hub: self.hub,
3053 _team_drive_id: Default::default(),
3054 _supports_team_drives: Default::default(),
3055 _supports_all_drives: Default::default(),
3056 _start_change_id: Default::default(),
3057 _spaces: Default::default(),
3058 _page_token: Default::default(),
3059 _max_results: Default::default(),
3060 _include_team_drive_items: Default::default(),
3061 _include_subscribed: Default::default(),
3062 _include_permissions_for_view: Default::default(),
3063 _include_labels: Default::default(),
3064 _include_items_from_all_drives: Default::default(),
3065 _include_deleted: Default::default(),
3066 _include_corpus_removals: Default::default(),
3067 _drive_id: Default::default(),
3068 _delegate: Default::default(),
3069 _additional_params: Default::default(),
3070 _scopes: Default::default(),
3071 }
3072 }
3073
3074 /// Create a builder to help you perform the following task:
3075 ///
3076 /// Subscribe to changes for a user.
3077 ///
3078 /// # Arguments
3079 ///
3080 /// * `request` - No description provided.
3081 pub fn watch(&self, request: Channel) -> ChangeWatchCall<'a, C> {
3082 ChangeWatchCall {
3083 hub: self.hub,
3084 _request: request,
3085 _team_drive_id: Default::default(),
3086 _supports_team_drives: Default::default(),
3087 _supports_all_drives: Default::default(),
3088 _start_change_id: Default::default(),
3089 _spaces: Default::default(),
3090 _page_token: Default::default(),
3091 _max_results: Default::default(),
3092 _include_team_drive_items: Default::default(),
3093 _include_subscribed: Default::default(),
3094 _include_permissions_for_view: Default::default(),
3095 _include_labels: Default::default(),
3096 _include_items_from_all_drives: Default::default(),
3097 _include_deleted: Default::default(),
3098 _include_corpus_removals: Default::default(),
3099 _drive_id: Default::default(),
3100 _delegate: Default::default(),
3101 _additional_params: Default::default(),
3102 _scopes: Default::default(),
3103 }
3104 }
3105}
3106
3107/// A builder providing access to all methods supported on *channel* resources.
3108/// It is not used directly, but through the [`DriveHub`] hub.
3109///
3110/// # Example
3111///
3112/// Instantiate a resource builder
3113///
3114/// ```test_harness,no_run
3115/// extern crate hyper;
3116/// extern crate hyper_rustls;
3117/// extern crate google_drive2 as drive2;
3118///
3119/// # async fn dox() {
3120/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3121///
3122/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3123/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3124/// .with_native_roots()
3125/// .unwrap()
3126/// .https_only()
3127/// .enable_http2()
3128/// .build();
3129///
3130/// let executor = hyper_util::rt::TokioExecutor::new();
3131/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3132/// secret,
3133/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3134/// yup_oauth2::client::CustomHyperClientBuilder::from(
3135/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3136/// ),
3137/// ).build().await.unwrap();
3138///
3139/// let client = hyper_util::client::legacy::Client::builder(
3140/// hyper_util::rt::TokioExecutor::new()
3141/// )
3142/// .build(
3143/// hyper_rustls::HttpsConnectorBuilder::new()
3144/// .with_native_roots()
3145/// .unwrap()
3146/// .https_or_http()
3147/// .enable_http2()
3148/// .build()
3149/// );
3150/// let mut hub = DriveHub::new(client, auth);
3151/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3152/// // like `stop(...)`
3153/// // to build up your call.
3154/// let rb = hub.channels();
3155/// # }
3156/// ```
3157pub struct ChannelMethods<'a, C>
3158where
3159 C: 'a,
3160{
3161 hub: &'a DriveHub<C>,
3162}
3163
3164impl<'a, C> common::MethodsBuilder for ChannelMethods<'a, C> {}
3165
3166impl<'a, C> ChannelMethods<'a, C> {
3167 /// Create a builder to help you perform the following task:
3168 ///
3169 /// Stops watching resources through this channel.
3170 ///
3171 /// # Arguments
3172 ///
3173 /// * `request` - No description provided.
3174 pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C> {
3175 ChannelStopCall {
3176 hub: self.hub,
3177 _request: request,
3178 _delegate: Default::default(),
3179 _additional_params: Default::default(),
3180 _scopes: Default::default(),
3181 }
3182 }
3183}
3184
3185/// A builder providing access to all methods supported on *child* resources.
3186/// It is not used directly, but through the [`DriveHub`] hub.
3187///
3188/// # Example
3189///
3190/// Instantiate a resource builder
3191///
3192/// ```test_harness,no_run
3193/// extern crate hyper;
3194/// extern crate hyper_rustls;
3195/// extern crate google_drive2 as drive2;
3196///
3197/// # async fn dox() {
3198/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3199///
3200/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3201/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3202/// .with_native_roots()
3203/// .unwrap()
3204/// .https_only()
3205/// .enable_http2()
3206/// .build();
3207///
3208/// let executor = hyper_util::rt::TokioExecutor::new();
3209/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3210/// secret,
3211/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3212/// yup_oauth2::client::CustomHyperClientBuilder::from(
3213/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3214/// ),
3215/// ).build().await.unwrap();
3216///
3217/// let client = hyper_util::client::legacy::Client::builder(
3218/// hyper_util::rt::TokioExecutor::new()
3219/// )
3220/// .build(
3221/// hyper_rustls::HttpsConnectorBuilder::new()
3222/// .with_native_roots()
3223/// .unwrap()
3224/// .https_or_http()
3225/// .enable_http2()
3226/// .build()
3227/// );
3228/// let mut hub = DriveHub::new(client, auth);
3229/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3230/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
3231/// // to build up your call.
3232/// let rb = hub.children();
3233/// # }
3234/// ```
3235pub struct ChildMethods<'a, C>
3236where
3237 C: 'a,
3238{
3239 hub: &'a DriveHub<C>,
3240}
3241
3242impl<'a, C> common::MethodsBuilder for ChildMethods<'a, C> {}
3243
3244impl<'a, C> ChildMethods<'a, C> {
3245 /// Create a builder to help you perform the following task:
3246 ///
3247 /// Removes a child from a folder.
3248 ///
3249 /// # Arguments
3250 ///
3251 /// * `folderId` - The ID of the folder.
3252 /// * `childId` - The ID of the child.
3253 pub fn delete(&self, folder_id: &str, child_id: &str) -> ChildDeleteCall<'a, C> {
3254 ChildDeleteCall {
3255 hub: self.hub,
3256 _folder_id: folder_id.to_string(),
3257 _child_id: child_id.to_string(),
3258 _enforce_single_parent: Default::default(),
3259 _delegate: Default::default(),
3260 _additional_params: Default::default(),
3261 _scopes: Default::default(),
3262 }
3263 }
3264
3265 /// Create a builder to help you perform the following task:
3266 ///
3267 /// Gets a specific child reference.
3268 ///
3269 /// # Arguments
3270 ///
3271 /// * `folderId` - The ID of the folder.
3272 /// * `childId` - The ID of the child.
3273 pub fn get(&self, folder_id: &str, child_id: &str) -> ChildGetCall<'a, C> {
3274 ChildGetCall {
3275 hub: self.hub,
3276 _folder_id: folder_id.to_string(),
3277 _child_id: child_id.to_string(),
3278 _delegate: Default::default(),
3279 _additional_params: Default::default(),
3280 _scopes: Default::default(),
3281 }
3282 }
3283
3284 /// Create a builder to help you perform the following task:
3285 ///
3286 /// Inserts a file into a folder.
3287 ///
3288 /// # Arguments
3289 ///
3290 /// * `request` - No description provided.
3291 /// * `folderId` - The ID of the folder.
3292 pub fn insert(&self, request: ChildReference, folder_id: &str) -> ChildInsertCall<'a, C> {
3293 ChildInsertCall {
3294 hub: self.hub,
3295 _request: request,
3296 _folder_id: folder_id.to_string(),
3297 _supports_team_drives: Default::default(),
3298 _supports_all_drives: Default::default(),
3299 _enforce_single_parent: Default::default(),
3300 _delegate: Default::default(),
3301 _additional_params: Default::default(),
3302 _scopes: Default::default(),
3303 }
3304 }
3305
3306 /// Create a builder to help you perform the following task:
3307 ///
3308 /// Lists a folder's children.
3309 ///
3310 /// # Arguments
3311 ///
3312 /// * `folderId` - The ID of the folder.
3313 pub fn list(&self, folder_id: &str) -> ChildListCall<'a, C> {
3314 ChildListCall {
3315 hub: self.hub,
3316 _folder_id: folder_id.to_string(),
3317 _q: Default::default(),
3318 _page_token: Default::default(),
3319 _order_by: Default::default(),
3320 _max_results: Default::default(),
3321 _delegate: Default::default(),
3322 _additional_params: Default::default(),
3323 _scopes: Default::default(),
3324 }
3325 }
3326}
3327
3328/// A builder providing access to all methods supported on *comment* resources.
3329/// It is not used directly, but through the [`DriveHub`] hub.
3330///
3331/// # Example
3332///
3333/// Instantiate a resource builder
3334///
3335/// ```test_harness,no_run
3336/// extern crate hyper;
3337/// extern crate hyper_rustls;
3338/// extern crate google_drive2 as drive2;
3339///
3340/// # async fn dox() {
3341/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3342///
3343/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3344/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3345/// .with_native_roots()
3346/// .unwrap()
3347/// .https_only()
3348/// .enable_http2()
3349/// .build();
3350///
3351/// let executor = hyper_util::rt::TokioExecutor::new();
3352/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3353/// secret,
3354/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3355/// yup_oauth2::client::CustomHyperClientBuilder::from(
3356/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3357/// ),
3358/// ).build().await.unwrap();
3359///
3360/// let client = hyper_util::client::legacy::Client::builder(
3361/// hyper_util::rt::TokioExecutor::new()
3362/// )
3363/// .build(
3364/// hyper_rustls::HttpsConnectorBuilder::new()
3365/// .with_native_roots()
3366/// .unwrap()
3367/// .https_or_http()
3368/// .enable_http2()
3369/// .build()
3370/// );
3371/// let mut hub = DriveHub::new(client, auth);
3372/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3373/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
3374/// // to build up your call.
3375/// let rb = hub.comments();
3376/// # }
3377/// ```
3378pub struct CommentMethods<'a, C>
3379where
3380 C: 'a,
3381{
3382 hub: &'a DriveHub<C>,
3383}
3384
3385impl<'a, C> common::MethodsBuilder for CommentMethods<'a, C> {}
3386
3387impl<'a, C> CommentMethods<'a, C> {
3388 /// Create a builder to help you perform the following task:
3389 ///
3390 /// Deletes a comment.
3391 ///
3392 /// # Arguments
3393 ///
3394 /// * `fileId` - The ID of the file.
3395 /// * `commentId` - The ID of the comment.
3396 pub fn delete(&self, file_id: &str, comment_id: &str) -> CommentDeleteCall<'a, C> {
3397 CommentDeleteCall {
3398 hub: self.hub,
3399 _file_id: file_id.to_string(),
3400 _comment_id: comment_id.to_string(),
3401 _delegate: Default::default(),
3402 _additional_params: Default::default(),
3403 _scopes: Default::default(),
3404 }
3405 }
3406
3407 /// Create a builder to help you perform the following task:
3408 ///
3409 /// Gets a comment by ID.
3410 ///
3411 /// # Arguments
3412 ///
3413 /// * `fileId` - The ID of the file.
3414 /// * `commentId` - The ID of the comment.
3415 pub fn get(&self, file_id: &str, comment_id: &str) -> CommentGetCall<'a, C> {
3416 CommentGetCall {
3417 hub: self.hub,
3418 _file_id: file_id.to_string(),
3419 _comment_id: comment_id.to_string(),
3420 _include_deleted: Default::default(),
3421 _delegate: Default::default(),
3422 _additional_params: Default::default(),
3423 _scopes: Default::default(),
3424 }
3425 }
3426
3427 /// Create a builder to help you perform the following task:
3428 ///
3429 /// Creates a new comment on the given file.
3430 ///
3431 /// # Arguments
3432 ///
3433 /// * `request` - No description provided.
3434 /// * `fileId` - The ID of the file.
3435 pub fn insert(&self, request: Comment, file_id: &str) -> CommentInsertCall<'a, C> {
3436 CommentInsertCall {
3437 hub: self.hub,
3438 _request: request,
3439 _file_id: file_id.to_string(),
3440 _delegate: Default::default(),
3441 _additional_params: Default::default(),
3442 _scopes: Default::default(),
3443 }
3444 }
3445
3446 /// Create a builder to help you perform the following task:
3447 ///
3448 /// Lists a file's comments.
3449 ///
3450 /// # Arguments
3451 ///
3452 /// * `fileId` - The ID of the file.
3453 pub fn list(&self, file_id: &str) -> CommentListCall<'a, C> {
3454 CommentListCall {
3455 hub: self.hub,
3456 _file_id: file_id.to_string(),
3457 _updated_min: Default::default(),
3458 _page_token: Default::default(),
3459 _max_results: Default::default(),
3460 _include_deleted: Default::default(),
3461 _delegate: Default::default(),
3462 _additional_params: Default::default(),
3463 _scopes: Default::default(),
3464 }
3465 }
3466
3467 /// Create a builder to help you perform the following task:
3468 ///
3469 /// Updates an existing comment.
3470 ///
3471 /// # Arguments
3472 ///
3473 /// * `request` - No description provided.
3474 /// * `fileId` - The ID of the file.
3475 /// * `commentId` - The ID of the comment.
3476 pub fn patch(
3477 &self,
3478 request: Comment,
3479 file_id: &str,
3480 comment_id: &str,
3481 ) -> CommentPatchCall<'a, C> {
3482 CommentPatchCall {
3483 hub: self.hub,
3484 _request: request,
3485 _file_id: file_id.to_string(),
3486 _comment_id: comment_id.to_string(),
3487 _delegate: Default::default(),
3488 _additional_params: Default::default(),
3489 _scopes: Default::default(),
3490 }
3491 }
3492
3493 /// Create a builder to help you perform the following task:
3494 ///
3495 /// Updates an existing comment.
3496 ///
3497 /// # Arguments
3498 ///
3499 /// * `request` - No description provided.
3500 /// * `fileId` - The ID of the file.
3501 /// * `commentId` - The ID of the comment.
3502 pub fn update(
3503 &self,
3504 request: Comment,
3505 file_id: &str,
3506 comment_id: &str,
3507 ) -> CommentUpdateCall<'a, C> {
3508 CommentUpdateCall {
3509 hub: self.hub,
3510 _request: request,
3511 _file_id: file_id.to_string(),
3512 _comment_id: comment_id.to_string(),
3513 _delegate: Default::default(),
3514 _additional_params: Default::default(),
3515 _scopes: Default::default(),
3516 }
3517 }
3518}
3519
3520/// A builder providing access to all methods supported on *drive* resources.
3521/// It is not used directly, but through the [`DriveHub`] hub.
3522///
3523/// # Example
3524///
3525/// Instantiate a resource builder
3526///
3527/// ```test_harness,no_run
3528/// extern crate hyper;
3529/// extern crate hyper_rustls;
3530/// extern crate google_drive2 as drive2;
3531///
3532/// # async fn dox() {
3533/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3534///
3535/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3536/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3537/// .with_native_roots()
3538/// .unwrap()
3539/// .https_only()
3540/// .enable_http2()
3541/// .build();
3542///
3543/// let executor = hyper_util::rt::TokioExecutor::new();
3544/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3545/// secret,
3546/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3547/// yup_oauth2::client::CustomHyperClientBuilder::from(
3548/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3549/// ),
3550/// ).build().await.unwrap();
3551///
3552/// let client = hyper_util::client::legacy::Client::builder(
3553/// hyper_util::rt::TokioExecutor::new()
3554/// )
3555/// .build(
3556/// hyper_rustls::HttpsConnectorBuilder::new()
3557/// .with_native_roots()
3558/// .unwrap()
3559/// .https_or_http()
3560/// .enable_http2()
3561/// .build()
3562/// );
3563/// let mut hub = DriveHub::new(client, auth);
3564/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3565/// // like `delete(...)`, `get(...)`, `hide(...)`, `insert(...)`, `list(...)`, `unhide(...)` and `update(...)`
3566/// // to build up your call.
3567/// let rb = hub.drives();
3568/// # }
3569/// ```
3570pub struct DriveMethods<'a, C>
3571where
3572 C: 'a,
3573{
3574 hub: &'a DriveHub<C>,
3575}
3576
3577impl<'a, C> common::MethodsBuilder for DriveMethods<'a, C> {}
3578
3579impl<'a, C> DriveMethods<'a, C> {
3580 /// Create a builder to help you perform the following task:
3581 ///
3582 /// Permanently deletes a shared drive for which the user is an `organizer`. The shared drive cannot contain any untrashed items.
3583 ///
3584 /// # Arguments
3585 ///
3586 /// * `driveId` - The ID of the shared drive.
3587 pub fn delete(&self, drive_id: &str) -> DriveDeleteCall<'a, C> {
3588 DriveDeleteCall {
3589 hub: self.hub,
3590 _drive_id: drive_id.to_string(),
3591 _use_domain_admin_access: Default::default(),
3592 _allow_item_deletion: Default::default(),
3593 _delegate: Default::default(),
3594 _additional_params: Default::default(),
3595 _scopes: Default::default(),
3596 }
3597 }
3598
3599 /// Create a builder to help you perform the following task:
3600 ///
3601 /// Gets a shared drive's metadata by ID.
3602 ///
3603 /// # Arguments
3604 ///
3605 /// * `driveId` - The ID of the shared drive.
3606 pub fn get(&self, drive_id: &str) -> DriveGetCall<'a, C> {
3607 DriveGetCall {
3608 hub: self.hub,
3609 _drive_id: drive_id.to_string(),
3610 _use_domain_admin_access: Default::default(),
3611 _delegate: Default::default(),
3612 _additional_params: Default::default(),
3613 _scopes: Default::default(),
3614 }
3615 }
3616
3617 /// Create a builder to help you perform the following task:
3618 ///
3619 /// Hides a shared drive from the default view.
3620 ///
3621 /// # Arguments
3622 ///
3623 /// * `driveId` - The ID of the shared drive.
3624 pub fn hide(&self, drive_id: &str) -> DriveHideCall<'a, C> {
3625 DriveHideCall {
3626 hub: self.hub,
3627 _drive_id: drive_id.to_string(),
3628 _delegate: Default::default(),
3629 _additional_params: Default::default(),
3630 _scopes: Default::default(),
3631 }
3632 }
3633
3634 /// Create a builder to help you perform the following task:
3635 ///
3636 /// Creates a new shared drive.
3637 ///
3638 /// # Arguments
3639 ///
3640 /// * `request` - No description provided.
3641 /// * `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.
3642 pub fn insert(&self, request: Drive, request_id: &str) -> DriveInsertCall<'a, C> {
3643 DriveInsertCall {
3644 hub: self.hub,
3645 _request: request,
3646 _request_id: request_id.to_string(),
3647 _delegate: Default::default(),
3648 _additional_params: Default::default(),
3649 _scopes: Default::default(),
3650 }
3651 }
3652
3653 /// Create a builder to help you perform the following task:
3654 ///
3655 /// 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/workspace/drive/api/guides/search-shareddrives) guide.
3656 pub fn list(&self) -> DriveListCall<'a, C> {
3657 DriveListCall {
3658 hub: self.hub,
3659 _use_domain_admin_access: Default::default(),
3660 _q: Default::default(),
3661 _page_token: Default::default(),
3662 _max_results: Default::default(),
3663 _delegate: Default::default(),
3664 _additional_params: Default::default(),
3665 _scopes: Default::default(),
3666 }
3667 }
3668
3669 /// Create a builder to help you perform the following task:
3670 ///
3671 /// Restores a shared drive to the default view.
3672 ///
3673 /// # Arguments
3674 ///
3675 /// * `driveId` - The ID of the shared drive.
3676 pub fn unhide(&self, drive_id: &str) -> DriveUnhideCall<'a, C> {
3677 DriveUnhideCall {
3678 hub: self.hub,
3679 _drive_id: drive_id.to_string(),
3680 _delegate: Default::default(),
3681 _additional_params: Default::default(),
3682 _scopes: Default::default(),
3683 }
3684 }
3685
3686 /// Create a builder to help you perform the following task:
3687 ///
3688 /// Updates the metadata for a shared drive.
3689 ///
3690 /// # Arguments
3691 ///
3692 /// * `request` - No description provided.
3693 /// * `driveId` - The ID of the shared drive.
3694 pub fn update(&self, request: Drive, drive_id: &str) -> DriveUpdateCall<'a, C> {
3695 DriveUpdateCall {
3696 hub: self.hub,
3697 _request: request,
3698 _drive_id: drive_id.to_string(),
3699 _use_domain_admin_access: Default::default(),
3700 _delegate: Default::default(),
3701 _additional_params: Default::default(),
3702 _scopes: Default::default(),
3703 }
3704 }
3705}
3706
3707/// A builder providing access to all methods supported on *file* resources.
3708/// It is not used directly, but through the [`DriveHub`] hub.
3709///
3710/// # Example
3711///
3712/// Instantiate a resource builder
3713///
3714/// ```test_harness,no_run
3715/// extern crate hyper;
3716/// extern crate hyper_rustls;
3717/// extern crate google_drive2 as drive2;
3718///
3719/// # async fn dox() {
3720/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3721///
3722/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3723/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3724/// .with_native_roots()
3725/// .unwrap()
3726/// .https_only()
3727/// .enable_http2()
3728/// .build();
3729///
3730/// let executor = hyper_util::rt::TokioExecutor::new();
3731/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3732/// secret,
3733/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3734/// yup_oauth2::client::CustomHyperClientBuilder::from(
3735/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3736/// ),
3737/// ).build().await.unwrap();
3738///
3739/// let client = hyper_util::client::legacy::Client::builder(
3740/// hyper_util::rt::TokioExecutor::new()
3741/// )
3742/// .build(
3743/// hyper_rustls::HttpsConnectorBuilder::new()
3744/// .with_native_roots()
3745/// .unwrap()
3746/// .https_or_http()
3747/// .enable_http2()
3748/// .build()
3749/// );
3750/// let mut hub = DriveHub::new(client, auth);
3751/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3752/// // like `copy(...)`, `delete(...)`, `empty_trash(...)`, `export(...)`, `generate_ids(...)`, `get(...)`, `insert(...)`, `list(...)`, `list_labels(...)`, `modify_labels(...)`, `patch(...)`, `touch(...)`, `trash(...)`, `untrash(...)`, `update(...)` and `watch(...)`
3753/// // to build up your call.
3754/// let rb = hub.files();
3755/// # }
3756/// ```
3757pub struct FileMethods<'a, C>
3758where
3759 C: 'a,
3760{
3761 hub: &'a DriveHub<C>,
3762}
3763
3764impl<'a, C> common::MethodsBuilder for FileMethods<'a, C> {}
3765
3766impl<'a, C> FileMethods<'a, C> {
3767 /// Create a builder to help you perform the following task:
3768 ///
3769 /// Creates a copy of the specified file.
3770 ///
3771 /// # Arguments
3772 ///
3773 /// * `request` - No description provided.
3774 /// * `fileId` - The ID of the file to copy.
3775 pub fn copy(&self, request: File, file_id: &str) -> FileCopyCall<'a, C> {
3776 FileCopyCall {
3777 hub: self.hub,
3778 _request: request,
3779 _file_id: file_id.to_string(),
3780 _visibility: Default::default(),
3781 _timed_text_track_name: Default::default(),
3782 _timed_text_language: Default::default(),
3783 _supports_team_drives: Default::default(),
3784 _supports_all_drives: Default::default(),
3785 _pinned: Default::default(),
3786 _ocr_language: Default::default(),
3787 _ocr: Default::default(),
3788 _include_permissions_for_view: Default::default(),
3789 _include_labels: Default::default(),
3790 _enforce_single_parent: Default::default(),
3791 _convert: Default::default(),
3792 _delegate: Default::default(),
3793 _additional_params: Default::default(),
3794 _scopes: Default::default(),
3795 }
3796 }
3797
3798 /// Create a builder to help you perform the following task:
3799 ///
3800 /// 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.
3801 ///
3802 /// # Arguments
3803 ///
3804 /// * `fileId` - The ID of the file to delete.
3805 pub fn delete(&self, file_id: &str) -> FileDeleteCall<'a, C> {
3806 FileDeleteCall {
3807 hub: self.hub,
3808 _file_id: file_id.to_string(),
3809 _supports_team_drives: Default::default(),
3810 _supports_all_drives: Default::default(),
3811 _enforce_single_parent: Default::default(),
3812 _delegate: Default::default(),
3813 _additional_params: Default::default(),
3814 _scopes: Default::default(),
3815 }
3816 }
3817
3818 /// Create a builder to help you perform the following task:
3819 ///
3820 /// Permanently deletes all of the user's trashed files.
3821 pub fn empty_trash(&self) -> FileEmptyTrashCall<'a, C> {
3822 FileEmptyTrashCall {
3823 hub: self.hub,
3824 _enforce_single_parent: Default::default(),
3825 _drive_id: Default::default(),
3826 _delegate: Default::default(),
3827 _additional_params: Default::default(),
3828 _scopes: Default::default(),
3829 }
3830 }
3831
3832 /// Create a builder to help you perform the following task:
3833 ///
3834 /// Exports a Google Workspace document to the requested MIME type and returns exported byte content. Note that the exported content is limited to 10MB.
3835 ///
3836 /// # Arguments
3837 ///
3838 /// * `fileId` - The ID of the file.
3839 /// * `mimeType` - Required. The MIME type of the format requested for this export.
3840 pub fn export(&self, file_id: &str, mime_type: &str) -> FileExportCall<'a, C> {
3841 FileExportCall {
3842 hub: self.hub,
3843 _file_id: file_id.to_string(),
3844 _mime_type: mime_type.to_string(),
3845 _delegate: Default::default(),
3846 _additional_params: Default::default(),
3847 _scopes: Default::default(),
3848 }
3849 }
3850
3851 /// Create a builder to help you perform the following task:
3852 ///
3853 /// Generates a set of file IDs which can be provided in insert or copy requests.
3854 pub fn generate_ids(&self) -> FileGenerateIdCall<'a, C> {
3855 FileGenerateIdCall {
3856 hub: self.hub,
3857 _type_: Default::default(),
3858 _space: Default::default(),
3859 _max_results: Default::default(),
3860 _delegate: Default::default(),
3861 _additional_params: Default::default(),
3862 _scopes: Default::default(),
3863 }
3864 }
3865
3866 /// Create a builder to help you perform the following task:
3867 ///
3868 /// 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/workspace/drive/api/reference/rest/v2/files/export) instead. For more information, see [Download & export files](https://developers.google.com/workspace/drive/api/guides/manage-downloads).
3869 ///
3870 /// # Arguments
3871 ///
3872 /// * `fileId` - The ID for the file in question.
3873 pub fn get(&self, file_id: &str) -> FileGetCall<'a, C> {
3874 FileGetCall {
3875 hub: self.hub,
3876 _file_id: file_id.to_string(),
3877 _update_viewed_date: Default::default(),
3878 _supports_team_drives: Default::default(),
3879 _supports_all_drives: Default::default(),
3880 _revision_id: Default::default(),
3881 _projection: Default::default(),
3882 _include_permissions_for_view: Default::default(),
3883 _include_labels: Default::default(),
3884 _acknowledge_abuse: Default::default(),
3885 _delegate: Default::default(),
3886 _additional_params: Default::default(),
3887 _scopes: Default::default(),
3888 }
3889 }
3890
3891 /// Create a builder to help you perform the following task:
3892 ///
3893 /// 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/workspace/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.
3894 ///
3895 /// # Arguments
3896 ///
3897 /// * `request` - No description provided.
3898 pub fn insert(&self, request: File) -> FileInsertCall<'a, C> {
3899 FileInsertCall {
3900 hub: self.hub,
3901 _request: request,
3902 _visibility: Default::default(),
3903 _use_content_as_indexable_text: Default::default(),
3904 _timed_text_track_name: Default::default(),
3905 _timed_text_language: Default::default(),
3906 _supports_team_drives: Default::default(),
3907 _supports_all_drives: Default::default(),
3908 _pinned: Default::default(),
3909 _ocr_language: Default::default(),
3910 _ocr: Default::default(),
3911 _include_permissions_for_view: Default::default(),
3912 _include_labels: Default::default(),
3913 _enforce_single_parent: Default::default(),
3914 _convert: Default::default(),
3915 _delegate: Default::default(),
3916 _additional_params: Default::default(),
3917 _scopes: Default::default(),
3918 }
3919 }
3920
3921 /// Create a builder to help you perform the following task:
3922 ///
3923 /// Lists the user’s files. For more information, see [Search for files and folders](https://developers.google.com/workspace/drive/api/guides/search-files). This method accepts the `q` parameter, which is a search query combining one or more search terms. 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.
3924 pub fn list(&self) -> FileListCall<'a, C> {
3925 FileListCall {
3926 hub: self.hub,
3927 _team_drive_id: Default::default(),
3928 _supports_team_drives: Default::default(),
3929 _supports_all_drives: Default::default(),
3930 _spaces: Default::default(),
3931 _q: Default::default(),
3932 _projection: Default::default(),
3933 _page_token: Default::default(),
3934 _order_by: Default::default(),
3935 _max_results: Default::default(),
3936 _include_team_drive_items: Default::default(),
3937 _include_permissions_for_view: Default::default(),
3938 _include_labels: Default::default(),
3939 _include_items_from_all_drives: Default::default(),
3940 _drive_id: Default::default(),
3941 _corpus: Default::default(),
3942 _corpora: Default::default(),
3943 _delegate: Default::default(),
3944 _additional_params: Default::default(),
3945 _scopes: Default::default(),
3946 }
3947 }
3948
3949 /// Create a builder to help you perform the following task:
3950 ///
3951 /// Lists the labels on a file.
3952 ///
3953 /// # Arguments
3954 ///
3955 /// * `fileId` - The ID for the file.
3956 pub fn list_labels(&self, file_id: &str) -> FileListLabelCall<'a, C> {
3957 FileListLabelCall {
3958 hub: self.hub,
3959 _file_id: file_id.to_string(),
3960 _page_token: Default::default(),
3961 _max_results: Default::default(),
3962 _delegate: Default::default(),
3963 _additional_params: Default::default(),
3964 _scopes: Default::default(),
3965 }
3966 }
3967
3968 /// Create a builder to help you perform the following task:
3969 ///
3970 /// Modifies the set of labels applied to a file. Returns a list of the labels that were added or modified.
3971 ///
3972 /// # Arguments
3973 ///
3974 /// * `request` - No description provided.
3975 /// * `fileId` - The ID of the file to which the labels belong.
3976 pub fn modify_labels(
3977 &self,
3978 request: ModifyLabelsRequest,
3979 file_id: &str,
3980 ) -> FileModifyLabelCall<'a, C> {
3981 FileModifyLabelCall {
3982 hub: self.hub,
3983 _request: request,
3984 _file_id: file_id.to_string(),
3985 _delegate: Default::default(),
3986 _additional_params: Default::default(),
3987 _scopes: Default::default(),
3988 }
3989 }
3990
3991 /// Create a builder to help you perform the following task:
3992 ///
3993 /// 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.
3994 ///
3995 /// # Arguments
3996 ///
3997 /// * `request` - No description provided.
3998 /// * `fileId` - The ID of the file to update.
3999 pub fn patch(&self, request: File, file_id: &str) -> FilePatchCall<'a, C> {
4000 FilePatchCall {
4001 hub: self.hub,
4002 _request: request,
4003 _file_id: file_id.to_string(),
4004 _use_content_as_indexable_text: Default::default(),
4005 _update_viewed_date: Default::default(),
4006 _timed_text_track_name: Default::default(),
4007 _timed_text_language: Default::default(),
4008 _supports_team_drives: Default::default(),
4009 _supports_all_drives: Default::default(),
4010 _set_modified_date: Default::default(),
4011 _remove_parents: Default::default(),
4012 _pinned: Default::default(),
4013 _ocr_language: Default::default(),
4014 _ocr: Default::default(),
4015 _new_revision: Default::default(),
4016 _modified_date_behavior: Default::default(),
4017 _include_permissions_for_view: Default::default(),
4018 _include_labels: Default::default(),
4019 _enforce_single_parent: Default::default(),
4020 _convert: Default::default(),
4021 _add_parents: Default::default(),
4022 _delegate: Default::default(),
4023 _additional_params: Default::default(),
4024 _scopes: Default::default(),
4025 }
4026 }
4027
4028 /// Create a builder to help you perform the following task:
4029 ///
4030 /// Set the file's updated time to the current server time.
4031 ///
4032 /// # Arguments
4033 ///
4034 /// * `fileId` - The ID of the file to update.
4035 pub fn touch(&self, file_id: &str) -> FileTouchCall<'a, C> {
4036 FileTouchCall {
4037 hub: self.hub,
4038 _file_id: file_id.to_string(),
4039 _supports_team_drives: Default::default(),
4040 _supports_all_drives: Default::default(),
4041 _include_permissions_for_view: Default::default(),
4042 _include_labels: Default::default(),
4043 _delegate: Default::default(),
4044 _additional_params: Default::default(),
4045 _scopes: Default::default(),
4046 }
4047 }
4048
4049 /// Create a builder to help you perform the following task:
4050 ///
4051 /// 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.
4052 ///
4053 /// # Arguments
4054 ///
4055 /// * `fileId` - The ID of the file to trash.
4056 pub fn trash(&self, file_id: &str) -> FileTrashCall<'a, C> {
4057 FileTrashCall {
4058 hub: self.hub,
4059 _file_id: file_id.to_string(),
4060 _supports_team_drives: Default::default(),
4061 _supports_all_drives: Default::default(),
4062 _include_permissions_for_view: Default::default(),
4063 _include_labels: Default::default(),
4064 _delegate: Default::default(),
4065 _additional_params: Default::default(),
4066 _scopes: Default::default(),
4067 }
4068 }
4069
4070 /// Create a builder to help you perform the following task:
4071 ///
4072 /// 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.
4073 ///
4074 /// # Arguments
4075 ///
4076 /// * `fileId` - The ID of the file to untrash.
4077 pub fn untrash(&self, file_id: &str) -> FileUntrashCall<'a, C> {
4078 FileUntrashCall {
4079 hub: self.hub,
4080 _file_id: file_id.to_string(),
4081 _supports_team_drives: Default::default(),
4082 _supports_all_drives: Default::default(),
4083 _include_permissions_for_view: Default::default(),
4084 _include_labels: Default::default(),
4085 _delegate: Default::default(),
4086 _additional_params: Default::default(),
4087 _scopes: Default::default(),
4088 }
4089 }
4090
4091 /// Create a builder to help you perform the following task:
4092 ///
4093 /// Updates a file’s metadata, content, or both. 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:* `*/*` (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, see [Google Workspace and Google Drive supported MIME types](https://developers.google.com/workspace/drive/api/guides/mime-types).) For more information on uploading files, see [Upload file data](https://developers.google.com/workspace/drive/api/guides/manage-uploads).
4094 ///
4095 /// # Arguments
4096 ///
4097 /// * `request` - No description provided.
4098 /// * `fileId` - The ID of the file to update.
4099 pub fn update(&self, request: File, file_id: &str) -> FileUpdateCall<'a, C> {
4100 FileUpdateCall {
4101 hub: self.hub,
4102 _request: request,
4103 _file_id: file_id.to_string(),
4104 _use_content_as_indexable_text: Default::default(),
4105 _update_viewed_date: Default::default(),
4106 _timed_text_track_name: Default::default(),
4107 _timed_text_language: Default::default(),
4108 _supports_team_drives: Default::default(),
4109 _supports_all_drives: Default::default(),
4110 _set_modified_date: Default::default(),
4111 _remove_parents: Default::default(),
4112 _pinned: Default::default(),
4113 _ocr_language: Default::default(),
4114 _ocr: Default::default(),
4115 _new_revision: Default::default(),
4116 _modified_date_behavior: Default::default(),
4117 _include_permissions_for_view: Default::default(),
4118 _include_labels: Default::default(),
4119 _enforce_single_parent: Default::default(),
4120 _convert: Default::default(),
4121 _add_parents: Default::default(),
4122 _delegate: Default::default(),
4123 _additional_params: Default::default(),
4124 _scopes: Default::default(),
4125 }
4126 }
4127
4128 /// Create a builder to help you perform the following task:
4129 ///
4130 /// Subscribes to changes to a file.
4131 ///
4132 /// # Arguments
4133 ///
4134 /// * `request` - No description provided.
4135 /// * `fileId` - The ID for the file in question.
4136 pub fn watch(&self, request: Channel, file_id: &str) -> FileWatchCall<'a, C> {
4137 FileWatchCall {
4138 hub: self.hub,
4139 _request: request,
4140 _file_id: file_id.to_string(),
4141 _update_viewed_date: Default::default(),
4142 _supports_team_drives: Default::default(),
4143 _supports_all_drives: Default::default(),
4144 _revision_id: Default::default(),
4145 _projection: Default::default(),
4146 _include_permissions_for_view: Default::default(),
4147 _include_labels: Default::default(),
4148 _acknowledge_abuse: Default::default(),
4149 _delegate: Default::default(),
4150 _additional_params: Default::default(),
4151 _scopes: Default::default(),
4152 }
4153 }
4154}
4155
4156/// A builder providing access to all methods supported on *parent* resources.
4157/// It is not used directly, but through the [`DriveHub`] hub.
4158///
4159/// # Example
4160///
4161/// Instantiate a resource builder
4162///
4163/// ```test_harness,no_run
4164/// extern crate hyper;
4165/// extern crate hyper_rustls;
4166/// extern crate google_drive2 as drive2;
4167///
4168/// # async fn dox() {
4169/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4170///
4171/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4172/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4173/// .with_native_roots()
4174/// .unwrap()
4175/// .https_only()
4176/// .enable_http2()
4177/// .build();
4178///
4179/// let executor = hyper_util::rt::TokioExecutor::new();
4180/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4181/// secret,
4182/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4183/// yup_oauth2::client::CustomHyperClientBuilder::from(
4184/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4185/// ),
4186/// ).build().await.unwrap();
4187///
4188/// let client = hyper_util::client::legacy::Client::builder(
4189/// hyper_util::rt::TokioExecutor::new()
4190/// )
4191/// .build(
4192/// hyper_rustls::HttpsConnectorBuilder::new()
4193/// .with_native_roots()
4194/// .unwrap()
4195/// .https_or_http()
4196/// .enable_http2()
4197/// .build()
4198/// );
4199/// let mut hub = DriveHub::new(client, auth);
4200/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4201/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
4202/// // to build up your call.
4203/// let rb = hub.parents();
4204/// # }
4205/// ```
4206pub struct ParentMethods<'a, C>
4207where
4208 C: 'a,
4209{
4210 hub: &'a DriveHub<C>,
4211}
4212
4213impl<'a, C> common::MethodsBuilder for ParentMethods<'a, C> {}
4214
4215impl<'a, C> ParentMethods<'a, C> {
4216 /// Create a builder to help you perform the following task:
4217 ///
4218 /// Removes a parent from a file.
4219 ///
4220 /// # Arguments
4221 ///
4222 /// * `fileId` - The ID of the file.
4223 /// * `parentId` - The ID of the parent.
4224 pub fn delete(&self, file_id: &str, parent_id: &str) -> ParentDeleteCall<'a, C> {
4225 ParentDeleteCall {
4226 hub: self.hub,
4227 _file_id: file_id.to_string(),
4228 _parent_id: parent_id.to_string(),
4229 _enforce_single_parent: Default::default(),
4230 _delegate: Default::default(),
4231 _additional_params: Default::default(),
4232 _scopes: Default::default(),
4233 }
4234 }
4235
4236 /// Create a builder to help you perform the following task:
4237 ///
4238 /// Gets a specific parent reference.
4239 ///
4240 /// # Arguments
4241 ///
4242 /// * `fileId` - The ID of the file.
4243 /// * `parentId` - The ID of the parent.
4244 pub fn get(&self, file_id: &str, parent_id: &str) -> ParentGetCall<'a, C> {
4245 ParentGetCall {
4246 hub: self.hub,
4247 _file_id: file_id.to_string(),
4248 _parent_id: parent_id.to_string(),
4249 _delegate: Default::default(),
4250 _additional_params: Default::default(),
4251 _scopes: Default::default(),
4252 }
4253 }
4254
4255 /// Create a builder to help you perform the following task:
4256 ///
4257 /// Adds a parent folder for a file.
4258 ///
4259 /// # Arguments
4260 ///
4261 /// * `request` - No description provided.
4262 /// * `fileId` - The ID of the file.
4263 pub fn insert(&self, request: ParentReference, file_id: &str) -> ParentInsertCall<'a, C> {
4264 ParentInsertCall {
4265 hub: self.hub,
4266 _request: request,
4267 _file_id: file_id.to_string(),
4268 _supports_team_drives: Default::default(),
4269 _supports_all_drives: Default::default(),
4270 _enforce_single_parent: Default::default(),
4271 _delegate: Default::default(),
4272 _additional_params: Default::default(),
4273 _scopes: Default::default(),
4274 }
4275 }
4276
4277 /// Create a builder to help you perform the following task:
4278 ///
4279 /// Lists a file's parents.
4280 ///
4281 /// # Arguments
4282 ///
4283 /// * `fileId` - The ID of the file.
4284 pub fn list(&self, file_id: &str) -> ParentListCall<'a, C> {
4285 ParentListCall {
4286 hub: self.hub,
4287 _file_id: file_id.to_string(),
4288 _delegate: Default::default(),
4289 _additional_params: Default::default(),
4290 _scopes: Default::default(),
4291 }
4292 }
4293}
4294
4295/// A builder providing access to all methods supported on *permission* resources.
4296/// It is not used directly, but through the [`DriveHub`] hub.
4297///
4298/// # Example
4299///
4300/// Instantiate a resource builder
4301///
4302/// ```test_harness,no_run
4303/// extern crate hyper;
4304/// extern crate hyper_rustls;
4305/// extern crate google_drive2 as drive2;
4306///
4307/// # async fn dox() {
4308/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4309///
4310/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4311/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4312/// .with_native_roots()
4313/// .unwrap()
4314/// .https_only()
4315/// .enable_http2()
4316/// .build();
4317///
4318/// let executor = hyper_util::rt::TokioExecutor::new();
4319/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4320/// secret,
4321/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4322/// yup_oauth2::client::CustomHyperClientBuilder::from(
4323/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4324/// ),
4325/// ).build().await.unwrap();
4326///
4327/// let client = hyper_util::client::legacy::Client::builder(
4328/// hyper_util::rt::TokioExecutor::new()
4329/// )
4330/// .build(
4331/// hyper_rustls::HttpsConnectorBuilder::new()
4332/// .with_native_roots()
4333/// .unwrap()
4334/// .https_or_http()
4335/// .enable_http2()
4336/// .build()
4337/// );
4338/// let mut hub = DriveHub::new(client, auth);
4339/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4340/// // like `delete(...)`, `get(...)`, `get_id_for_email(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
4341/// // to build up your call.
4342/// let rb = hub.permissions();
4343/// # }
4344/// ```
4345pub struct PermissionMethods<'a, C>
4346where
4347 C: 'a,
4348{
4349 hub: &'a DriveHub<C>,
4350}
4351
4352impl<'a, C> common::MethodsBuilder for PermissionMethods<'a, C> {}
4353
4354impl<'a, C> PermissionMethods<'a, C> {
4355 /// Create a builder to help you perform the following task:
4356 ///
4357 /// 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.
4358 ///
4359 /// # Arguments
4360 ///
4361 /// * `fileId` - The ID for the file or shared drive.
4362 /// * `permissionId` - The ID for the permission.
4363 pub fn delete(&self, file_id: &str, permission_id: &str) -> PermissionDeleteCall<'a, C> {
4364 PermissionDeleteCall {
4365 hub: self.hub,
4366 _file_id: file_id.to_string(),
4367 _permission_id: permission_id.to_string(),
4368 _use_domain_admin_access: Default::default(),
4369 _supports_team_drives: Default::default(),
4370 _supports_all_drives: Default::default(),
4371 _enforce_expansive_access: Default::default(),
4372 _delegate: Default::default(),
4373 _additional_params: Default::default(),
4374 _scopes: Default::default(),
4375 }
4376 }
4377
4378 /// Create a builder to help you perform the following task:
4379 ///
4380 /// Gets a permission by ID.
4381 ///
4382 /// # Arguments
4383 ///
4384 /// * `fileId` - The ID for the file or shared drive.
4385 /// * `permissionId` - The ID for the permission.
4386 pub fn get(&self, file_id: &str, permission_id: &str) -> PermissionGetCall<'a, C> {
4387 PermissionGetCall {
4388 hub: self.hub,
4389 _file_id: file_id.to_string(),
4390 _permission_id: permission_id.to_string(),
4391 _use_domain_admin_access: Default::default(),
4392 _supports_team_drives: Default::default(),
4393 _supports_all_drives: Default::default(),
4394 _delegate: Default::default(),
4395 _additional_params: Default::default(),
4396 _scopes: Default::default(),
4397 }
4398 }
4399
4400 /// Create a builder to help you perform the following task:
4401 ///
4402 /// Returns the permission ID for an email address.
4403 ///
4404 /// # Arguments
4405 ///
4406 /// * `email` - The email address for which to return a permission ID
4407 pub fn get_id_for_email(&self, email: &str) -> PermissionGetIdForEmailCall<'a, C> {
4408 PermissionGetIdForEmailCall {
4409 hub: self.hub,
4410 _email: email.to_string(),
4411 _delegate: Default::default(),
4412 _additional_params: Default::default(),
4413 _scopes: Default::default(),
4414 }
4415 }
4416
4417 /// Create a builder to help you perform the following task:
4418 ///
4419 /// 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.
4420 ///
4421 /// # Arguments
4422 ///
4423 /// * `request` - No description provided.
4424 /// * `fileId` - The ID for the file or shared drive.
4425 pub fn insert(&self, request: Permission, file_id: &str) -> PermissionInsertCall<'a, C> {
4426 PermissionInsertCall {
4427 hub: self.hub,
4428 _request: request,
4429 _file_id: file_id.to_string(),
4430 _use_domain_admin_access: Default::default(),
4431 _supports_team_drives: Default::default(),
4432 _supports_all_drives: Default::default(),
4433 _send_notification_emails: Default::default(),
4434 _move_to_new_owners_root: Default::default(),
4435 _enforce_single_parent: Default::default(),
4436 _enforce_expansive_access: Default::default(),
4437 _email_message: Default::default(),
4438 _delegate: Default::default(),
4439 _additional_params: Default::default(),
4440 _scopes: Default::default(),
4441 }
4442 }
4443
4444 /// Create a builder to help you perform the following task:
4445 ///
4446 /// Lists a file's or shared drive's permissions.
4447 ///
4448 /// # Arguments
4449 ///
4450 /// * `fileId` - The ID for the file or shared drive.
4451 pub fn list(&self, file_id: &str) -> PermissionListCall<'a, C> {
4452 PermissionListCall {
4453 hub: self.hub,
4454 _file_id: file_id.to_string(),
4455 _use_domain_admin_access: Default::default(),
4456 _supports_team_drives: Default::default(),
4457 _supports_all_drives: Default::default(),
4458 _page_token: Default::default(),
4459 _max_results: Default::default(),
4460 _include_permissions_for_view: Default::default(),
4461 _delegate: Default::default(),
4462 _additional_params: Default::default(),
4463 _scopes: Default::default(),
4464 }
4465 }
4466
4467 /// Create a builder to help you perform the following task:
4468 ///
4469 /// Updates a permission using patch semantics. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied.
4470 ///
4471 /// # Arguments
4472 ///
4473 /// * `request` - No description provided.
4474 /// * `fileId` - The ID for the file or shared drive.
4475 /// * `permissionId` - The ID for the permission.
4476 pub fn patch(
4477 &self,
4478 request: Permission,
4479 file_id: &str,
4480 permission_id: &str,
4481 ) -> PermissionPatchCall<'a, C> {
4482 PermissionPatchCall {
4483 hub: self.hub,
4484 _request: request,
4485 _file_id: file_id.to_string(),
4486 _permission_id: permission_id.to_string(),
4487 _use_domain_admin_access: Default::default(),
4488 _transfer_ownership: Default::default(),
4489 _supports_team_drives: Default::default(),
4490 _supports_all_drives: Default::default(),
4491 _remove_expiration: Default::default(),
4492 _enforce_expansive_access: Default::default(),
4493 _delegate: Default::default(),
4494 _additional_params: Default::default(),
4495 _scopes: Default::default(),
4496 }
4497 }
4498
4499 /// Create a builder to help you perform the following task:
4500 ///
4501 /// Updates a permission. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied.
4502 ///
4503 /// # Arguments
4504 ///
4505 /// * `request` - No description provided.
4506 /// * `fileId` - The ID for the file or shared drive.
4507 /// * `permissionId` - The ID for the permission.
4508 pub fn update(
4509 &self,
4510 request: Permission,
4511 file_id: &str,
4512 permission_id: &str,
4513 ) -> PermissionUpdateCall<'a, C> {
4514 PermissionUpdateCall {
4515 hub: self.hub,
4516 _request: request,
4517 _file_id: file_id.to_string(),
4518 _permission_id: permission_id.to_string(),
4519 _use_domain_admin_access: Default::default(),
4520 _transfer_ownership: Default::default(),
4521 _supports_team_drives: Default::default(),
4522 _supports_all_drives: Default::default(),
4523 _remove_expiration: Default::default(),
4524 _enforce_expansive_access: Default::default(),
4525 _delegate: Default::default(),
4526 _additional_params: Default::default(),
4527 _scopes: Default::default(),
4528 }
4529 }
4530}
4531
4532/// A builder providing access to all methods supported on *property* resources.
4533/// It is not used directly, but through the [`DriveHub`] hub.
4534///
4535/// # Example
4536///
4537/// Instantiate a resource builder
4538///
4539/// ```test_harness,no_run
4540/// extern crate hyper;
4541/// extern crate hyper_rustls;
4542/// extern crate google_drive2 as drive2;
4543///
4544/// # async fn dox() {
4545/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4546///
4547/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4548/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4549/// .with_native_roots()
4550/// .unwrap()
4551/// .https_only()
4552/// .enable_http2()
4553/// .build();
4554///
4555/// let executor = hyper_util::rt::TokioExecutor::new();
4556/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4557/// secret,
4558/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4559/// yup_oauth2::client::CustomHyperClientBuilder::from(
4560/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4561/// ),
4562/// ).build().await.unwrap();
4563///
4564/// let client = hyper_util::client::legacy::Client::builder(
4565/// hyper_util::rt::TokioExecutor::new()
4566/// )
4567/// .build(
4568/// hyper_rustls::HttpsConnectorBuilder::new()
4569/// .with_native_roots()
4570/// .unwrap()
4571/// .https_or_http()
4572/// .enable_http2()
4573/// .build()
4574/// );
4575/// let mut hub = DriveHub::new(client, auth);
4576/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4577/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
4578/// // to build up your call.
4579/// let rb = hub.properties();
4580/// # }
4581/// ```
4582pub struct PropertyMethods<'a, C>
4583where
4584 C: 'a,
4585{
4586 hub: &'a DriveHub<C>,
4587}
4588
4589impl<'a, C> common::MethodsBuilder for PropertyMethods<'a, C> {}
4590
4591impl<'a, C> PropertyMethods<'a, C> {
4592 /// Create a builder to help you perform the following task:
4593 ///
4594 /// Deletes a property.
4595 ///
4596 /// # Arguments
4597 ///
4598 /// * `fileId` - The ID of the file.
4599 /// * `propertyKey` - The key of the property.
4600 pub fn delete(&self, file_id: &str, property_key: &str) -> PropertyDeleteCall<'a, C> {
4601 PropertyDeleteCall {
4602 hub: self.hub,
4603 _file_id: file_id.to_string(),
4604 _property_key: property_key.to_string(),
4605 _visibility: Default::default(),
4606 _delegate: Default::default(),
4607 _additional_params: Default::default(),
4608 _scopes: Default::default(),
4609 }
4610 }
4611
4612 /// Create a builder to help you perform the following task:
4613 ///
4614 /// Gets a property by its key.
4615 ///
4616 /// # Arguments
4617 ///
4618 /// * `fileId` - The ID of the file.
4619 /// * `propertyKey` - The key of the property.
4620 pub fn get(&self, file_id: &str, property_key: &str) -> PropertyGetCall<'a, C> {
4621 PropertyGetCall {
4622 hub: self.hub,
4623 _file_id: file_id.to_string(),
4624 _property_key: property_key.to_string(),
4625 _visibility: Default::default(),
4626 _delegate: Default::default(),
4627 _additional_params: Default::default(),
4628 _scopes: Default::default(),
4629 }
4630 }
4631
4632 /// Create a builder to help you perform the following task:
4633 ///
4634 /// Adds a property to a file, or updates it if it already exists.
4635 ///
4636 /// # Arguments
4637 ///
4638 /// * `request` - No description provided.
4639 /// * `fileId` - The ID of the file.
4640 pub fn insert(&self, request: Property, file_id: &str) -> PropertyInsertCall<'a, C> {
4641 PropertyInsertCall {
4642 hub: self.hub,
4643 _request: request,
4644 _file_id: file_id.to_string(),
4645 _delegate: Default::default(),
4646 _additional_params: Default::default(),
4647 _scopes: Default::default(),
4648 }
4649 }
4650
4651 /// Create a builder to help you perform the following task:
4652 ///
4653 /// Lists a file's properties.
4654 ///
4655 /// # Arguments
4656 ///
4657 /// * `fileId` - The ID of the file.
4658 pub fn list(&self, file_id: &str) -> PropertyListCall<'a, C> {
4659 PropertyListCall {
4660 hub: self.hub,
4661 _file_id: file_id.to_string(),
4662 _delegate: Default::default(),
4663 _additional_params: Default::default(),
4664 _scopes: Default::default(),
4665 }
4666 }
4667
4668 /// Create a builder to help you perform the following task:
4669 ///
4670 /// Updates a property.
4671 ///
4672 /// # Arguments
4673 ///
4674 /// * `request` - No description provided.
4675 /// * `fileId` - The ID of the file.
4676 /// * `propertyKey` - The key of the property.
4677 pub fn patch(
4678 &self,
4679 request: Property,
4680 file_id: &str,
4681 property_key: &str,
4682 ) -> PropertyPatchCall<'a, C> {
4683 PropertyPatchCall {
4684 hub: self.hub,
4685 _request: request,
4686 _file_id: file_id.to_string(),
4687 _property_key: property_key.to_string(),
4688 _visibility: Default::default(),
4689 _delegate: Default::default(),
4690 _additional_params: Default::default(),
4691 _scopes: Default::default(),
4692 }
4693 }
4694
4695 /// Create a builder to help you perform the following task:
4696 ///
4697 /// Updates a property.
4698 ///
4699 /// # Arguments
4700 ///
4701 /// * `request` - No description provided.
4702 /// * `fileId` - The ID of the file.
4703 /// * `propertyKey` - The key of the property.
4704 pub fn update(
4705 &self,
4706 request: Property,
4707 file_id: &str,
4708 property_key: &str,
4709 ) -> PropertyUpdateCall<'a, C> {
4710 PropertyUpdateCall {
4711 hub: self.hub,
4712 _request: request,
4713 _file_id: file_id.to_string(),
4714 _property_key: property_key.to_string(),
4715 _visibility: Default::default(),
4716 _delegate: Default::default(),
4717 _additional_params: Default::default(),
4718 _scopes: Default::default(),
4719 }
4720 }
4721}
4722
4723/// A builder providing access to all methods supported on *reply* resources.
4724/// It is not used directly, but through the [`DriveHub`] hub.
4725///
4726/// # Example
4727///
4728/// Instantiate a resource builder
4729///
4730/// ```test_harness,no_run
4731/// extern crate hyper;
4732/// extern crate hyper_rustls;
4733/// extern crate google_drive2 as drive2;
4734///
4735/// # async fn dox() {
4736/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4737///
4738/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4739/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4740/// .with_native_roots()
4741/// .unwrap()
4742/// .https_only()
4743/// .enable_http2()
4744/// .build();
4745///
4746/// let executor = hyper_util::rt::TokioExecutor::new();
4747/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4748/// secret,
4749/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4750/// yup_oauth2::client::CustomHyperClientBuilder::from(
4751/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4752/// ),
4753/// ).build().await.unwrap();
4754///
4755/// let client = hyper_util::client::legacy::Client::builder(
4756/// hyper_util::rt::TokioExecutor::new()
4757/// )
4758/// .build(
4759/// hyper_rustls::HttpsConnectorBuilder::new()
4760/// .with_native_roots()
4761/// .unwrap()
4762/// .https_or_http()
4763/// .enable_http2()
4764/// .build()
4765/// );
4766/// let mut hub = DriveHub::new(client, auth);
4767/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4768/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
4769/// // to build up your call.
4770/// let rb = hub.replies();
4771/// # }
4772/// ```
4773pub struct ReplyMethods<'a, C>
4774where
4775 C: 'a,
4776{
4777 hub: &'a DriveHub<C>,
4778}
4779
4780impl<'a, C> common::MethodsBuilder for ReplyMethods<'a, C> {}
4781
4782impl<'a, C> ReplyMethods<'a, C> {
4783 /// Create a builder to help you perform the following task:
4784 ///
4785 /// Deletes a reply.
4786 ///
4787 /// # Arguments
4788 ///
4789 /// * `fileId` - The ID of the file.
4790 /// * `commentId` - The ID of the comment.
4791 /// * `replyId` - The ID of the reply.
4792 pub fn delete(
4793 &self,
4794 file_id: &str,
4795 comment_id: &str,
4796 reply_id: &str,
4797 ) -> ReplyDeleteCall<'a, C> {
4798 ReplyDeleteCall {
4799 hub: self.hub,
4800 _file_id: file_id.to_string(),
4801 _comment_id: comment_id.to_string(),
4802 _reply_id: reply_id.to_string(),
4803 _delegate: Default::default(),
4804 _additional_params: Default::default(),
4805 _scopes: Default::default(),
4806 }
4807 }
4808
4809 /// Create a builder to help you perform the following task:
4810 ///
4811 /// Gets a reply.
4812 ///
4813 /// # Arguments
4814 ///
4815 /// * `fileId` - The ID of the file.
4816 /// * `commentId` - The ID of the comment.
4817 /// * `replyId` - The ID of the reply.
4818 pub fn get(&self, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyGetCall<'a, C> {
4819 ReplyGetCall {
4820 hub: self.hub,
4821 _file_id: file_id.to_string(),
4822 _comment_id: comment_id.to_string(),
4823 _reply_id: reply_id.to_string(),
4824 _include_deleted: Default::default(),
4825 _delegate: Default::default(),
4826 _additional_params: Default::default(),
4827 _scopes: Default::default(),
4828 }
4829 }
4830
4831 /// Create a builder to help you perform the following task:
4832 ///
4833 /// Creates a new reply to the given comment.
4834 ///
4835 /// # Arguments
4836 ///
4837 /// * `request` - No description provided.
4838 /// * `fileId` - The ID of the file.
4839 /// * `commentId` - The ID of the comment.
4840 pub fn insert(
4841 &self,
4842 request: CommentReply,
4843 file_id: &str,
4844 comment_id: &str,
4845 ) -> ReplyInsertCall<'a, C> {
4846 ReplyInsertCall {
4847 hub: self.hub,
4848 _request: request,
4849 _file_id: file_id.to_string(),
4850 _comment_id: comment_id.to_string(),
4851 _delegate: Default::default(),
4852 _additional_params: Default::default(),
4853 _scopes: Default::default(),
4854 }
4855 }
4856
4857 /// Create a builder to help you perform the following task:
4858 ///
4859 /// Lists all of the replies to a comment.
4860 ///
4861 /// # Arguments
4862 ///
4863 /// * `fileId` - The ID of the file.
4864 /// * `commentId` - The ID of the comment.
4865 pub fn list(&self, file_id: &str, comment_id: &str) -> ReplyListCall<'a, C> {
4866 ReplyListCall {
4867 hub: self.hub,
4868 _file_id: file_id.to_string(),
4869 _comment_id: comment_id.to_string(),
4870 _page_token: Default::default(),
4871 _max_results: Default::default(),
4872 _include_deleted: Default::default(),
4873 _delegate: Default::default(),
4874 _additional_params: Default::default(),
4875 _scopes: Default::default(),
4876 }
4877 }
4878
4879 /// Create a builder to help you perform the following task:
4880 ///
4881 /// Updates an existing reply.
4882 ///
4883 /// # Arguments
4884 ///
4885 /// * `request` - No description provided.
4886 /// * `fileId` - The ID of the file.
4887 /// * `commentId` - The ID of the comment.
4888 /// * `replyId` - The ID of the reply.
4889 pub fn patch(
4890 &self,
4891 request: CommentReply,
4892 file_id: &str,
4893 comment_id: &str,
4894 reply_id: &str,
4895 ) -> ReplyPatchCall<'a, C> {
4896 ReplyPatchCall {
4897 hub: self.hub,
4898 _request: request,
4899 _file_id: file_id.to_string(),
4900 _comment_id: comment_id.to_string(),
4901 _reply_id: reply_id.to_string(),
4902 _delegate: Default::default(),
4903 _additional_params: Default::default(),
4904 _scopes: Default::default(),
4905 }
4906 }
4907
4908 /// Create a builder to help you perform the following task:
4909 ///
4910 /// Updates an existing reply.
4911 ///
4912 /// # Arguments
4913 ///
4914 /// * `request` - No description provided.
4915 /// * `fileId` - The ID of the file.
4916 /// * `commentId` - The ID of the comment.
4917 /// * `replyId` - The ID of the reply.
4918 pub fn update(
4919 &self,
4920 request: CommentReply,
4921 file_id: &str,
4922 comment_id: &str,
4923 reply_id: &str,
4924 ) -> ReplyUpdateCall<'a, C> {
4925 ReplyUpdateCall {
4926 hub: self.hub,
4927 _request: request,
4928 _file_id: file_id.to_string(),
4929 _comment_id: comment_id.to_string(),
4930 _reply_id: reply_id.to_string(),
4931 _delegate: Default::default(),
4932 _additional_params: Default::default(),
4933 _scopes: Default::default(),
4934 }
4935 }
4936}
4937
4938/// A builder providing access to all methods supported on *revision* resources.
4939/// It is not used directly, but through the [`DriveHub`] hub.
4940///
4941/// # Example
4942///
4943/// Instantiate a resource builder
4944///
4945/// ```test_harness,no_run
4946/// extern crate hyper;
4947/// extern crate hyper_rustls;
4948/// extern crate google_drive2 as drive2;
4949///
4950/// # async fn dox() {
4951/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4952///
4953/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4954/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4955/// .with_native_roots()
4956/// .unwrap()
4957/// .https_only()
4958/// .enable_http2()
4959/// .build();
4960///
4961/// let executor = hyper_util::rt::TokioExecutor::new();
4962/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4963/// secret,
4964/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4965/// yup_oauth2::client::CustomHyperClientBuilder::from(
4966/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4967/// ),
4968/// ).build().await.unwrap();
4969///
4970/// let client = hyper_util::client::legacy::Client::builder(
4971/// hyper_util::rt::TokioExecutor::new()
4972/// )
4973/// .build(
4974/// hyper_rustls::HttpsConnectorBuilder::new()
4975/// .with_native_roots()
4976/// .unwrap()
4977/// .https_or_http()
4978/// .enable_http2()
4979/// .build()
4980/// );
4981/// let mut hub = DriveHub::new(client, auth);
4982/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4983/// // like `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)`
4984/// // to build up your call.
4985/// let rb = hub.revisions();
4986/// # }
4987/// ```
4988pub struct RevisionMethods<'a, C>
4989where
4990 C: 'a,
4991{
4992 hub: &'a DriveHub<C>,
4993}
4994
4995impl<'a, C> common::MethodsBuilder for RevisionMethods<'a, C> {}
4996
4997impl<'a, C> RevisionMethods<'a, C> {
4998 /// Create a builder to help you perform the following task:
4999 ///
5000 /// 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.
5001 ///
5002 /// # Arguments
5003 ///
5004 /// * `fileId` - The ID of the file.
5005 /// * `revisionId` - The ID of the revision.
5006 pub fn delete(&self, file_id: &str, revision_id: &str) -> RevisionDeleteCall<'a, C> {
5007 RevisionDeleteCall {
5008 hub: self.hub,
5009 _file_id: file_id.to_string(),
5010 _revision_id: revision_id.to_string(),
5011 _delegate: Default::default(),
5012 _additional_params: Default::default(),
5013 _scopes: Default::default(),
5014 }
5015 }
5016
5017 /// Create a builder to help you perform the following task:
5018 ///
5019 /// Gets a specific revision.
5020 ///
5021 /// # Arguments
5022 ///
5023 /// * `fileId` - The ID of the file.
5024 /// * `revisionId` - The ID of the revision.
5025 pub fn get(&self, file_id: &str, revision_id: &str) -> RevisionGetCall<'a, C> {
5026 RevisionGetCall {
5027 hub: self.hub,
5028 _file_id: file_id.to_string(),
5029 _revision_id: revision_id.to_string(),
5030 _delegate: Default::default(),
5031 _additional_params: Default::default(),
5032 _scopes: Default::default(),
5033 }
5034 }
5035
5036 /// Create a builder to help you perform the following task:
5037 ///
5038 /// Lists a file's revisions. **Important:** The list of revisions returned by this method might be incomplete for files with a large revision history, including frequently edited Google Docs, Sheets, and Slides. Older revisions might be omitted from the response, meaning the first revision returned may not be the oldest existing revision. The revision history visible in the Workspace editor user interface might be more complete than the list returned by the API.
5039 ///
5040 /// # Arguments
5041 ///
5042 /// * `fileId` - The ID of the file.
5043 pub fn list(&self, file_id: &str) -> RevisionListCall<'a, C> {
5044 RevisionListCall {
5045 hub: self.hub,
5046 _file_id: file_id.to_string(),
5047 _page_token: Default::default(),
5048 _max_results: Default::default(),
5049 _delegate: Default::default(),
5050 _additional_params: Default::default(),
5051 _scopes: Default::default(),
5052 }
5053 }
5054
5055 /// Create a builder to help you perform the following task:
5056 ///
5057 /// Updates a revision.
5058 ///
5059 /// # Arguments
5060 ///
5061 /// * `request` - No description provided.
5062 /// * `fileId` - The ID for the file.
5063 /// * `revisionId` - The ID for the revision.
5064 pub fn patch(
5065 &self,
5066 request: Revision,
5067 file_id: &str,
5068 revision_id: &str,
5069 ) -> RevisionPatchCall<'a, C> {
5070 RevisionPatchCall {
5071 hub: self.hub,
5072 _request: request,
5073 _file_id: file_id.to_string(),
5074 _revision_id: revision_id.to_string(),
5075 _delegate: Default::default(),
5076 _additional_params: Default::default(),
5077 _scopes: Default::default(),
5078 }
5079 }
5080
5081 /// Create a builder to help you perform the following task:
5082 ///
5083 /// Updates a revision.
5084 ///
5085 /// # Arguments
5086 ///
5087 /// * `request` - No description provided.
5088 /// * `fileId` - The ID for the file.
5089 /// * `revisionId` - The ID for the revision.
5090 pub fn update(
5091 &self,
5092 request: Revision,
5093 file_id: &str,
5094 revision_id: &str,
5095 ) -> RevisionUpdateCall<'a, C> {
5096 RevisionUpdateCall {
5097 hub: self.hub,
5098 _request: request,
5099 _file_id: file_id.to_string(),
5100 _revision_id: revision_id.to_string(),
5101 _delegate: Default::default(),
5102 _additional_params: Default::default(),
5103 _scopes: Default::default(),
5104 }
5105 }
5106}
5107
5108/// A builder providing access to all methods supported on *teamdrive* resources.
5109/// It is not used directly, but through the [`DriveHub`] hub.
5110///
5111/// # Example
5112///
5113/// Instantiate a resource builder
5114///
5115/// ```test_harness,no_run
5116/// extern crate hyper;
5117/// extern crate hyper_rustls;
5118/// extern crate google_drive2 as drive2;
5119///
5120/// # async fn dox() {
5121/// use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5122///
5123/// let secret: yup_oauth2::ApplicationSecret = Default::default();
5124/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
5125/// .with_native_roots()
5126/// .unwrap()
5127/// .https_only()
5128/// .enable_http2()
5129/// .build();
5130///
5131/// let executor = hyper_util::rt::TokioExecutor::new();
5132/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5133/// secret,
5134/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5135/// yup_oauth2::client::CustomHyperClientBuilder::from(
5136/// hyper_util::client::legacy::Client::builder(executor).build(connector),
5137/// ),
5138/// ).build().await.unwrap();
5139///
5140/// let client = hyper_util::client::legacy::Client::builder(
5141/// hyper_util::rt::TokioExecutor::new()
5142/// )
5143/// .build(
5144/// hyper_rustls::HttpsConnectorBuilder::new()
5145/// .with_native_roots()
5146/// .unwrap()
5147/// .https_or_http()
5148/// .enable_http2()
5149/// .build()
5150/// );
5151/// let mut hub = DriveHub::new(client, auth);
5152/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
5153/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)` and `update(...)`
5154/// // to build up your call.
5155/// let rb = hub.teamdrives();
5156/// # }
5157/// ```
5158pub struct TeamdriveMethods<'a, C>
5159where
5160 C: 'a,
5161{
5162 hub: &'a DriveHub<C>,
5163}
5164
5165impl<'a, C> common::MethodsBuilder for TeamdriveMethods<'a, C> {}
5166
5167impl<'a, C> TeamdriveMethods<'a, C> {
5168 /// Create a builder to help you perform the following task:
5169 ///
5170 /// Deprecated: Use `drives.delete` instead.
5171 ///
5172 /// # Arguments
5173 ///
5174 /// * `teamDriveId` - The ID of the Team Drive
5175 pub fn delete(&self, team_drive_id: &str) -> TeamdriveDeleteCall<'a, C> {
5176 TeamdriveDeleteCall {
5177 hub: self.hub,
5178 _team_drive_id: team_drive_id.to_string(),
5179 _delegate: Default::default(),
5180 _additional_params: Default::default(),
5181 _scopes: Default::default(),
5182 }
5183 }
5184
5185 /// Create a builder to help you perform the following task:
5186 ///
5187 /// Deprecated: Use `drives.get` instead.
5188 ///
5189 /// # Arguments
5190 ///
5191 /// * `teamDriveId` - The ID of the Team Drive
5192 pub fn get(&self, team_drive_id: &str) -> TeamdriveGetCall<'a, C> {
5193 TeamdriveGetCall {
5194 hub: self.hub,
5195 _team_drive_id: team_drive_id.to_string(),
5196 _use_domain_admin_access: Default::default(),
5197 _delegate: Default::default(),
5198 _additional_params: Default::default(),
5199 _scopes: Default::default(),
5200 }
5201 }
5202
5203 /// Create a builder to help you perform the following task:
5204 ///
5205 /// Deprecated: Use `drives.insert` instead.
5206 ///
5207 /// # Arguments
5208 ///
5209 /// * `request` - No description provided.
5210 /// * `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.
5211 pub fn insert(&self, request: TeamDrive, request_id: &str) -> TeamdriveInsertCall<'a, C> {
5212 TeamdriveInsertCall {
5213 hub: self.hub,
5214 _request: request,
5215 _request_id: request_id.to_string(),
5216 _delegate: Default::default(),
5217 _additional_params: Default::default(),
5218 _scopes: Default::default(),
5219 }
5220 }
5221
5222 /// Create a builder to help you perform the following task:
5223 ///
5224 /// Deprecated: Use `drives.list` instead.
5225 pub fn list(&self) -> TeamdriveListCall<'a, C> {
5226 TeamdriveListCall {
5227 hub: self.hub,
5228 _use_domain_admin_access: Default::default(),
5229 _q: Default::default(),
5230 _page_token: Default::default(),
5231 _max_results: Default::default(),
5232 _delegate: Default::default(),
5233 _additional_params: Default::default(),
5234 _scopes: Default::default(),
5235 }
5236 }
5237
5238 /// Create a builder to help you perform the following task:
5239 ///
5240 /// Deprecated: Use `drives.update` instead.
5241 ///
5242 /// # Arguments
5243 ///
5244 /// * `request` - No description provided.
5245 /// * `teamDriveId` - The ID of the Team Drive
5246 pub fn update(&self, request: TeamDrive, team_drive_id: &str) -> TeamdriveUpdateCall<'a, C> {
5247 TeamdriveUpdateCall {
5248 hub: self.hub,
5249 _request: request,
5250 _team_drive_id: team_drive_id.to_string(),
5251 _use_domain_admin_access: Default::default(),
5252 _delegate: Default::default(),
5253 _additional_params: Default::default(),
5254 _scopes: Default::default(),
5255 }
5256 }
5257}
5258
5259// ###################
5260// CallBuilders ###
5261// #################
5262
5263/// Gets the information about the current user along with Drive API settings
5264///
5265/// A builder for the *get* method supported by a *about* resource.
5266/// It is not used directly, but through a [`AboutMethods`] instance.
5267///
5268/// # Example
5269///
5270/// Instantiate a resource method builder
5271///
5272/// ```test_harness,no_run
5273/// # extern crate hyper;
5274/// # extern crate hyper_rustls;
5275/// # extern crate google_drive2 as drive2;
5276/// # async fn dox() {
5277/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5278///
5279/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5280/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5281/// # .with_native_roots()
5282/// # .unwrap()
5283/// # .https_only()
5284/// # .enable_http2()
5285/// # .build();
5286///
5287/// # let executor = hyper_util::rt::TokioExecutor::new();
5288/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5289/// # secret,
5290/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5291/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5292/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5293/// # ),
5294/// # ).build().await.unwrap();
5295///
5296/// # let client = hyper_util::client::legacy::Client::builder(
5297/// # hyper_util::rt::TokioExecutor::new()
5298/// # )
5299/// # .build(
5300/// # hyper_rustls::HttpsConnectorBuilder::new()
5301/// # .with_native_roots()
5302/// # .unwrap()
5303/// # .https_or_http()
5304/// # .enable_http2()
5305/// # .build()
5306/// # );
5307/// # let mut hub = DriveHub::new(client, auth);
5308/// // You can configure optional parameters by calling the respective setters at will, and
5309/// // execute the final call using `doit()`.
5310/// // Values shown here are possibly random and not representative !
5311/// let result = hub.about().get()
5312/// .start_change_id(-30)
5313/// .max_change_id_count(-9)
5314/// .include_subscribed(true)
5315/// .doit().await;
5316/// # }
5317/// ```
5318pub struct AboutGetCall<'a, C>
5319where
5320 C: 'a,
5321{
5322 hub: &'a DriveHub<C>,
5323 _start_change_id: Option<i64>,
5324 _max_change_id_count: Option<i64>,
5325 _include_subscribed: Option<bool>,
5326 _delegate: Option<&'a mut dyn common::Delegate>,
5327 _additional_params: HashMap<String, String>,
5328 _scopes: BTreeSet<String>,
5329}
5330
5331impl<'a, C> common::CallBuilder for AboutGetCall<'a, C> {}
5332
5333impl<'a, C> AboutGetCall<'a, C>
5334where
5335 C: common::Connector,
5336{
5337 /// Perform the operation you have build so far.
5338 pub async fn doit(mut self) -> common::Result<(common::Response, About)> {
5339 use std::borrow::Cow;
5340 use std::io::{Read, Seek};
5341
5342 use common::{url::Params, ToParts};
5343 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5344
5345 let mut dd = common::DefaultDelegate;
5346 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5347 dlg.begin(common::MethodInfo {
5348 id: "drive.about.get",
5349 http_method: hyper::Method::GET,
5350 });
5351
5352 for &field in [
5353 "alt",
5354 "startChangeId",
5355 "maxChangeIdCount",
5356 "includeSubscribed",
5357 ]
5358 .iter()
5359 {
5360 if self._additional_params.contains_key(field) {
5361 dlg.finished(false);
5362 return Err(common::Error::FieldClash(field));
5363 }
5364 }
5365
5366 let mut params = Params::with_capacity(5 + self._additional_params.len());
5367 if let Some(value) = self._start_change_id.as_ref() {
5368 params.push("startChangeId", value.to_string());
5369 }
5370 if let Some(value) = self._max_change_id_count.as_ref() {
5371 params.push("maxChangeIdCount", value.to_string());
5372 }
5373 if let Some(value) = self._include_subscribed.as_ref() {
5374 params.push("includeSubscribed", value.to_string());
5375 }
5376
5377 params.extend(self._additional_params.iter());
5378
5379 params.push("alt", "json");
5380 let mut url = self.hub._base_url.clone() + "about";
5381 if self._scopes.is_empty() {
5382 self._scopes
5383 .insert(Scope::MetadataReadonly.as_ref().to_string());
5384 }
5385
5386 let url = params.parse_with_url(&url);
5387
5388 loop {
5389 let token = match self
5390 .hub
5391 .auth
5392 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5393 .await
5394 {
5395 Ok(token) => token,
5396 Err(e) => match dlg.token(e) {
5397 Ok(token) => token,
5398 Err(e) => {
5399 dlg.finished(false);
5400 return Err(common::Error::MissingToken(e));
5401 }
5402 },
5403 };
5404 let mut req_result = {
5405 let client = &self.hub.client;
5406 dlg.pre_request();
5407 let mut req_builder = hyper::Request::builder()
5408 .method(hyper::Method::GET)
5409 .uri(url.as_str())
5410 .header(USER_AGENT, self.hub._user_agent.clone());
5411
5412 if let Some(token) = token.as_ref() {
5413 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5414 }
5415
5416 let request = req_builder
5417 .header(CONTENT_LENGTH, 0_u64)
5418 .body(common::to_body::<String>(None));
5419
5420 client.request(request.unwrap()).await
5421 };
5422
5423 match req_result {
5424 Err(err) => {
5425 if let common::Retry::After(d) = dlg.http_error(&err) {
5426 sleep(d).await;
5427 continue;
5428 }
5429 dlg.finished(false);
5430 return Err(common::Error::HttpError(err));
5431 }
5432 Ok(res) => {
5433 let (mut parts, body) = res.into_parts();
5434 let mut body = common::Body::new(body);
5435 if !parts.status.is_success() {
5436 let bytes = common::to_bytes(body).await.unwrap_or_default();
5437 let error = serde_json::from_str(&common::to_string(&bytes));
5438 let response = common::to_response(parts, bytes.into());
5439
5440 if let common::Retry::After(d) =
5441 dlg.http_failure(&response, error.as_ref().ok())
5442 {
5443 sleep(d).await;
5444 continue;
5445 }
5446
5447 dlg.finished(false);
5448
5449 return Err(match error {
5450 Ok(value) => common::Error::BadRequest(value),
5451 _ => common::Error::Failure(response),
5452 });
5453 }
5454 let response = {
5455 let bytes = common::to_bytes(body).await.unwrap_or_default();
5456 let encoded = common::to_string(&bytes);
5457 match serde_json::from_str(&encoded) {
5458 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5459 Err(error) => {
5460 dlg.response_json_decode_error(&encoded, &error);
5461 return Err(common::Error::JsonDecodeError(
5462 encoded.to_string(),
5463 error,
5464 ));
5465 }
5466 }
5467 };
5468
5469 dlg.finished(true);
5470 return Ok(response);
5471 }
5472 }
5473 }
5474 }
5475
5476 /// Change ID to start counting from when calculating number of remaining change IDs
5477 ///
5478 /// Sets the *start change id* query property to the given value.
5479 pub fn start_change_id(mut self, new_value: i64) -> AboutGetCall<'a, C> {
5480 self._start_change_id = Some(new_value);
5481 self
5482 }
5483 /// Maximum number of remaining change IDs to count
5484 ///
5485 /// Sets the *max change id count* query property to the given value.
5486 pub fn max_change_id_count(mut self, new_value: i64) -> AboutGetCall<'a, C> {
5487 self._max_change_id_count = Some(new_value);
5488 self
5489 }
5490 /// 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`.
5491 ///
5492 /// Sets the *include subscribed* query property to the given value.
5493 pub fn include_subscribed(mut self, new_value: bool) -> AboutGetCall<'a, C> {
5494 self._include_subscribed = Some(new_value);
5495 self
5496 }
5497 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5498 /// while executing the actual API request.
5499 ///
5500 /// ````text
5501 /// It should be used to handle progress information, and to implement a certain level of resilience.
5502 /// ````
5503 ///
5504 /// Sets the *delegate* property to the given value.
5505 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AboutGetCall<'a, C> {
5506 self._delegate = Some(new_value);
5507 self
5508 }
5509
5510 /// Set any additional parameter of the query string used in the request.
5511 /// It should be used to set parameters which are not yet available through their own
5512 /// setters.
5513 ///
5514 /// Please note that this method must not be used to set any of the known parameters
5515 /// which have their own setter method. If done anyway, the request will fail.
5516 ///
5517 /// # Additional Parameters
5518 ///
5519 /// * *$.xgafv* (query-string) - V1 error format.
5520 /// * *access_token* (query-string) - OAuth access token.
5521 /// * *alt* (query-string) - Data format for response.
5522 /// * *callback* (query-string) - JSONP
5523 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5524 /// * *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.
5525 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5526 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5527 /// * *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.
5528 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5529 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5530 pub fn param<T>(mut self, name: T, value: T) -> AboutGetCall<'a, C>
5531 where
5532 T: AsRef<str>,
5533 {
5534 self._additional_params
5535 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5536 self
5537 }
5538
5539 /// Identifies the authorization scope for the method you are building.
5540 ///
5541 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5542 /// [`Scope::MetadataReadonly`].
5543 ///
5544 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5545 /// tokens for more than one scope.
5546 ///
5547 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5548 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5549 /// sufficient, a read-write scope will do as well.
5550 pub fn add_scope<St>(mut self, scope: St) -> AboutGetCall<'a, C>
5551 where
5552 St: AsRef<str>,
5553 {
5554 self._scopes.insert(String::from(scope.as_ref()));
5555 self
5556 }
5557 /// Identifies the authorization scope(s) for the method you are building.
5558 ///
5559 /// See [`Self::add_scope()`] for details.
5560 pub fn add_scopes<I, St>(mut self, scopes: I) -> AboutGetCall<'a, C>
5561 where
5562 I: IntoIterator<Item = St>,
5563 St: AsRef<str>,
5564 {
5565 self._scopes
5566 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5567 self
5568 }
5569
5570 /// Removes all scopes, and no default scope will be used either.
5571 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5572 /// for details).
5573 pub fn clear_scopes(mut self) -> AboutGetCall<'a, C> {
5574 self._scopes.clear();
5575 self
5576 }
5577}
5578
5579/// Gets a specific app.
5580///
5581/// A builder for the *get* method supported by a *app* resource.
5582/// It is not used directly, but through a [`AppMethods`] instance.
5583///
5584/// # Example
5585///
5586/// Instantiate a resource method builder
5587///
5588/// ```test_harness,no_run
5589/// # extern crate hyper;
5590/// # extern crate hyper_rustls;
5591/// # extern crate google_drive2 as drive2;
5592/// # async fn dox() {
5593/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5594///
5595/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5596/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5597/// # .with_native_roots()
5598/// # .unwrap()
5599/// # .https_only()
5600/// # .enable_http2()
5601/// # .build();
5602///
5603/// # let executor = hyper_util::rt::TokioExecutor::new();
5604/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5605/// # secret,
5606/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5607/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5608/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5609/// # ),
5610/// # ).build().await.unwrap();
5611///
5612/// # let client = hyper_util::client::legacy::Client::builder(
5613/// # hyper_util::rt::TokioExecutor::new()
5614/// # )
5615/// # .build(
5616/// # hyper_rustls::HttpsConnectorBuilder::new()
5617/// # .with_native_roots()
5618/// # .unwrap()
5619/// # .https_or_http()
5620/// # .enable_http2()
5621/// # .build()
5622/// # );
5623/// # let mut hub = DriveHub::new(client, auth);
5624/// // You can configure optional parameters by calling the respective setters at will, and
5625/// // execute the final call using `doit()`.
5626/// // Values shown here are possibly random and not representative !
5627/// let result = hub.apps().get("appId")
5628/// .doit().await;
5629/// # }
5630/// ```
5631pub struct AppGetCall<'a, C>
5632where
5633 C: 'a,
5634{
5635 hub: &'a DriveHub<C>,
5636 _app_id: String,
5637 _delegate: Option<&'a mut dyn common::Delegate>,
5638 _additional_params: HashMap<String, String>,
5639 _scopes: BTreeSet<String>,
5640}
5641
5642impl<'a, C> common::CallBuilder for AppGetCall<'a, C> {}
5643
5644impl<'a, C> AppGetCall<'a, C>
5645where
5646 C: common::Connector,
5647{
5648 /// Perform the operation you have build so far.
5649 pub async fn doit(mut self) -> common::Result<(common::Response, App)> {
5650 use std::borrow::Cow;
5651 use std::io::{Read, Seek};
5652
5653 use common::{url::Params, ToParts};
5654 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5655
5656 let mut dd = common::DefaultDelegate;
5657 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5658 dlg.begin(common::MethodInfo {
5659 id: "drive.apps.get",
5660 http_method: hyper::Method::GET,
5661 });
5662
5663 for &field in ["alt", "appId"].iter() {
5664 if self._additional_params.contains_key(field) {
5665 dlg.finished(false);
5666 return Err(common::Error::FieldClash(field));
5667 }
5668 }
5669
5670 let mut params = Params::with_capacity(3 + self._additional_params.len());
5671 params.push("appId", self._app_id);
5672
5673 params.extend(self._additional_params.iter());
5674
5675 params.push("alt", "json");
5676 let mut url = self.hub._base_url.clone() + "apps/{appId}";
5677 if self._scopes.is_empty() {
5678 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
5679 }
5680
5681 #[allow(clippy::single_element_loop)]
5682 for &(find_this, param_name) in [("{appId}", "appId")].iter() {
5683 url = params.uri_replacement(url, param_name, find_this, false);
5684 }
5685 {
5686 let to_remove = ["appId"];
5687 params.remove_params(&to_remove);
5688 }
5689
5690 let url = params.parse_with_url(&url);
5691
5692 loop {
5693 let token = match self
5694 .hub
5695 .auth
5696 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5697 .await
5698 {
5699 Ok(token) => token,
5700 Err(e) => match dlg.token(e) {
5701 Ok(token) => token,
5702 Err(e) => {
5703 dlg.finished(false);
5704 return Err(common::Error::MissingToken(e));
5705 }
5706 },
5707 };
5708 let mut req_result = {
5709 let client = &self.hub.client;
5710 dlg.pre_request();
5711 let mut req_builder = hyper::Request::builder()
5712 .method(hyper::Method::GET)
5713 .uri(url.as_str())
5714 .header(USER_AGENT, self.hub._user_agent.clone());
5715
5716 if let Some(token) = token.as_ref() {
5717 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5718 }
5719
5720 let request = req_builder
5721 .header(CONTENT_LENGTH, 0_u64)
5722 .body(common::to_body::<String>(None));
5723
5724 client.request(request.unwrap()).await
5725 };
5726
5727 match req_result {
5728 Err(err) => {
5729 if let common::Retry::After(d) = dlg.http_error(&err) {
5730 sleep(d).await;
5731 continue;
5732 }
5733 dlg.finished(false);
5734 return Err(common::Error::HttpError(err));
5735 }
5736 Ok(res) => {
5737 let (mut parts, body) = res.into_parts();
5738 let mut body = common::Body::new(body);
5739 if !parts.status.is_success() {
5740 let bytes = common::to_bytes(body).await.unwrap_or_default();
5741 let error = serde_json::from_str(&common::to_string(&bytes));
5742 let response = common::to_response(parts, bytes.into());
5743
5744 if let common::Retry::After(d) =
5745 dlg.http_failure(&response, error.as_ref().ok())
5746 {
5747 sleep(d).await;
5748 continue;
5749 }
5750
5751 dlg.finished(false);
5752
5753 return Err(match error {
5754 Ok(value) => common::Error::BadRequest(value),
5755 _ => common::Error::Failure(response),
5756 });
5757 }
5758 let response = {
5759 let bytes = common::to_bytes(body).await.unwrap_or_default();
5760 let encoded = common::to_string(&bytes);
5761 match serde_json::from_str(&encoded) {
5762 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5763 Err(error) => {
5764 dlg.response_json_decode_error(&encoded, &error);
5765 return Err(common::Error::JsonDecodeError(
5766 encoded.to_string(),
5767 error,
5768 ));
5769 }
5770 }
5771 };
5772
5773 dlg.finished(true);
5774 return Ok(response);
5775 }
5776 }
5777 }
5778 }
5779
5780 /// The ID of the app.
5781 ///
5782 /// Sets the *app id* path property to the given value.
5783 ///
5784 /// Even though the property as already been set when instantiating this call,
5785 /// we provide this method for API completeness.
5786 pub fn app_id(mut self, new_value: &str) -> AppGetCall<'a, C> {
5787 self._app_id = new_value.to_string();
5788 self
5789 }
5790 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5791 /// while executing the actual API request.
5792 ///
5793 /// ````text
5794 /// It should be used to handle progress information, and to implement a certain level of resilience.
5795 /// ````
5796 ///
5797 /// Sets the *delegate* property to the given value.
5798 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AppGetCall<'a, C> {
5799 self._delegate = Some(new_value);
5800 self
5801 }
5802
5803 /// Set any additional parameter of the query string used in the request.
5804 /// It should be used to set parameters which are not yet available through their own
5805 /// setters.
5806 ///
5807 /// Please note that this method must not be used to set any of the known parameters
5808 /// which have their own setter method. If done anyway, the request will fail.
5809 ///
5810 /// # Additional Parameters
5811 ///
5812 /// * *$.xgafv* (query-string) - V1 error format.
5813 /// * *access_token* (query-string) - OAuth access token.
5814 /// * *alt* (query-string) - Data format for response.
5815 /// * *callback* (query-string) - JSONP
5816 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5817 /// * *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.
5818 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5819 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5820 /// * *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.
5821 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5822 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5823 pub fn param<T>(mut self, name: T, value: T) -> AppGetCall<'a, C>
5824 where
5825 T: AsRef<str>,
5826 {
5827 self._additional_params
5828 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5829 self
5830 }
5831
5832 /// Identifies the authorization scope for the method you are building.
5833 ///
5834 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5835 /// [`Scope::AppReadonly`].
5836 ///
5837 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5838 /// tokens for more than one scope.
5839 ///
5840 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5841 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5842 /// sufficient, a read-write scope will do as well.
5843 pub fn add_scope<St>(mut self, scope: St) -> AppGetCall<'a, C>
5844 where
5845 St: AsRef<str>,
5846 {
5847 self._scopes.insert(String::from(scope.as_ref()));
5848 self
5849 }
5850 /// Identifies the authorization scope(s) for the method you are building.
5851 ///
5852 /// See [`Self::add_scope()`] for details.
5853 pub fn add_scopes<I, St>(mut self, scopes: I) -> AppGetCall<'a, C>
5854 where
5855 I: IntoIterator<Item = St>,
5856 St: AsRef<str>,
5857 {
5858 self._scopes
5859 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5860 self
5861 }
5862
5863 /// Removes all scopes, and no default scope will be used either.
5864 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5865 /// for details).
5866 pub fn clear_scopes(mut self) -> AppGetCall<'a, C> {
5867 self._scopes.clear();
5868 self
5869 }
5870}
5871
5872/// Lists a user's installed apps.
5873///
5874/// A builder for the *list* method supported by a *app* resource.
5875/// It is not used directly, but through a [`AppMethods`] instance.
5876///
5877/// # Example
5878///
5879/// Instantiate a resource method builder
5880///
5881/// ```test_harness,no_run
5882/// # extern crate hyper;
5883/// # extern crate hyper_rustls;
5884/// # extern crate google_drive2 as drive2;
5885/// # async fn dox() {
5886/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5887///
5888/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5889/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5890/// # .with_native_roots()
5891/// # .unwrap()
5892/// # .https_only()
5893/// # .enable_http2()
5894/// # .build();
5895///
5896/// # let executor = hyper_util::rt::TokioExecutor::new();
5897/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5898/// # secret,
5899/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5900/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5901/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5902/// # ),
5903/// # ).build().await.unwrap();
5904///
5905/// # let client = hyper_util::client::legacy::Client::builder(
5906/// # hyper_util::rt::TokioExecutor::new()
5907/// # )
5908/// # .build(
5909/// # hyper_rustls::HttpsConnectorBuilder::new()
5910/// # .with_native_roots()
5911/// # .unwrap()
5912/// # .https_or_http()
5913/// # .enable_http2()
5914/// # .build()
5915/// # );
5916/// # let mut hub = DriveHub::new(client, auth);
5917/// // You can configure optional parameters by calling the respective setters at will, and
5918/// // execute the final call using `doit()`.
5919/// // Values shown here are possibly random and not representative !
5920/// let result = hub.apps().list()
5921/// .language_code("accusam")
5922/// .app_filter_mime_types("voluptua.")
5923/// .app_filter_extensions("dolore")
5924/// .doit().await;
5925/// # }
5926/// ```
5927pub struct AppListCall<'a, C>
5928where
5929 C: 'a,
5930{
5931 hub: &'a DriveHub<C>,
5932 _language_code: Option<String>,
5933 _app_filter_mime_types: Option<String>,
5934 _app_filter_extensions: Option<String>,
5935 _delegate: Option<&'a mut dyn common::Delegate>,
5936 _additional_params: HashMap<String, String>,
5937 _scopes: BTreeSet<String>,
5938}
5939
5940impl<'a, C> common::CallBuilder for AppListCall<'a, C> {}
5941
5942impl<'a, C> AppListCall<'a, C>
5943where
5944 C: common::Connector,
5945{
5946 /// Perform the operation you have build so far.
5947 pub async fn doit(mut self) -> common::Result<(common::Response, AppList)> {
5948 use std::borrow::Cow;
5949 use std::io::{Read, Seek};
5950
5951 use common::{url::Params, ToParts};
5952 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5953
5954 let mut dd = common::DefaultDelegate;
5955 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5956 dlg.begin(common::MethodInfo {
5957 id: "drive.apps.list",
5958 http_method: hyper::Method::GET,
5959 });
5960
5961 for &field in [
5962 "alt",
5963 "languageCode",
5964 "appFilterMimeTypes",
5965 "appFilterExtensions",
5966 ]
5967 .iter()
5968 {
5969 if self._additional_params.contains_key(field) {
5970 dlg.finished(false);
5971 return Err(common::Error::FieldClash(field));
5972 }
5973 }
5974
5975 let mut params = Params::with_capacity(5 + self._additional_params.len());
5976 if let Some(value) = self._language_code.as_ref() {
5977 params.push("languageCode", value);
5978 }
5979 if let Some(value) = self._app_filter_mime_types.as_ref() {
5980 params.push("appFilterMimeTypes", value);
5981 }
5982 if let Some(value) = self._app_filter_extensions.as_ref() {
5983 params.push("appFilterExtensions", value);
5984 }
5985
5986 params.extend(self._additional_params.iter());
5987
5988 params.push("alt", "json");
5989 let mut url = self.hub._base_url.clone() + "apps";
5990 if self._scopes.is_empty() {
5991 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
5992 }
5993
5994 let url = params.parse_with_url(&url);
5995
5996 loop {
5997 let token = match self
5998 .hub
5999 .auth
6000 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6001 .await
6002 {
6003 Ok(token) => token,
6004 Err(e) => match dlg.token(e) {
6005 Ok(token) => token,
6006 Err(e) => {
6007 dlg.finished(false);
6008 return Err(common::Error::MissingToken(e));
6009 }
6010 },
6011 };
6012 let mut req_result = {
6013 let client = &self.hub.client;
6014 dlg.pre_request();
6015 let mut req_builder = hyper::Request::builder()
6016 .method(hyper::Method::GET)
6017 .uri(url.as_str())
6018 .header(USER_AGENT, self.hub._user_agent.clone());
6019
6020 if let Some(token) = token.as_ref() {
6021 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6022 }
6023
6024 let request = req_builder
6025 .header(CONTENT_LENGTH, 0_u64)
6026 .body(common::to_body::<String>(None));
6027
6028 client.request(request.unwrap()).await
6029 };
6030
6031 match req_result {
6032 Err(err) => {
6033 if let common::Retry::After(d) = dlg.http_error(&err) {
6034 sleep(d).await;
6035 continue;
6036 }
6037 dlg.finished(false);
6038 return Err(common::Error::HttpError(err));
6039 }
6040 Ok(res) => {
6041 let (mut parts, body) = res.into_parts();
6042 let mut body = common::Body::new(body);
6043 if !parts.status.is_success() {
6044 let bytes = common::to_bytes(body).await.unwrap_or_default();
6045 let error = serde_json::from_str(&common::to_string(&bytes));
6046 let response = common::to_response(parts, bytes.into());
6047
6048 if let common::Retry::After(d) =
6049 dlg.http_failure(&response, error.as_ref().ok())
6050 {
6051 sleep(d).await;
6052 continue;
6053 }
6054
6055 dlg.finished(false);
6056
6057 return Err(match error {
6058 Ok(value) => common::Error::BadRequest(value),
6059 _ => common::Error::Failure(response),
6060 });
6061 }
6062 let response = {
6063 let bytes = common::to_bytes(body).await.unwrap_or_default();
6064 let encoded = common::to_string(&bytes);
6065 match serde_json::from_str(&encoded) {
6066 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6067 Err(error) => {
6068 dlg.response_json_decode_error(&encoded, &error);
6069 return Err(common::Error::JsonDecodeError(
6070 encoded.to_string(),
6071 error,
6072 ));
6073 }
6074 }
6075 };
6076
6077 dlg.finished(true);
6078 return Ok(response);
6079 }
6080 }
6081 }
6082 }
6083
6084 /// A language or locale code, as defined by BCP 47, with some extensions from Unicode's LDML format (http://www.unicode.org/reports/tr35/).
6085 ///
6086 /// Sets the *language code* query property to the given value.
6087 pub fn language_code(mut self, new_value: &str) -> AppListCall<'a, C> {
6088 self._language_code = Some(new_value.to_string());
6089 self
6090 }
6091 /// 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.
6092 ///
6093 /// Sets the *app filter mime types* query property to the given value.
6094 pub fn app_filter_mime_types(mut self, new_value: &str) -> AppListCall<'a, C> {
6095 self._app_filter_mime_types = Some(new_value.to_string());
6096 self
6097 }
6098 /// 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.
6099 ///
6100 /// Sets the *app filter extensions* query property to the given value.
6101 pub fn app_filter_extensions(mut self, new_value: &str) -> AppListCall<'a, C> {
6102 self._app_filter_extensions = Some(new_value.to_string());
6103 self
6104 }
6105 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6106 /// while executing the actual API request.
6107 ///
6108 /// ````text
6109 /// It should be used to handle progress information, and to implement a certain level of resilience.
6110 /// ````
6111 ///
6112 /// Sets the *delegate* property to the given value.
6113 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AppListCall<'a, C> {
6114 self._delegate = Some(new_value);
6115 self
6116 }
6117
6118 /// Set any additional parameter of the query string used in the request.
6119 /// It should be used to set parameters which are not yet available through their own
6120 /// setters.
6121 ///
6122 /// Please note that this method must not be used to set any of the known parameters
6123 /// which have their own setter method. If done anyway, the request will fail.
6124 ///
6125 /// # Additional Parameters
6126 ///
6127 /// * *$.xgafv* (query-string) - V1 error format.
6128 /// * *access_token* (query-string) - OAuth access token.
6129 /// * *alt* (query-string) - Data format for response.
6130 /// * *callback* (query-string) - JSONP
6131 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6132 /// * *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.
6133 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6134 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6135 /// * *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.
6136 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6137 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6138 pub fn param<T>(mut self, name: T, value: T) -> AppListCall<'a, C>
6139 where
6140 T: AsRef<str>,
6141 {
6142 self._additional_params
6143 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6144 self
6145 }
6146
6147 /// Identifies the authorization scope for the method you are building.
6148 ///
6149 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6150 /// [`Scope::AppReadonly`].
6151 ///
6152 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6153 /// tokens for more than one scope.
6154 ///
6155 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6156 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6157 /// sufficient, a read-write scope will do as well.
6158 pub fn add_scope<St>(mut self, scope: St) -> AppListCall<'a, C>
6159 where
6160 St: AsRef<str>,
6161 {
6162 self._scopes.insert(String::from(scope.as_ref()));
6163 self
6164 }
6165 /// Identifies the authorization scope(s) for the method you are building.
6166 ///
6167 /// See [`Self::add_scope()`] for details.
6168 pub fn add_scopes<I, St>(mut self, scopes: I) -> AppListCall<'a, C>
6169 where
6170 I: IntoIterator<Item = St>,
6171 St: AsRef<str>,
6172 {
6173 self._scopes
6174 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6175 self
6176 }
6177
6178 /// Removes all scopes, and no default scope will be used either.
6179 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6180 /// for details).
6181 pub fn clear_scopes(mut self) -> AppListCall<'a, C> {
6182 self._scopes.clear();
6183 self
6184 }
6185}
6186
6187/// Deprecated: Use `changes.getStartPageToken` and `changes.list` to retrieve recent changes.
6188///
6189/// A builder for the *get* method supported by a *change* resource.
6190/// It is not used directly, but through a [`ChangeMethods`] instance.
6191///
6192/// # Example
6193///
6194/// Instantiate a resource method builder
6195///
6196/// ```test_harness,no_run
6197/// # extern crate hyper;
6198/// # extern crate hyper_rustls;
6199/// # extern crate google_drive2 as drive2;
6200/// # async fn dox() {
6201/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6202///
6203/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6204/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6205/// # .with_native_roots()
6206/// # .unwrap()
6207/// # .https_only()
6208/// # .enable_http2()
6209/// # .build();
6210///
6211/// # let executor = hyper_util::rt::TokioExecutor::new();
6212/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6213/// # secret,
6214/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6215/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6216/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6217/// # ),
6218/// # ).build().await.unwrap();
6219///
6220/// # let client = hyper_util::client::legacy::Client::builder(
6221/// # hyper_util::rt::TokioExecutor::new()
6222/// # )
6223/// # .build(
6224/// # hyper_rustls::HttpsConnectorBuilder::new()
6225/// # .with_native_roots()
6226/// # .unwrap()
6227/// # .https_or_http()
6228/// # .enable_http2()
6229/// # .build()
6230/// # );
6231/// # let mut hub = DriveHub::new(client, auth);
6232/// // You can configure optional parameters by calling the respective setters at will, and
6233/// // execute the final call using `doit()`.
6234/// // Values shown here are possibly random and not representative !
6235/// let result = hub.changes().get("changeId")
6236/// .team_drive_id("dolore")
6237/// .supports_team_drives(false)
6238/// .supports_all_drives(false)
6239/// .drive_id("Lorem")
6240/// .doit().await;
6241/// # }
6242/// ```
6243pub struct ChangeGetCall<'a, C>
6244where
6245 C: 'a,
6246{
6247 hub: &'a DriveHub<C>,
6248 _change_id: String,
6249 _team_drive_id: Option<String>,
6250 _supports_team_drives: Option<bool>,
6251 _supports_all_drives: Option<bool>,
6252 _drive_id: Option<String>,
6253 _delegate: Option<&'a mut dyn common::Delegate>,
6254 _additional_params: HashMap<String, String>,
6255 _scopes: BTreeSet<String>,
6256}
6257
6258impl<'a, C> common::CallBuilder for ChangeGetCall<'a, C> {}
6259
6260impl<'a, C> ChangeGetCall<'a, C>
6261where
6262 C: common::Connector,
6263{
6264 /// Perform the operation you have build so far.
6265 pub async fn doit(mut self) -> common::Result<(common::Response, Change)> {
6266 use std::borrow::Cow;
6267 use std::io::{Read, Seek};
6268
6269 use common::{url::Params, ToParts};
6270 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6271
6272 let mut dd = common::DefaultDelegate;
6273 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6274 dlg.begin(common::MethodInfo {
6275 id: "drive.changes.get",
6276 http_method: hyper::Method::GET,
6277 });
6278
6279 for &field in [
6280 "alt",
6281 "changeId",
6282 "teamDriveId",
6283 "supportsTeamDrives",
6284 "supportsAllDrives",
6285 "driveId",
6286 ]
6287 .iter()
6288 {
6289 if self._additional_params.contains_key(field) {
6290 dlg.finished(false);
6291 return Err(common::Error::FieldClash(field));
6292 }
6293 }
6294
6295 let mut params = Params::with_capacity(7 + self._additional_params.len());
6296 params.push("changeId", self._change_id);
6297 if let Some(value) = self._team_drive_id.as_ref() {
6298 params.push("teamDriveId", value);
6299 }
6300 if let Some(value) = self._supports_team_drives.as_ref() {
6301 params.push("supportsTeamDrives", value.to_string());
6302 }
6303 if let Some(value) = self._supports_all_drives.as_ref() {
6304 params.push("supportsAllDrives", value.to_string());
6305 }
6306 if let Some(value) = self._drive_id.as_ref() {
6307 params.push("driveId", value);
6308 }
6309
6310 params.extend(self._additional_params.iter());
6311
6312 params.push("alt", "json");
6313 let mut url = self.hub._base_url.clone() + "changes/{changeId}";
6314 if self._scopes.is_empty() {
6315 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
6316 }
6317
6318 #[allow(clippy::single_element_loop)]
6319 for &(find_this, param_name) in [("{changeId}", "changeId")].iter() {
6320 url = params.uri_replacement(url, param_name, find_this, false);
6321 }
6322 {
6323 let to_remove = ["changeId"];
6324 params.remove_params(&to_remove);
6325 }
6326
6327 let url = params.parse_with_url(&url);
6328
6329 loop {
6330 let token = match self
6331 .hub
6332 .auth
6333 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6334 .await
6335 {
6336 Ok(token) => token,
6337 Err(e) => match dlg.token(e) {
6338 Ok(token) => token,
6339 Err(e) => {
6340 dlg.finished(false);
6341 return Err(common::Error::MissingToken(e));
6342 }
6343 },
6344 };
6345 let mut req_result = {
6346 let client = &self.hub.client;
6347 dlg.pre_request();
6348 let mut req_builder = hyper::Request::builder()
6349 .method(hyper::Method::GET)
6350 .uri(url.as_str())
6351 .header(USER_AGENT, self.hub._user_agent.clone());
6352
6353 if let Some(token) = token.as_ref() {
6354 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6355 }
6356
6357 let request = req_builder
6358 .header(CONTENT_LENGTH, 0_u64)
6359 .body(common::to_body::<String>(None));
6360
6361 client.request(request.unwrap()).await
6362 };
6363
6364 match req_result {
6365 Err(err) => {
6366 if let common::Retry::After(d) = dlg.http_error(&err) {
6367 sleep(d).await;
6368 continue;
6369 }
6370 dlg.finished(false);
6371 return Err(common::Error::HttpError(err));
6372 }
6373 Ok(res) => {
6374 let (mut parts, body) = res.into_parts();
6375 let mut body = common::Body::new(body);
6376 if !parts.status.is_success() {
6377 let bytes = common::to_bytes(body).await.unwrap_or_default();
6378 let error = serde_json::from_str(&common::to_string(&bytes));
6379 let response = common::to_response(parts, bytes.into());
6380
6381 if let common::Retry::After(d) =
6382 dlg.http_failure(&response, error.as_ref().ok())
6383 {
6384 sleep(d).await;
6385 continue;
6386 }
6387
6388 dlg.finished(false);
6389
6390 return Err(match error {
6391 Ok(value) => common::Error::BadRequest(value),
6392 _ => common::Error::Failure(response),
6393 });
6394 }
6395 let response = {
6396 let bytes = common::to_bytes(body).await.unwrap_or_default();
6397 let encoded = common::to_string(&bytes);
6398 match serde_json::from_str(&encoded) {
6399 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6400 Err(error) => {
6401 dlg.response_json_decode_error(&encoded, &error);
6402 return Err(common::Error::JsonDecodeError(
6403 encoded.to_string(),
6404 error,
6405 ));
6406 }
6407 }
6408 };
6409
6410 dlg.finished(true);
6411 return Ok(response);
6412 }
6413 }
6414 }
6415 }
6416
6417 /// The ID of the change.
6418 ///
6419 /// Sets the *change id* path property to the given value.
6420 ///
6421 /// Even though the property as already been set when instantiating this call,
6422 /// we provide this method for API completeness.
6423 pub fn change_id(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
6424 self._change_id = new_value.to_string();
6425 self
6426 }
6427 /// Deprecated: Use `driveId` instead.
6428 ///
6429 /// Sets the *team drive id* query property to the given value.
6430 pub fn team_drive_id(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
6431 self._team_drive_id = Some(new_value.to_string());
6432 self
6433 }
6434 /// Deprecated: Use `supportsAllDrives` instead.
6435 ///
6436 /// Sets the *supports team drives* query property to the given value.
6437 pub fn supports_team_drives(mut self, new_value: bool) -> ChangeGetCall<'a, C> {
6438 self._supports_team_drives = Some(new_value);
6439 self
6440 }
6441 /// Whether the requesting application supports both My Drives and shared drives.
6442 ///
6443 /// Sets the *supports all drives* query property to the given value.
6444 pub fn supports_all_drives(mut self, new_value: bool) -> ChangeGetCall<'a, C> {
6445 self._supports_all_drives = Some(new_value);
6446 self
6447 }
6448 /// The shared drive from which the change will be returned.
6449 ///
6450 /// Sets the *drive id* query property to the given value.
6451 pub fn drive_id(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
6452 self._drive_id = Some(new_value.to_string());
6453 self
6454 }
6455 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6456 /// while executing the actual API request.
6457 ///
6458 /// ````text
6459 /// It should be used to handle progress information, and to implement a certain level of resilience.
6460 /// ````
6461 ///
6462 /// Sets the *delegate* property to the given value.
6463 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeGetCall<'a, C> {
6464 self._delegate = Some(new_value);
6465 self
6466 }
6467
6468 /// Set any additional parameter of the query string used in the request.
6469 /// It should be used to set parameters which are not yet available through their own
6470 /// setters.
6471 ///
6472 /// Please note that this method must not be used to set any of the known parameters
6473 /// which have their own setter method. If done anyway, the request will fail.
6474 ///
6475 /// # Additional Parameters
6476 ///
6477 /// * *$.xgafv* (query-string) - V1 error format.
6478 /// * *access_token* (query-string) - OAuth access token.
6479 /// * *alt* (query-string) - Data format for response.
6480 /// * *callback* (query-string) - JSONP
6481 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6482 /// * *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.
6483 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6484 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6485 /// * *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.
6486 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6487 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6488 pub fn param<T>(mut self, name: T, value: T) -> ChangeGetCall<'a, C>
6489 where
6490 T: AsRef<str>,
6491 {
6492 self._additional_params
6493 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6494 self
6495 }
6496
6497 /// Identifies the authorization scope for the method you are building.
6498 ///
6499 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6500 /// [`Scope::AppReadonly`].
6501 ///
6502 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6503 /// tokens for more than one scope.
6504 ///
6505 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6506 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6507 /// sufficient, a read-write scope will do as well.
6508 pub fn add_scope<St>(mut self, scope: St) -> ChangeGetCall<'a, C>
6509 where
6510 St: AsRef<str>,
6511 {
6512 self._scopes.insert(String::from(scope.as_ref()));
6513 self
6514 }
6515 /// Identifies the authorization scope(s) for the method you are building.
6516 ///
6517 /// See [`Self::add_scope()`] for details.
6518 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeGetCall<'a, C>
6519 where
6520 I: IntoIterator<Item = St>,
6521 St: AsRef<str>,
6522 {
6523 self._scopes
6524 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6525 self
6526 }
6527
6528 /// Removes all scopes, and no default scope will be used either.
6529 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6530 /// for details).
6531 pub fn clear_scopes(mut self) -> ChangeGetCall<'a, C> {
6532 self._scopes.clear();
6533 self
6534 }
6535}
6536
6537/// Gets the starting pageToken for listing future changes.
6538///
6539/// A builder for the *getStartPageToken* method supported by a *change* resource.
6540/// It is not used directly, but through a [`ChangeMethods`] instance.
6541///
6542/// # Example
6543///
6544/// Instantiate a resource method builder
6545///
6546/// ```test_harness,no_run
6547/// # extern crate hyper;
6548/// # extern crate hyper_rustls;
6549/// # extern crate google_drive2 as drive2;
6550/// # async fn dox() {
6551/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6552///
6553/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6554/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6555/// # .with_native_roots()
6556/// # .unwrap()
6557/// # .https_only()
6558/// # .enable_http2()
6559/// # .build();
6560///
6561/// # let executor = hyper_util::rt::TokioExecutor::new();
6562/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6563/// # secret,
6564/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6565/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6566/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6567/// # ),
6568/// # ).build().await.unwrap();
6569///
6570/// # let client = hyper_util::client::legacy::Client::builder(
6571/// # hyper_util::rt::TokioExecutor::new()
6572/// # )
6573/// # .build(
6574/// # hyper_rustls::HttpsConnectorBuilder::new()
6575/// # .with_native_roots()
6576/// # .unwrap()
6577/// # .https_or_http()
6578/// # .enable_http2()
6579/// # .build()
6580/// # );
6581/// # let mut hub = DriveHub::new(client, auth);
6582/// // You can configure optional parameters by calling the respective setters at will, and
6583/// // execute the final call using `doit()`.
6584/// // Values shown here are possibly random and not representative !
6585/// let result = hub.changes().get_start_page_token()
6586/// .team_drive_id("invidunt")
6587/// .supports_team_drives(true)
6588/// .supports_all_drives(false)
6589/// .drive_id("et")
6590/// .doit().await;
6591/// # }
6592/// ```
6593pub struct ChangeGetStartPageTokenCall<'a, C>
6594where
6595 C: 'a,
6596{
6597 hub: &'a DriveHub<C>,
6598 _team_drive_id: Option<String>,
6599 _supports_team_drives: Option<bool>,
6600 _supports_all_drives: Option<bool>,
6601 _drive_id: Option<String>,
6602 _delegate: Option<&'a mut dyn common::Delegate>,
6603 _additional_params: HashMap<String, String>,
6604 _scopes: BTreeSet<String>,
6605}
6606
6607impl<'a, C> common::CallBuilder for ChangeGetStartPageTokenCall<'a, C> {}
6608
6609impl<'a, C> ChangeGetStartPageTokenCall<'a, C>
6610where
6611 C: common::Connector,
6612{
6613 /// Perform the operation you have build so far.
6614 pub async fn doit(mut self) -> common::Result<(common::Response, StartPageToken)> {
6615 use std::borrow::Cow;
6616 use std::io::{Read, Seek};
6617
6618 use common::{url::Params, ToParts};
6619 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6620
6621 let mut dd = common::DefaultDelegate;
6622 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6623 dlg.begin(common::MethodInfo {
6624 id: "drive.changes.getStartPageToken",
6625 http_method: hyper::Method::GET,
6626 });
6627
6628 for &field in [
6629 "alt",
6630 "teamDriveId",
6631 "supportsTeamDrives",
6632 "supportsAllDrives",
6633 "driveId",
6634 ]
6635 .iter()
6636 {
6637 if self._additional_params.contains_key(field) {
6638 dlg.finished(false);
6639 return Err(common::Error::FieldClash(field));
6640 }
6641 }
6642
6643 let mut params = Params::with_capacity(6 + self._additional_params.len());
6644 if let Some(value) = self._team_drive_id.as_ref() {
6645 params.push("teamDriveId", value);
6646 }
6647 if let Some(value) = self._supports_team_drives.as_ref() {
6648 params.push("supportsTeamDrives", value.to_string());
6649 }
6650 if let Some(value) = self._supports_all_drives.as_ref() {
6651 params.push("supportsAllDrives", value.to_string());
6652 }
6653 if let Some(value) = self._drive_id.as_ref() {
6654 params.push("driveId", value);
6655 }
6656
6657 params.extend(self._additional_params.iter());
6658
6659 params.push("alt", "json");
6660 let mut url = self.hub._base_url.clone() + "changes/startPageToken";
6661 if self._scopes.is_empty() {
6662 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
6663 }
6664
6665 let url = params.parse_with_url(&url);
6666
6667 loop {
6668 let token = match self
6669 .hub
6670 .auth
6671 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6672 .await
6673 {
6674 Ok(token) => token,
6675 Err(e) => match dlg.token(e) {
6676 Ok(token) => token,
6677 Err(e) => {
6678 dlg.finished(false);
6679 return Err(common::Error::MissingToken(e));
6680 }
6681 },
6682 };
6683 let mut req_result = {
6684 let client = &self.hub.client;
6685 dlg.pre_request();
6686 let mut req_builder = hyper::Request::builder()
6687 .method(hyper::Method::GET)
6688 .uri(url.as_str())
6689 .header(USER_AGENT, self.hub._user_agent.clone());
6690
6691 if let Some(token) = token.as_ref() {
6692 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6693 }
6694
6695 let request = req_builder
6696 .header(CONTENT_LENGTH, 0_u64)
6697 .body(common::to_body::<String>(None));
6698
6699 client.request(request.unwrap()).await
6700 };
6701
6702 match req_result {
6703 Err(err) => {
6704 if let common::Retry::After(d) = dlg.http_error(&err) {
6705 sleep(d).await;
6706 continue;
6707 }
6708 dlg.finished(false);
6709 return Err(common::Error::HttpError(err));
6710 }
6711 Ok(res) => {
6712 let (mut parts, body) = res.into_parts();
6713 let mut body = common::Body::new(body);
6714 if !parts.status.is_success() {
6715 let bytes = common::to_bytes(body).await.unwrap_or_default();
6716 let error = serde_json::from_str(&common::to_string(&bytes));
6717 let response = common::to_response(parts, bytes.into());
6718
6719 if let common::Retry::After(d) =
6720 dlg.http_failure(&response, error.as_ref().ok())
6721 {
6722 sleep(d).await;
6723 continue;
6724 }
6725
6726 dlg.finished(false);
6727
6728 return Err(match error {
6729 Ok(value) => common::Error::BadRequest(value),
6730 _ => common::Error::Failure(response),
6731 });
6732 }
6733 let response = {
6734 let bytes = common::to_bytes(body).await.unwrap_or_default();
6735 let encoded = common::to_string(&bytes);
6736 match serde_json::from_str(&encoded) {
6737 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6738 Err(error) => {
6739 dlg.response_json_decode_error(&encoded, &error);
6740 return Err(common::Error::JsonDecodeError(
6741 encoded.to_string(),
6742 error,
6743 ));
6744 }
6745 }
6746 };
6747
6748 dlg.finished(true);
6749 return Ok(response);
6750 }
6751 }
6752 }
6753 }
6754
6755 /// Deprecated: Use `driveId` instead.
6756 ///
6757 /// Sets the *team drive id* query property to the given value.
6758 pub fn team_drive_id(mut self, new_value: &str) -> ChangeGetStartPageTokenCall<'a, C> {
6759 self._team_drive_id = Some(new_value.to_string());
6760 self
6761 }
6762 /// Deprecated: Use `supportsAllDrives` instead.
6763 ///
6764 /// Sets the *supports team drives* query property to the given value.
6765 pub fn supports_team_drives(mut self, new_value: bool) -> ChangeGetStartPageTokenCall<'a, C> {
6766 self._supports_team_drives = Some(new_value);
6767 self
6768 }
6769 /// Whether the requesting application supports both My Drives and shared drives.
6770 ///
6771 /// Sets the *supports all drives* query property to the given value.
6772 pub fn supports_all_drives(mut self, new_value: bool) -> ChangeGetStartPageTokenCall<'a, C> {
6773 self._supports_all_drives = Some(new_value);
6774 self
6775 }
6776 /// The ID of the shared drive for which the starting pageToken for listing future changes from that shared drive will be returned.
6777 ///
6778 /// Sets the *drive id* query property to the given value.
6779 pub fn drive_id(mut self, new_value: &str) -> ChangeGetStartPageTokenCall<'a, C> {
6780 self._drive_id = Some(new_value.to_string());
6781 self
6782 }
6783 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6784 /// while executing the actual API request.
6785 ///
6786 /// ````text
6787 /// It should be used to handle progress information, and to implement a certain level of resilience.
6788 /// ````
6789 ///
6790 /// Sets the *delegate* property to the given value.
6791 pub fn delegate(
6792 mut self,
6793 new_value: &'a mut dyn common::Delegate,
6794 ) -> ChangeGetStartPageTokenCall<'a, C> {
6795 self._delegate = Some(new_value);
6796 self
6797 }
6798
6799 /// Set any additional parameter of the query string used in the request.
6800 /// It should be used to set parameters which are not yet available through their own
6801 /// setters.
6802 ///
6803 /// Please note that this method must not be used to set any of the known parameters
6804 /// which have their own setter method. If done anyway, the request will fail.
6805 ///
6806 /// # Additional Parameters
6807 ///
6808 /// * *$.xgafv* (query-string) - V1 error format.
6809 /// * *access_token* (query-string) - OAuth access token.
6810 /// * *alt* (query-string) - Data format for response.
6811 /// * *callback* (query-string) - JSONP
6812 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6813 /// * *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.
6814 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6815 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6816 /// * *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.
6817 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6818 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6819 pub fn param<T>(mut self, name: T, value: T) -> ChangeGetStartPageTokenCall<'a, C>
6820 where
6821 T: AsRef<str>,
6822 {
6823 self._additional_params
6824 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6825 self
6826 }
6827
6828 /// Identifies the authorization scope for the method you are building.
6829 ///
6830 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6831 /// [`Scope::AppReadonly`].
6832 ///
6833 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6834 /// tokens for more than one scope.
6835 ///
6836 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6837 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6838 /// sufficient, a read-write scope will do as well.
6839 pub fn add_scope<St>(mut self, scope: St) -> ChangeGetStartPageTokenCall<'a, C>
6840 where
6841 St: AsRef<str>,
6842 {
6843 self._scopes.insert(String::from(scope.as_ref()));
6844 self
6845 }
6846 /// Identifies the authorization scope(s) for the method you are building.
6847 ///
6848 /// See [`Self::add_scope()`] for details.
6849 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeGetStartPageTokenCall<'a, C>
6850 where
6851 I: IntoIterator<Item = St>,
6852 St: AsRef<str>,
6853 {
6854 self._scopes
6855 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6856 self
6857 }
6858
6859 /// Removes all scopes, and no default scope will be used either.
6860 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6861 /// for details).
6862 pub fn clear_scopes(mut self) -> ChangeGetStartPageTokenCall<'a, C> {
6863 self._scopes.clear();
6864 self
6865 }
6866}
6867
6868/// Lists the changes for a user or shared drive.
6869///
6870/// A builder for the *list* method supported by a *change* resource.
6871/// It is not used directly, but through a [`ChangeMethods`] instance.
6872///
6873/// # Example
6874///
6875/// Instantiate a resource method builder
6876///
6877/// ```test_harness,no_run
6878/// # extern crate hyper;
6879/// # extern crate hyper_rustls;
6880/// # extern crate google_drive2 as drive2;
6881/// # async fn dox() {
6882/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6883///
6884/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6885/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6886/// # .with_native_roots()
6887/// # .unwrap()
6888/// # .https_only()
6889/// # .enable_http2()
6890/// # .build();
6891///
6892/// # let executor = hyper_util::rt::TokioExecutor::new();
6893/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6894/// # secret,
6895/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6896/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6897/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6898/// # ),
6899/// # ).build().await.unwrap();
6900///
6901/// # let client = hyper_util::client::legacy::Client::builder(
6902/// # hyper_util::rt::TokioExecutor::new()
6903/// # )
6904/// # .build(
6905/// # hyper_rustls::HttpsConnectorBuilder::new()
6906/// # .with_native_roots()
6907/// # .unwrap()
6908/// # .https_or_http()
6909/// # .enable_http2()
6910/// # .build()
6911/// # );
6912/// # let mut hub = DriveHub::new(client, auth);
6913/// // You can configure optional parameters by calling the respective setters at will, and
6914/// // execute the final call using `doit()`.
6915/// // Values shown here are possibly random and not representative !
6916/// let result = hub.changes().list()
6917/// .team_drive_id("tempor")
6918/// .supports_team_drives(true)
6919/// .supports_all_drives(true)
6920/// .start_change_id(-68)
6921/// .spaces("sed")
6922/// .page_token("no")
6923/// .max_results(-85)
6924/// .include_team_drive_items(false)
6925/// .include_subscribed(false)
6926/// .include_permissions_for_view("no")
6927/// .include_labels("nonumy")
6928/// .include_items_from_all_drives(false)
6929/// .include_deleted(true)
6930/// .include_corpus_removals(true)
6931/// .drive_id("sadipscing")
6932/// .doit().await;
6933/// # }
6934/// ```
6935pub struct ChangeListCall<'a, C>
6936where
6937 C: 'a,
6938{
6939 hub: &'a DriveHub<C>,
6940 _team_drive_id: Option<String>,
6941 _supports_team_drives: Option<bool>,
6942 _supports_all_drives: Option<bool>,
6943 _start_change_id: Option<i64>,
6944 _spaces: Option<String>,
6945 _page_token: Option<String>,
6946 _max_results: Option<i32>,
6947 _include_team_drive_items: Option<bool>,
6948 _include_subscribed: Option<bool>,
6949 _include_permissions_for_view: Option<String>,
6950 _include_labels: Option<String>,
6951 _include_items_from_all_drives: Option<bool>,
6952 _include_deleted: Option<bool>,
6953 _include_corpus_removals: Option<bool>,
6954 _drive_id: Option<String>,
6955 _delegate: Option<&'a mut dyn common::Delegate>,
6956 _additional_params: HashMap<String, String>,
6957 _scopes: BTreeSet<String>,
6958}
6959
6960impl<'a, C> common::CallBuilder for ChangeListCall<'a, C> {}
6961
6962impl<'a, C> ChangeListCall<'a, C>
6963where
6964 C: common::Connector,
6965{
6966 /// Perform the operation you have build so far.
6967 pub async fn doit(mut self) -> common::Result<(common::Response, ChangeList)> {
6968 use std::borrow::Cow;
6969 use std::io::{Read, Seek};
6970
6971 use common::{url::Params, ToParts};
6972 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6973
6974 let mut dd = common::DefaultDelegate;
6975 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6976 dlg.begin(common::MethodInfo {
6977 id: "drive.changes.list",
6978 http_method: hyper::Method::GET,
6979 });
6980
6981 for &field in [
6982 "alt",
6983 "teamDriveId",
6984 "supportsTeamDrives",
6985 "supportsAllDrives",
6986 "startChangeId",
6987 "spaces",
6988 "pageToken",
6989 "maxResults",
6990 "includeTeamDriveItems",
6991 "includeSubscribed",
6992 "includePermissionsForView",
6993 "includeLabels",
6994 "includeItemsFromAllDrives",
6995 "includeDeleted",
6996 "includeCorpusRemovals",
6997 "driveId",
6998 ]
6999 .iter()
7000 {
7001 if self._additional_params.contains_key(field) {
7002 dlg.finished(false);
7003 return Err(common::Error::FieldClash(field));
7004 }
7005 }
7006
7007 let mut params = Params::with_capacity(17 + self._additional_params.len());
7008 if let Some(value) = self._team_drive_id.as_ref() {
7009 params.push("teamDriveId", value);
7010 }
7011 if let Some(value) = self._supports_team_drives.as_ref() {
7012 params.push("supportsTeamDrives", value.to_string());
7013 }
7014 if let Some(value) = self._supports_all_drives.as_ref() {
7015 params.push("supportsAllDrives", value.to_string());
7016 }
7017 if let Some(value) = self._start_change_id.as_ref() {
7018 params.push("startChangeId", value.to_string());
7019 }
7020 if let Some(value) = self._spaces.as_ref() {
7021 params.push("spaces", value);
7022 }
7023 if let Some(value) = self._page_token.as_ref() {
7024 params.push("pageToken", value);
7025 }
7026 if let Some(value) = self._max_results.as_ref() {
7027 params.push("maxResults", value.to_string());
7028 }
7029 if let Some(value) = self._include_team_drive_items.as_ref() {
7030 params.push("includeTeamDriveItems", value.to_string());
7031 }
7032 if let Some(value) = self._include_subscribed.as_ref() {
7033 params.push("includeSubscribed", value.to_string());
7034 }
7035 if let Some(value) = self._include_permissions_for_view.as_ref() {
7036 params.push("includePermissionsForView", value);
7037 }
7038 if let Some(value) = self._include_labels.as_ref() {
7039 params.push("includeLabels", value);
7040 }
7041 if let Some(value) = self._include_items_from_all_drives.as_ref() {
7042 params.push("includeItemsFromAllDrives", value.to_string());
7043 }
7044 if let Some(value) = self._include_deleted.as_ref() {
7045 params.push("includeDeleted", value.to_string());
7046 }
7047 if let Some(value) = self._include_corpus_removals.as_ref() {
7048 params.push("includeCorpusRemovals", value.to_string());
7049 }
7050 if let Some(value) = self._drive_id.as_ref() {
7051 params.push("driveId", value);
7052 }
7053
7054 params.extend(self._additional_params.iter());
7055
7056 params.push("alt", "json");
7057 let mut url = self.hub._base_url.clone() + "changes";
7058 if self._scopes.is_empty() {
7059 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
7060 }
7061
7062 let url = params.parse_with_url(&url);
7063
7064 loop {
7065 let token = match self
7066 .hub
7067 .auth
7068 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7069 .await
7070 {
7071 Ok(token) => token,
7072 Err(e) => match dlg.token(e) {
7073 Ok(token) => token,
7074 Err(e) => {
7075 dlg.finished(false);
7076 return Err(common::Error::MissingToken(e));
7077 }
7078 },
7079 };
7080 let mut req_result = {
7081 let client = &self.hub.client;
7082 dlg.pre_request();
7083 let mut req_builder = hyper::Request::builder()
7084 .method(hyper::Method::GET)
7085 .uri(url.as_str())
7086 .header(USER_AGENT, self.hub._user_agent.clone());
7087
7088 if let Some(token) = token.as_ref() {
7089 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7090 }
7091
7092 let request = req_builder
7093 .header(CONTENT_LENGTH, 0_u64)
7094 .body(common::to_body::<String>(None));
7095
7096 client.request(request.unwrap()).await
7097 };
7098
7099 match req_result {
7100 Err(err) => {
7101 if let common::Retry::After(d) = dlg.http_error(&err) {
7102 sleep(d).await;
7103 continue;
7104 }
7105 dlg.finished(false);
7106 return Err(common::Error::HttpError(err));
7107 }
7108 Ok(res) => {
7109 let (mut parts, body) = res.into_parts();
7110 let mut body = common::Body::new(body);
7111 if !parts.status.is_success() {
7112 let bytes = common::to_bytes(body).await.unwrap_or_default();
7113 let error = serde_json::from_str(&common::to_string(&bytes));
7114 let response = common::to_response(parts, bytes.into());
7115
7116 if let common::Retry::After(d) =
7117 dlg.http_failure(&response, error.as_ref().ok())
7118 {
7119 sleep(d).await;
7120 continue;
7121 }
7122
7123 dlg.finished(false);
7124
7125 return Err(match error {
7126 Ok(value) => common::Error::BadRequest(value),
7127 _ => common::Error::Failure(response),
7128 });
7129 }
7130 let response = {
7131 let bytes = common::to_bytes(body).await.unwrap_or_default();
7132 let encoded = common::to_string(&bytes);
7133 match serde_json::from_str(&encoded) {
7134 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7135 Err(error) => {
7136 dlg.response_json_decode_error(&encoded, &error);
7137 return Err(common::Error::JsonDecodeError(
7138 encoded.to_string(),
7139 error,
7140 ));
7141 }
7142 }
7143 };
7144
7145 dlg.finished(true);
7146 return Ok(response);
7147 }
7148 }
7149 }
7150 }
7151
7152 /// Deprecated: Use `driveId` instead.
7153 ///
7154 /// Sets the *team drive id* query property to the given value.
7155 pub fn team_drive_id(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7156 self._team_drive_id = Some(new_value.to_string());
7157 self
7158 }
7159 /// Deprecated: Use `supportsAllDrives` instead.
7160 ///
7161 /// Sets the *supports team drives* query property to the given value.
7162 pub fn supports_team_drives(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7163 self._supports_team_drives = Some(new_value);
7164 self
7165 }
7166 /// Whether the requesting application supports both My Drives and shared drives.
7167 ///
7168 /// Sets the *supports all drives* query property to the given value.
7169 pub fn supports_all_drives(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7170 self._supports_all_drives = Some(new_value);
7171 self
7172 }
7173 /// Deprecated: Use `pageToken` instead.
7174 ///
7175 /// Sets the *start change id* query property to the given value.
7176 pub fn start_change_id(mut self, new_value: i64) -> ChangeListCall<'a, C> {
7177 self._start_change_id = Some(new_value);
7178 self
7179 }
7180 /// A comma-separated list of spaces to query. Supported values are `drive`, `appDataFolder` and `photos`.
7181 ///
7182 /// Sets the *spaces* query property to the given value.
7183 pub fn spaces(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7184 self._spaces = Some(new_value.to_string());
7185 self
7186 }
7187 /// 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.
7188 ///
7189 /// Sets the *page token* query property to the given value.
7190 pub fn page_token(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7191 self._page_token = Some(new_value.to_string());
7192 self
7193 }
7194 /// Maximum number of changes to return.
7195 ///
7196 /// Sets the *max results* query property to the given value.
7197 pub fn max_results(mut self, new_value: i32) -> ChangeListCall<'a, C> {
7198 self._max_results = Some(new_value);
7199 self
7200 }
7201 /// Deprecated: Use `includeItemsFromAllDrives` instead.
7202 ///
7203 /// Sets the *include team drive items* query property to the given value.
7204 pub fn include_team_drive_items(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7205 self._include_team_drive_items = Some(new_value);
7206 self
7207 }
7208 /// 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.
7209 ///
7210 /// Sets the *include subscribed* query property to the given value.
7211 pub fn include_subscribed(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7212 self._include_subscribed = Some(new_value);
7213 self
7214 }
7215 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
7216 ///
7217 /// Sets the *include permissions for view* query property to the given value.
7218 pub fn include_permissions_for_view(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7219 self._include_permissions_for_view = Some(new_value.to_string());
7220 self
7221 }
7222 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
7223 ///
7224 /// Sets the *include labels* query property to the given value.
7225 pub fn include_labels(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7226 self._include_labels = Some(new_value.to_string());
7227 self
7228 }
7229 /// Whether both My Drive and shared drive items should be included in results.
7230 ///
7231 /// Sets the *include items from all drives* query property to the given value.
7232 pub fn include_items_from_all_drives(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7233 self._include_items_from_all_drives = Some(new_value);
7234 self
7235 }
7236 /// Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.
7237 ///
7238 /// Sets the *include deleted* query property to the given value.
7239 pub fn include_deleted(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7240 self._include_deleted = Some(new_value);
7241 self
7242 }
7243 /// 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.
7244 ///
7245 /// Sets the *include corpus removals* query property to the given value.
7246 pub fn include_corpus_removals(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7247 self._include_corpus_removals = Some(new_value);
7248 self
7249 }
7250 /// 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.
7251 ///
7252 /// Sets the *drive id* query property to the given value.
7253 pub fn drive_id(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7254 self._drive_id = Some(new_value.to_string());
7255 self
7256 }
7257 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7258 /// while executing the actual API request.
7259 ///
7260 /// ````text
7261 /// It should be used to handle progress information, and to implement a certain level of resilience.
7262 /// ````
7263 ///
7264 /// Sets the *delegate* property to the given value.
7265 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeListCall<'a, C> {
7266 self._delegate = Some(new_value);
7267 self
7268 }
7269
7270 /// Set any additional parameter of the query string used in the request.
7271 /// It should be used to set parameters which are not yet available through their own
7272 /// setters.
7273 ///
7274 /// Please note that this method must not be used to set any of the known parameters
7275 /// which have their own setter method. If done anyway, the request will fail.
7276 ///
7277 /// # Additional Parameters
7278 ///
7279 /// * *$.xgafv* (query-string) - V1 error format.
7280 /// * *access_token* (query-string) - OAuth access token.
7281 /// * *alt* (query-string) - Data format for response.
7282 /// * *callback* (query-string) - JSONP
7283 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7284 /// * *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.
7285 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7286 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7287 /// * *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.
7288 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7289 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7290 pub fn param<T>(mut self, name: T, value: T) -> ChangeListCall<'a, C>
7291 where
7292 T: AsRef<str>,
7293 {
7294 self._additional_params
7295 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7296 self
7297 }
7298
7299 /// Identifies the authorization scope for the method you are building.
7300 ///
7301 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7302 /// [`Scope::AppReadonly`].
7303 ///
7304 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7305 /// tokens for more than one scope.
7306 ///
7307 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7308 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7309 /// sufficient, a read-write scope will do as well.
7310 pub fn add_scope<St>(mut self, scope: St) -> ChangeListCall<'a, C>
7311 where
7312 St: AsRef<str>,
7313 {
7314 self._scopes.insert(String::from(scope.as_ref()));
7315 self
7316 }
7317 /// Identifies the authorization scope(s) for the method you are building.
7318 ///
7319 /// See [`Self::add_scope()`] for details.
7320 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeListCall<'a, C>
7321 where
7322 I: IntoIterator<Item = St>,
7323 St: AsRef<str>,
7324 {
7325 self._scopes
7326 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7327 self
7328 }
7329
7330 /// Removes all scopes, and no default scope will be used either.
7331 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7332 /// for details).
7333 pub fn clear_scopes(mut self) -> ChangeListCall<'a, C> {
7334 self._scopes.clear();
7335 self
7336 }
7337}
7338
7339/// Subscribe to changes for a user.
7340///
7341/// A builder for the *watch* method supported by a *change* resource.
7342/// It is not used directly, but through a [`ChangeMethods`] instance.
7343///
7344/// # Example
7345///
7346/// Instantiate a resource method builder
7347///
7348/// ```test_harness,no_run
7349/// # extern crate hyper;
7350/// # extern crate hyper_rustls;
7351/// # extern crate google_drive2 as drive2;
7352/// use drive2::api::Channel;
7353/// # async fn dox() {
7354/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7355///
7356/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7357/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7358/// # .with_native_roots()
7359/// # .unwrap()
7360/// # .https_only()
7361/// # .enable_http2()
7362/// # .build();
7363///
7364/// # let executor = hyper_util::rt::TokioExecutor::new();
7365/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7366/// # secret,
7367/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7368/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7369/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7370/// # ),
7371/// # ).build().await.unwrap();
7372///
7373/// # let client = hyper_util::client::legacy::Client::builder(
7374/// # hyper_util::rt::TokioExecutor::new()
7375/// # )
7376/// # .build(
7377/// # hyper_rustls::HttpsConnectorBuilder::new()
7378/// # .with_native_roots()
7379/// # .unwrap()
7380/// # .https_or_http()
7381/// # .enable_http2()
7382/// # .build()
7383/// # );
7384/// # let mut hub = DriveHub::new(client, auth);
7385/// // As the method needs a request, you would usually fill it with the desired information
7386/// // into the respective structure. Some of the parts shown here might not be applicable !
7387/// // Values shown here are possibly random and not representative !
7388/// let mut req = Channel::default();
7389///
7390/// // You can configure optional parameters by calling the respective setters at will, and
7391/// // execute the final call using `doit()`.
7392/// // Values shown here are possibly random and not representative !
7393/// let result = hub.changes().watch(req)
7394/// .team_drive_id("erat")
7395/// .supports_team_drives(false)
7396/// .supports_all_drives(true)
7397/// .start_change_id(-57)
7398/// .spaces("et")
7399/// .page_token("sea")
7400/// .max_results(-96)
7401/// .include_team_drive_items(true)
7402/// .include_subscribed(true)
7403/// .include_permissions_for_view("est")
7404/// .include_labels("aliquyam")
7405/// .include_items_from_all_drives(false)
7406/// .include_deleted(true)
7407/// .include_corpus_removals(true)
7408/// .drive_id("sit")
7409/// .doit().await;
7410/// # }
7411/// ```
7412pub struct ChangeWatchCall<'a, C>
7413where
7414 C: 'a,
7415{
7416 hub: &'a DriveHub<C>,
7417 _request: Channel,
7418 _team_drive_id: Option<String>,
7419 _supports_team_drives: Option<bool>,
7420 _supports_all_drives: Option<bool>,
7421 _start_change_id: Option<i64>,
7422 _spaces: Option<String>,
7423 _page_token: Option<String>,
7424 _max_results: Option<i32>,
7425 _include_team_drive_items: Option<bool>,
7426 _include_subscribed: Option<bool>,
7427 _include_permissions_for_view: Option<String>,
7428 _include_labels: Option<String>,
7429 _include_items_from_all_drives: Option<bool>,
7430 _include_deleted: Option<bool>,
7431 _include_corpus_removals: Option<bool>,
7432 _drive_id: Option<String>,
7433 _delegate: Option<&'a mut dyn common::Delegate>,
7434 _additional_params: HashMap<String, String>,
7435 _scopes: BTreeSet<String>,
7436}
7437
7438impl<'a, C> common::CallBuilder for ChangeWatchCall<'a, C> {}
7439
7440impl<'a, C> ChangeWatchCall<'a, C>
7441where
7442 C: common::Connector,
7443{
7444 /// Perform the operation you have build so far.
7445 pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
7446 use std::borrow::Cow;
7447 use std::io::{Read, Seek};
7448
7449 use common::{url::Params, ToParts};
7450 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7451
7452 let mut dd = common::DefaultDelegate;
7453 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7454 dlg.begin(common::MethodInfo {
7455 id: "drive.changes.watch",
7456 http_method: hyper::Method::POST,
7457 });
7458
7459 for &field in [
7460 "alt",
7461 "teamDriveId",
7462 "supportsTeamDrives",
7463 "supportsAllDrives",
7464 "startChangeId",
7465 "spaces",
7466 "pageToken",
7467 "maxResults",
7468 "includeTeamDriveItems",
7469 "includeSubscribed",
7470 "includePermissionsForView",
7471 "includeLabels",
7472 "includeItemsFromAllDrives",
7473 "includeDeleted",
7474 "includeCorpusRemovals",
7475 "driveId",
7476 ]
7477 .iter()
7478 {
7479 if self._additional_params.contains_key(field) {
7480 dlg.finished(false);
7481 return Err(common::Error::FieldClash(field));
7482 }
7483 }
7484
7485 let mut params = Params::with_capacity(18 + self._additional_params.len());
7486 if let Some(value) = self._team_drive_id.as_ref() {
7487 params.push("teamDriveId", value);
7488 }
7489 if let Some(value) = self._supports_team_drives.as_ref() {
7490 params.push("supportsTeamDrives", value.to_string());
7491 }
7492 if let Some(value) = self._supports_all_drives.as_ref() {
7493 params.push("supportsAllDrives", value.to_string());
7494 }
7495 if let Some(value) = self._start_change_id.as_ref() {
7496 params.push("startChangeId", value.to_string());
7497 }
7498 if let Some(value) = self._spaces.as_ref() {
7499 params.push("spaces", value);
7500 }
7501 if let Some(value) = self._page_token.as_ref() {
7502 params.push("pageToken", value);
7503 }
7504 if let Some(value) = self._max_results.as_ref() {
7505 params.push("maxResults", value.to_string());
7506 }
7507 if let Some(value) = self._include_team_drive_items.as_ref() {
7508 params.push("includeTeamDriveItems", value.to_string());
7509 }
7510 if let Some(value) = self._include_subscribed.as_ref() {
7511 params.push("includeSubscribed", value.to_string());
7512 }
7513 if let Some(value) = self._include_permissions_for_view.as_ref() {
7514 params.push("includePermissionsForView", value);
7515 }
7516 if let Some(value) = self._include_labels.as_ref() {
7517 params.push("includeLabels", value);
7518 }
7519 if let Some(value) = self._include_items_from_all_drives.as_ref() {
7520 params.push("includeItemsFromAllDrives", value.to_string());
7521 }
7522 if let Some(value) = self._include_deleted.as_ref() {
7523 params.push("includeDeleted", value.to_string());
7524 }
7525 if let Some(value) = self._include_corpus_removals.as_ref() {
7526 params.push("includeCorpusRemovals", value.to_string());
7527 }
7528 if let Some(value) = self._drive_id.as_ref() {
7529 params.push("driveId", value);
7530 }
7531
7532 params.extend(self._additional_params.iter());
7533
7534 params.push("alt", "json");
7535 let mut url = self.hub._base_url.clone() + "changes/watch";
7536 if self._scopes.is_empty() {
7537 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
7538 }
7539
7540 let url = params.parse_with_url(&url);
7541
7542 let mut json_mime_type = mime::APPLICATION_JSON;
7543 let mut request_value_reader = {
7544 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7545 common::remove_json_null_values(&mut value);
7546 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7547 serde_json::to_writer(&mut dst, &value).unwrap();
7548 dst
7549 };
7550 let request_size = request_value_reader
7551 .seek(std::io::SeekFrom::End(0))
7552 .unwrap();
7553 request_value_reader
7554 .seek(std::io::SeekFrom::Start(0))
7555 .unwrap();
7556
7557 loop {
7558 let token = match self
7559 .hub
7560 .auth
7561 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7562 .await
7563 {
7564 Ok(token) => token,
7565 Err(e) => match dlg.token(e) {
7566 Ok(token) => token,
7567 Err(e) => {
7568 dlg.finished(false);
7569 return Err(common::Error::MissingToken(e));
7570 }
7571 },
7572 };
7573 request_value_reader
7574 .seek(std::io::SeekFrom::Start(0))
7575 .unwrap();
7576 let mut req_result = {
7577 let client = &self.hub.client;
7578 dlg.pre_request();
7579 let mut req_builder = hyper::Request::builder()
7580 .method(hyper::Method::POST)
7581 .uri(url.as_str())
7582 .header(USER_AGENT, self.hub._user_agent.clone());
7583
7584 if let Some(token) = token.as_ref() {
7585 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7586 }
7587
7588 let request = req_builder
7589 .header(CONTENT_TYPE, json_mime_type.to_string())
7590 .header(CONTENT_LENGTH, request_size as u64)
7591 .body(common::to_body(
7592 request_value_reader.get_ref().clone().into(),
7593 ));
7594
7595 client.request(request.unwrap()).await
7596 };
7597
7598 match req_result {
7599 Err(err) => {
7600 if let common::Retry::After(d) = dlg.http_error(&err) {
7601 sleep(d).await;
7602 continue;
7603 }
7604 dlg.finished(false);
7605 return Err(common::Error::HttpError(err));
7606 }
7607 Ok(res) => {
7608 let (mut parts, body) = res.into_parts();
7609 let mut body = common::Body::new(body);
7610 if !parts.status.is_success() {
7611 let bytes = common::to_bytes(body).await.unwrap_or_default();
7612 let error = serde_json::from_str(&common::to_string(&bytes));
7613 let response = common::to_response(parts, bytes.into());
7614
7615 if let common::Retry::After(d) =
7616 dlg.http_failure(&response, error.as_ref().ok())
7617 {
7618 sleep(d).await;
7619 continue;
7620 }
7621
7622 dlg.finished(false);
7623
7624 return Err(match error {
7625 Ok(value) => common::Error::BadRequest(value),
7626 _ => common::Error::Failure(response),
7627 });
7628 }
7629 let response = {
7630 let bytes = common::to_bytes(body).await.unwrap_or_default();
7631 let encoded = common::to_string(&bytes);
7632 match serde_json::from_str(&encoded) {
7633 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7634 Err(error) => {
7635 dlg.response_json_decode_error(&encoded, &error);
7636 return Err(common::Error::JsonDecodeError(
7637 encoded.to_string(),
7638 error,
7639 ));
7640 }
7641 }
7642 };
7643
7644 dlg.finished(true);
7645 return Ok(response);
7646 }
7647 }
7648 }
7649 }
7650
7651 ///
7652 /// Sets the *request* property to the given value.
7653 ///
7654 /// Even though the property as already been set when instantiating this call,
7655 /// we provide this method for API completeness.
7656 pub fn request(mut self, new_value: Channel) -> ChangeWatchCall<'a, C> {
7657 self._request = new_value;
7658 self
7659 }
7660 /// Deprecated: Use `driveId` instead.
7661 ///
7662 /// Sets the *team drive id* query property to the given value.
7663 pub fn team_drive_id(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
7664 self._team_drive_id = Some(new_value.to_string());
7665 self
7666 }
7667 /// Deprecated: Use `supportsAllDrives` instead.
7668 ///
7669 /// Sets the *supports team drives* query property to the given value.
7670 pub fn supports_team_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
7671 self._supports_team_drives = Some(new_value);
7672 self
7673 }
7674 /// Whether the requesting application supports both My Drives and shared drives.
7675 ///
7676 /// Sets the *supports all drives* query property to the given value.
7677 pub fn supports_all_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
7678 self._supports_all_drives = Some(new_value);
7679 self
7680 }
7681 /// Deprecated: Use `pageToken` instead.
7682 ///
7683 /// Sets the *start change id* query property to the given value.
7684 pub fn start_change_id(mut self, new_value: i64) -> ChangeWatchCall<'a, C> {
7685 self._start_change_id = Some(new_value);
7686 self
7687 }
7688 /// A comma-separated list of spaces to query. Supported values are `drive`, `appDataFolder` and `photos`.
7689 ///
7690 /// Sets the *spaces* query property to the given value.
7691 pub fn spaces(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
7692 self._spaces = Some(new_value.to_string());
7693 self
7694 }
7695 /// 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.
7696 ///
7697 /// Sets the *page token* query property to the given value.
7698 pub fn page_token(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
7699 self._page_token = Some(new_value.to_string());
7700 self
7701 }
7702 /// Maximum number of changes to return.
7703 ///
7704 /// Sets the *max results* query property to the given value.
7705 pub fn max_results(mut self, new_value: i32) -> ChangeWatchCall<'a, C> {
7706 self._max_results = Some(new_value);
7707 self
7708 }
7709 /// Deprecated: Use `includeItemsFromAllDrives` instead.
7710 ///
7711 /// Sets the *include team drive items* query property to the given value.
7712 pub fn include_team_drive_items(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
7713 self._include_team_drive_items = Some(new_value);
7714 self
7715 }
7716 /// 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.
7717 ///
7718 /// Sets the *include subscribed* query property to the given value.
7719 pub fn include_subscribed(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
7720 self._include_subscribed = Some(new_value);
7721 self
7722 }
7723 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
7724 ///
7725 /// Sets the *include permissions for view* query property to the given value.
7726 pub fn include_permissions_for_view(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
7727 self._include_permissions_for_view = Some(new_value.to_string());
7728 self
7729 }
7730 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
7731 ///
7732 /// Sets the *include labels* query property to the given value.
7733 pub fn include_labels(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
7734 self._include_labels = Some(new_value.to_string());
7735 self
7736 }
7737 /// Whether both My Drive and shared drive items should be included in results.
7738 ///
7739 /// Sets the *include items from all drives* query property to the given value.
7740 pub fn include_items_from_all_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
7741 self._include_items_from_all_drives = Some(new_value);
7742 self
7743 }
7744 /// Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.
7745 ///
7746 /// Sets the *include deleted* query property to the given value.
7747 pub fn include_deleted(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
7748 self._include_deleted = Some(new_value);
7749 self
7750 }
7751 /// 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.
7752 ///
7753 /// Sets the *include corpus removals* query property to the given value.
7754 pub fn include_corpus_removals(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
7755 self._include_corpus_removals = Some(new_value);
7756 self
7757 }
7758 /// 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.
7759 ///
7760 /// Sets the *drive id* query property to the given value.
7761 pub fn drive_id(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
7762 self._drive_id = Some(new_value.to_string());
7763 self
7764 }
7765 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7766 /// while executing the actual API request.
7767 ///
7768 /// ````text
7769 /// It should be used to handle progress information, and to implement a certain level of resilience.
7770 /// ````
7771 ///
7772 /// Sets the *delegate* property to the given value.
7773 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeWatchCall<'a, C> {
7774 self._delegate = Some(new_value);
7775 self
7776 }
7777
7778 /// Set any additional parameter of the query string used in the request.
7779 /// It should be used to set parameters which are not yet available through their own
7780 /// setters.
7781 ///
7782 /// Please note that this method must not be used to set any of the known parameters
7783 /// which have their own setter method. If done anyway, the request will fail.
7784 ///
7785 /// # Additional Parameters
7786 ///
7787 /// * *$.xgafv* (query-string) - V1 error format.
7788 /// * *access_token* (query-string) - OAuth access token.
7789 /// * *alt* (query-string) - Data format for response.
7790 /// * *callback* (query-string) - JSONP
7791 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7792 /// * *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.
7793 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7794 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7795 /// * *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.
7796 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7797 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7798 pub fn param<T>(mut self, name: T, value: T) -> ChangeWatchCall<'a, C>
7799 where
7800 T: AsRef<str>,
7801 {
7802 self._additional_params
7803 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7804 self
7805 }
7806
7807 /// Identifies the authorization scope for the method you are building.
7808 ///
7809 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7810 /// [`Scope::AppReadonly`].
7811 ///
7812 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7813 /// tokens for more than one scope.
7814 ///
7815 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7816 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7817 /// sufficient, a read-write scope will do as well.
7818 pub fn add_scope<St>(mut self, scope: St) -> ChangeWatchCall<'a, C>
7819 where
7820 St: AsRef<str>,
7821 {
7822 self._scopes.insert(String::from(scope.as_ref()));
7823 self
7824 }
7825 /// Identifies the authorization scope(s) for the method you are building.
7826 ///
7827 /// See [`Self::add_scope()`] for details.
7828 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeWatchCall<'a, C>
7829 where
7830 I: IntoIterator<Item = St>,
7831 St: AsRef<str>,
7832 {
7833 self._scopes
7834 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7835 self
7836 }
7837
7838 /// Removes all scopes, and no default scope will be used either.
7839 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7840 /// for details).
7841 pub fn clear_scopes(mut self) -> ChangeWatchCall<'a, C> {
7842 self._scopes.clear();
7843 self
7844 }
7845}
7846
7847/// Stops watching resources through this channel.
7848///
7849/// A builder for the *stop* method supported by a *channel* resource.
7850/// It is not used directly, but through a [`ChannelMethods`] instance.
7851///
7852/// # Example
7853///
7854/// Instantiate a resource method builder
7855///
7856/// ```test_harness,no_run
7857/// # extern crate hyper;
7858/// # extern crate hyper_rustls;
7859/// # extern crate google_drive2 as drive2;
7860/// use drive2::api::Channel;
7861/// # async fn dox() {
7862/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7863///
7864/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7865/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7866/// # .with_native_roots()
7867/// # .unwrap()
7868/// # .https_only()
7869/// # .enable_http2()
7870/// # .build();
7871///
7872/// # let executor = hyper_util::rt::TokioExecutor::new();
7873/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7874/// # secret,
7875/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7876/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7877/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7878/// # ),
7879/// # ).build().await.unwrap();
7880///
7881/// # let client = hyper_util::client::legacy::Client::builder(
7882/// # hyper_util::rt::TokioExecutor::new()
7883/// # )
7884/// # .build(
7885/// # hyper_rustls::HttpsConnectorBuilder::new()
7886/// # .with_native_roots()
7887/// # .unwrap()
7888/// # .https_or_http()
7889/// # .enable_http2()
7890/// # .build()
7891/// # );
7892/// # let mut hub = DriveHub::new(client, auth);
7893/// // As the method needs a request, you would usually fill it with the desired information
7894/// // into the respective structure. Some of the parts shown here might not be applicable !
7895/// // Values shown here are possibly random and not representative !
7896/// let mut req = Channel::default();
7897///
7898/// // You can configure optional parameters by calling the respective setters at will, and
7899/// // execute the final call using `doit()`.
7900/// // Values shown here are possibly random and not representative !
7901/// let result = hub.channels().stop(req)
7902/// .doit().await;
7903/// # }
7904/// ```
7905pub struct ChannelStopCall<'a, C>
7906where
7907 C: 'a,
7908{
7909 hub: &'a DriveHub<C>,
7910 _request: Channel,
7911 _delegate: Option<&'a mut dyn common::Delegate>,
7912 _additional_params: HashMap<String, String>,
7913 _scopes: BTreeSet<String>,
7914}
7915
7916impl<'a, C> common::CallBuilder for ChannelStopCall<'a, C> {}
7917
7918impl<'a, C> ChannelStopCall<'a, C>
7919where
7920 C: common::Connector,
7921{
7922 /// Perform the operation you have build so far.
7923 pub async fn doit(mut self) -> common::Result<common::Response> {
7924 use std::borrow::Cow;
7925 use std::io::{Read, Seek};
7926
7927 use common::{url::Params, ToParts};
7928 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7929
7930 let mut dd = common::DefaultDelegate;
7931 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7932 dlg.begin(common::MethodInfo {
7933 id: "drive.channels.stop",
7934 http_method: hyper::Method::POST,
7935 });
7936
7937 for &field in [].iter() {
7938 if self._additional_params.contains_key(field) {
7939 dlg.finished(false);
7940 return Err(common::Error::FieldClash(field));
7941 }
7942 }
7943
7944 let mut params = Params::with_capacity(2 + self._additional_params.len());
7945
7946 params.extend(self._additional_params.iter());
7947
7948 let mut url = self.hub._base_url.clone() + "channels/stop";
7949 if self._scopes.is_empty() {
7950 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
7951 }
7952
7953 let url = params.parse_with_url(&url);
7954
7955 let mut json_mime_type = mime::APPLICATION_JSON;
7956 let mut request_value_reader = {
7957 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7958 common::remove_json_null_values(&mut value);
7959 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7960 serde_json::to_writer(&mut dst, &value).unwrap();
7961 dst
7962 };
7963 let request_size = request_value_reader
7964 .seek(std::io::SeekFrom::End(0))
7965 .unwrap();
7966 request_value_reader
7967 .seek(std::io::SeekFrom::Start(0))
7968 .unwrap();
7969
7970 loop {
7971 let token = match self
7972 .hub
7973 .auth
7974 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7975 .await
7976 {
7977 Ok(token) => token,
7978 Err(e) => match dlg.token(e) {
7979 Ok(token) => token,
7980 Err(e) => {
7981 dlg.finished(false);
7982 return Err(common::Error::MissingToken(e));
7983 }
7984 },
7985 };
7986 request_value_reader
7987 .seek(std::io::SeekFrom::Start(0))
7988 .unwrap();
7989 let mut req_result = {
7990 let client = &self.hub.client;
7991 dlg.pre_request();
7992 let mut req_builder = hyper::Request::builder()
7993 .method(hyper::Method::POST)
7994 .uri(url.as_str())
7995 .header(USER_AGENT, self.hub._user_agent.clone());
7996
7997 if let Some(token) = token.as_ref() {
7998 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7999 }
8000
8001 let request = req_builder
8002 .header(CONTENT_TYPE, json_mime_type.to_string())
8003 .header(CONTENT_LENGTH, request_size as u64)
8004 .body(common::to_body(
8005 request_value_reader.get_ref().clone().into(),
8006 ));
8007
8008 client.request(request.unwrap()).await
8009 };
8010
8011 match req_result {
8012 Err(err) => {
8013 if let common::Retry::After(d) = dlg.http_error(&err) {
8014 sleep(d).await;
8015 continue;
8016 }
8017 dlg.finished(false);
8018 return Err(common::Error::HttpError(err));
8019 }
8020 Ok(res) => {
8021 let (mut parts, body) = res.into_parts();
8022 let mut body = common::Body::new(body);
8023 if !parts.status.is_success() {
8024 let bytes = common::to_bytes(body).await.unwrap_or_default();
8025 let error = serde_json::from_str(&common::to_string(&bytes));
8026 let response = common::to_response(parts, bytes.into());
8027
8028 if let common::Retry::After(d) =
8029 dlg.http_failure(&response, error.as_ref().ok())
8030 {
8031 sleep(d).await;
8032 continue;
8033 }
8034
8035 dlg.finished(false);
8036
8037 return Err(match error {
8038 Ok(value) => common::Error::BadRequest(value),
8039 _ => common::Error::Failure(response),
8040 });
8041 }
8042 let response = common::Response::from_parts(parts, body);
8043
8044 dlg.finished(true);
8045 return Ok(response);
8046 }
8047 }
8048 }
8049 }
8050
8051 ///
8052 /// Sets the *request* property to the given value.
8053 ///
8054 /// Even though the property as already been set when instantiating this call,
8055 /// we provide this method for API completeness.
8056 pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C> {
8057 self._request = new_value;
8058 self
8059 }
8060 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8061 /// while executing the actual API request.
8062 ///
8063 /// ````text
8064 /// It should be used to handle progress information, and to implement a certain level of resilience.
8065 /// ````
8066 ///
8067 /// Sets the *delegate* property to the given value.
8068 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChannelStopCall<'a, C> {
8069 self._delegate = Some(new_value);
8070 self
8071 }
8072
8073 /// Set any additional parameter of the query string used in the request.
8074 /// It should be used to set parameters which are not yet available through their own
8075 /// setters.
8076 ///
8077 /// Please note that this method must not be used to set any of the known parameters
8078 /// which have their own setter method. If done anyway, the request will fail.
8079 ///
8080 /// # Additional Parameters
8081 ///
8082 /// * *$.xgafv* (query-string) - V1 error format.
8083 /// * *access_token* (query-string) - OAuth access token.
8084 /// * *alt* (query-string) - Data format for response.
8085 /// * *callback* (query-string) - JSONP
8086 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8087 /// * *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.
8088 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8089 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8090 /// * *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.
8091 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8092 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8093 pub fn param<T>(mut self, name: T, value: T) -> ChannelStopCall<'a, C>
8094 where
8095 T: AsRef<str>,
8096 {
8097 self._additional_params
8098 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8099 self
8100 }
8101
8102 /// Identifies the authorization scope for the method you are building.
8103 ///
8104 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8105 /// [`Scope::AppReadonly`].
8106 ///
8107 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8108 /// tokens for more than one scope.
8109 ///
8110 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8111 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8112 /// sufficient, a read-write scope will do as well.
8113 pub fn add_scope<St>(mut self, scope: St) -> ChannelStopCall<'a, C>
8114 where
8115 St: AsRef<str>,
8116 {
8117 self._scopes.insert(String::from(scope.as_ref()));
8118 self
8119 }
8120 /// Identifies the authorization scope(s) for the method you are building.
8121 ///
8122 /// See [`Self::add_scope()`] for details.
8123 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChannelStopCall<'a, C>
8124 where
8125 I: IntoIterator<Item = St>,
8126 St: AsRef<str>,
8127 {
8128 self._scopes
8129 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8130 self
8131 }
8132
8133 /// Removes all scopes, and no default scope will be used either.
8134 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8135 /// for details).
8136 pub fn clear_scopes(mut self) -> ChannelStopCall<'a, C> {
8137 self._scopes.clear();
8138 self
8139 }
8140}
8141
8142/// Removes a child from a folder.
8143///
8144/// A builder for the *delete* method supported by a *child* resource.
8145/// It is not used directly, but through a [`ChildMethods`] instance.
8146///
8147/// # Example
8148///
8149/// Instantiate a resource method builder
8150///
8151/// ```test_harness,no_run
8152/// # extern crate hyper;
8153/// # extern crate hyper_rustls;
8154/// # extern crate google_drive2 as drive2;
8155/// # async fn dox() {
8156/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8157///
8158/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8159/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8160/// # .with_native_roots()
8161/// # .unwrap()
8162/// # .https_only()
8163/// # .enable_http2()
8164/// # .build();
8165///
8166/// # let executor = hyper_util::rt::TokioExecutor::new();
8167/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8168/// # secret,
8169/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8170/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8171/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8172/// # ),
8173/// # ).build().await.unwrap();
8174///
8175/// # let client = hyper_util::client::legacy::Client::builder(
8176/// # hyper_util::rt::TokioExecutor::new()
8177/// # )
8178/// # .build(
8179/// # hyper_rustls::HttpsConnectorBuilder::new()
8180/// # .with_native_roots()
8181/// # .unwrap()
8182/// # .https_or_http()
8183/// # .enable_http2()
8184/// # .build()
8185/// # );
8186/// # let mut hub = DriveHub::new(client, auth);
8187/// // You can configure optional parameters by calling the respective setters at will, and
8188/// // execute the final call using `doit()`.
8189/// // Values shown here are possibly random and not representative !
8190/// let result = hub.children().delete("folderId", "childId")
8191/// .enforce_single_parent(true)
8192/// .doit().await;
8193/// # }
8194/// ```
8195pub struct ChildDeleteCall<'a, C>
8196where
8197 C: 'a,
8198{
8199 hub: &'a DriveHub<C>,
8200 _folder_id: String,
8201 _child_id: String,
8202 _enforce_single_parent: Option<bool>,
8203 _delegate: Option<&'a mut dyn common::Delegate>,
8204 _additional_params: HashMap<String, String>,
8205 _scopes: BTreeSet<String>,
8206}
8207
8208impl<'a, C> common::CallBuilder for ChildDeleteCall<'a, C> {}
8209
8210impl<'a, C> ChildDeleteCall<'a, C>
8211where
8212 C: common::Connector,
8213{
8214 /// Perform the operation you have build so far.
8215 pub async fn doit(mut self) -> common::Result<common::Response> {
8216 use std::borrow::Cow;
8217 use std::io::{Read, Seek};
8218
8219 use common::{url::Params, ToParts};
8220 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8221
8222 let mut dd = common::DefaultDelegate;
8223 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8224 dlg.begin(common::MethodInfo {
8225 id: "drive.children.delete",
8226 http_method: hyper::Method::DELETE,
8227 });
8228
8229 for &field in ["folderId", "childId", "enforceSingleParent"].iter() {
8230 if self._additional_params.contains_key(field) {
8231 dlg.finished(false);
8232 return Err(common::Error::FieldClash(field));
8233 }
8234 }
8235
8236 let mut params = Params::with_capacity(4 + self._additional_params.len());
8237 params.push("folderId", self._folder_id);
8238 params.push("childId", self._child_id);
8239 if let Some(value) = self._enforce_single_parent.as_ref() {
8240 params.push("enforceSingleParent", value.to_string());
8241 }
8242
8243 params.extend(self._additional_params.iter());
8244
8245 let mut url = self.hub._base_url.clone() + "files/{folderId}/children/{childId}";
8246 if self._scopes.is_empty() {
8247 self._scopes.insert(Scope::Full.as_ref().to_string());
8248 }
8249
8250 #[allow(clippy::single_element_loop)]
8251 for &(find_this, param_name) in
8252 [("{folderId}", "folderId"), ("{childId}", "childId")].iter()
8253 {
8254 url = params.uri_replacement(url, param_name, find_this, false);
8255 }
8256 {
8257 let to_remove = ["childId", "folderId"];
8258 params.remove_params(&to_remove);
8259 }
8260
8261 let url = params.parse_with_url(&url);
8262
8263 loop {
8264 let token = match self
8265 .hub
8266 .auth
8267 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8268 .await
8269 {
8270 Ok(token) => token,
8271 Err(e) => match dlg.token(e) {
8272 Ok(token) => token,
8273 Err(e) => {
8274 dlg.finished(false);
8275 return Err(common::Error::MissingToken(e));
8276 }
8277 },
8278 };
8279 let mut req_result = {
8280 let client = &self.hub.client;
8281 dlg.pre_request();
8282 let mut req_builder = hyper::Request::builder()
8283 .method(hyper::Method::DELETE)
8284 .uri(url.as_str())
8285 .header(USER_AGENT, self.hub._user_agent.clone());
8286
8287 if let Some(token) = token.as_ref() {
8288 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8289 }
8290
8291 let request = req_builder
8292 .header(CONTENT_LENGTH, 0_u64)
8293 .body(common::to_body::<String>(None));
8294
8295 client.request(request.unwrap()).await
8296 };
8297
8298 match req_result {
8299 Err(err) => {
8300 if let common::Retry::After(d) = dlg.http_error(&err) {
8301 sleep(d).await;
8302 continue;
8303 }
8304 dlg.finished(false);
8305 return Err(common::Error::HttpError(err));
8306 }
8307 Ok(res) => {
8308 let (mut parts, body) = res.into_parts();
8309 let mut body = common::Body::new(body);
8310 if !parts.status.is_success() {
8311 let bytes = common::to_bytes(body).await.unwrap_or_default();
8312 let error = serde_json::from_str(&common::to_string(&bytes));
8313 let response = common::to_response(parts, bytes.into());
8314
8315 if let common::Retry::After(d) =
8316 dlg.http_failure(&response, error.as_ref().ok())
8317 {
8318 sleep(d).await;
8319 continue;
8320 }
8321
8322 dlg.finished(false);
8323
8324 return Err(match error {
8325 Ok(value) => common::Error::BadRequest(value),
8326 _ => common::Error::Failure(response),
8327 });
8328 }
8329 let response = common::Response::from_parts(parts, body);
8330
8331 dlg.finished(true);
8332 return Ok(response);
8333 }
8334 }
8335 }
8336 }
8337
8338 /// The ID of the folder.
8339 ///
8340 /// Sets the *folder id* path property to the given value.
8341 ///
8342 /// Even though the property as already been set when instantiating this call,
8343 /// we provide this method for API completeness.
8344 pub fn folder_id(mut self, new_value: &str) -> ChildDeleteCall<'a, C> {
8345 self._folder_id = new_value.to_string();
8346 self
8347 }
8348 /// The ID of the child.
8349 ///
8350 /// Sets the *child id* path property to the given value.
8351 ///
8352 /// Even though the property as already been set when instantiating this call,
8353 /// we provide this method for API completeness.
8354 pub fn child_id(mut self, new_value: &str) -> ChildDeleteCall<'a, C> {
8355 self._child_id = new_value.to_string();
8356 self
8357 }
8358 /// 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.
8359 ///
8360 /// Sets the *enforce single parent* query property to the given value.
8361 pub fn enforce_single_parent(mut self, new_value: bool) -> ChildDeleteCall<'a, C> {
8362 self._enforce_single_parent = Some(new_value);
8363 self
8364 }
8365 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8366 /// while executing the actual API request.
8367 ///
8368 /// ````text
8369 /// It should be used to handle progress information, and to implement a certain level of resilience.
8370 /// ````
8371 ///
8372 /// Sets the *delegate* property to the given value.
8373 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChildDeleteCall<'a, C> {
8374 self._delegate = Some(new_value);
8375 self
8376 }
8377
8378 /// Set any additional parameter of the query string used in the request.
8379 /// It should be used to set parameters which are not yet available through their own
8380 /// setters.
8381 ///
8382 /// Please note that this method must not be used to set any of the known parameters
8383 /// which have their own setter method. If done anyway, the request will fail.
8384 ///
8385 /// # Additional Parameters
8386 ///
8387 /// * *$.xgafv* (query-string) - V1 error format.
8388 /// * *access_token* (query-string) - OAuth access token.
8389 /// * *alt* (query-string) - Data format for response.
8390 /// * *callback* (query-string) - JSONP
8391 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8392 /// * *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.
8393 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8394 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8395 /// * *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.
8396 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8397 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8398 pub fn param<T>(mut self, name: T, value: T) -> ChildDeleteCall<'a, C>
8399 where
8400 T: AsRef<str>,
8401 {
8402 self._additional_params
8403 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8404 self
8405 }
8406
8407 /// Identifies the authorization scope for the method you are building.
8408 ///
8409 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8410 /// [`Scope::Full`].
8411 ///
8412 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8413 /// tokens for more than one scope.
8414 ///
8415 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8416 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8417 /// sufficient, a read-write scope will do as well.
8418 pub fn add_scope<St>(mut self, scope: St) -> ChildDeleteCall<'a, C>
8419 where
8420 St: AsRef<str>,
8421 {
8422 self._scopes.insert(String::from(scope.as_ref()));
8423 self
8424 }
8425 /// Identifies the authorization scope(s) for the method you are building.
8426 ///
8427 /// See [`Self::add_scope()`] for details.
8428 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChildDeleteCall<'a, C>
8429 where
8430 I: IntoIterator<Item = St>,
8431 St: AsRef<str>,
8432 {
8433 self._scopes
8434 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8435 self
8436 }
8437
8438 /// Removes all scopes, and no default scope will be used either.
8439 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8440 /// for details).
8441 pub fn clear_scopes(mut self) -> ChildDeleteCall<'a, C> {
8442 self._scopes.clear();
8443 self
8444 }
8445}
8446
8447/// Gets a specific child reference.
8448///
8449/// A builder for the *get* method supported by a *child* resource.
8450/// It is not used directly, but through a [`ChildMethods`] instance.
8451///
8452/// # Example
8453///
8454/// Instantiate a resource method builder
8455///
8456/// ```test_harness,no_run
8457/// # extern crate hyper;
8458/// # extern crate hyper_rustls;
8459/// # extern crate google_drive2 as drive2;
8460/// # async fn dox() {
8461/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8462///
8463/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8464/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8465/// # .with_native_roots()
8466/// # .unwrap()
8467/// # .https_only()
8468/// # .enable_http2()
8469/// # .build();
8470///
8471/// # let executor = hyper_util::rt::TokioExecutor::new();
8472/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8473/// # secret,
8474/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8475/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8476/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8477/// # ),
8478/// # ).build().await.unwrap();
8479///
8480/// # let client = hyper_util::client::legacy::Client::builder(
8481/// # hyper_util::rt::TokioExecutor::new()
8482/// # )
8483/// # .build(
8484/// # hyper_rustls::HttpsConnectorBuilder::new()
8485/// # .with_native_roots()
8486/// # .unwrap()
8487/// # .https_or_http()
8488/// # .enable_http2()
8489/// # .build()
8490/// # );
8491/// # let mut hub = DriveHub::new(client, auth);
8492/// // You can configure optional parameters by calling the respective setters at will, and
8493/// // execute the final call using `doit()`.
8494/// // Values shown here are possibly random and not representative !
8495/// let result = hub.children().get("folderId", "childId")
8496/// .doit().await;
8497/// # }
8498/// ```
8499pub struct ChildGetCall<'a, C>
8500where
8501 C: 'a,
8502{
8503 hub: &'a DriveHub<C>,
8504 _folder_id: String,
8505 _child_id: String,
8506 _delegate: Option<&'a mut dyn common::Delegate>,
8507 _additional_params: HashMap<String, String>,
8508 _scopes: BTreeSet<String>,
8509}
8510
8511impl<'a, C> common::CallBuilder for ChildGetCall<'a, C> {}
8512
8513impl<'a, C> ChildGetCall<'a, C>
8514where
8515 C: common::Connector,
8516{
8517 /// Perform the operation you have build so far.
8518 pub async fn doit(mut self) -> common::Result<(common::Response, ChildReference)> {
8519 use std::borrow::Cow;
8520 use std::io::{Read, Seek};
8521
8522 use common::{url::Params, ToParts};
8523 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8524
8525 let mut dd = common::DefaultDelegate;
8526 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8527 dlg.begin(common::MethodInfo {
8528 id: "drive.children.get",
8529 http_method: hyper::Method::GET,
8530 });
8531
8532 for &field in ["alt", "folderId", "childId"].iter() {
8533 if self._additional_params.contains_key(field) {
8534 dlg.finished(false);
8535 return Err(common::Error::FieldClash(field));
8536 }
8537 }
8538
8539 let mut params = Params::with_capacity(4 + self._additional_params.len());
8540 params.push("folderId", self._folder_id);
8541 params.push("childId", self._child_id);
8542
8543 params.extend(self._additional_params.iter());
8544
8545 params.push("alt", "json");
8546 let mut url = self.hub._base_url.clone() + "files/{folderId}/children/{childId}";
8547 if self._scopes.is_empty() {
8548 self._scopes
8549 .insert(Scope::MeetReadonly.as_ref().to_string());
8550 }
8551
8552 #[allow(clippy::single_element_loop)]
8553 for &(find_this, param_name) in
8554 [("{folderId}", "folderId"), ("{childId}", "childId")].iter()
8555 {
8556 url = params.uri_replacement(url, param_name, find_this, false);
8557 }
8558 {
8559 let to_remove = ["childId", "folderId"];
8560 params.remove_params(&to_remove);
8561 }
8562
8563 let url = params.parse_with_url(&url);
8564
8565 loop {
8566 let token = match self
8567 .hub
8568 .auth
8569 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8570 .await
8571 {
8572 Ok(token) => token,
8573 Err(e) => match dlg.token(e) {
8574 Ok(token) => token,
8575 Err(e) => {
8576 dlg.finished(false);
8577 return Err(common::Error::MissingToken(e));
8578 }
8579 },
8580 };
8581 let mut req_result = {
8582 let client = &self.hub.client;
8583 dlg.pre_request();
8584 let mut req_builder = hyper::Request::builder()
8585 .method(hyper::Method::GET)
8586 .uri(url.as_str())
8587 .header(USER_AGENT, self.hub._user_agent.clone());
8588
8589 if let Some(token) = token.as_ref() {
8590 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8591 }
8592
8593 let request = req_builder
8594 .header(CONTENT_LENGTH, 0_u64)
8595 .body(common::to_body::<String>(None));
8596
8597 client.request(request.unwrap()).await
8598 };
8599
8600 match req_result {
8601 Err(err) => {
8602 if let common::Retry::After(d) = dlg.http_error(&err) {
8603 sleep(d).await;
8604 continue;
8605 }
8606 dlg.finished(false);
8607 return Err(common::Error::HttpError(err));
8608 }
8609 Ok(res) => {
8610 let (mut parts, body) = res.into_parts();
8611 let mut body = common::Body::new(body);
8612 if !parts.status.is_success() {
8613 let bytes = common::to_bytes(body).await.unwrap_or_default();
8614 let error = serde_json::from_str(&common::to_string(&bytes));
8615 let response = common::to_response(parts, bytes.into());
8616
8617 if let common::Retry::After(d) =
8618 dlg.http_failure(&response, error.as_ref().ok())
8619 {
8620 sleep(d).await;
8621 continue;
8622 }
8623
8624 dlg.finished(false);
8625
8626 return Err(match error {
8627 Ok(value) => common::Error::BadRequest(value),
8628 _ => common::Error::Failure(response),
8629 });
8630 }
8631 let response = {
8632 let bytes = common::to_bytes(body).await.unwrap_or_default();
8633 let encoded = common::to_string(&bytes);
8634 match serde_json::from_str(&encoded) {
8635 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8636 Err(error) => {
8637 dlg.response_json_decode_error(&encoded, &error);
8638 return Err(common::Error::JsonDecodeError(
8639 encoded.to_string(),
8640 error,
8641 ));
8642 }
8643 }
8644 };
8645
8646 dlg.finished(true);
8647 return Ok(response);
8648 }
8649 }
8650 }
8651 }
8652
8653 /// The ID of the folder.
8654 ///
8655 /// Sets the *folder id* path property to the given value.
8656 ///
8657 /// Even though the property as already been set when instantiating this call,
8658 /// we provide this method for API completeness.
8659 pub fn folder_id(mut self, new_value: &str) -> ChildGetCall<'a, C> {
8660 self._folder_id = new_value.to_string();
8661 self
8662 }
8663 /// The ID of the child.
8664 ///
8665 /// Sets the *child id* path property to the given value.
8666 ///
8667 /// Even though the property as already been set when instantiating this call,
8668 /// we provide this method for API completeness.
8669 pub fn child_id(mut self, new_value: &str) -> ChildGetCall<'a, C> {
8670 self._child_id = new_value.to_string();
8671 self
8672 }
8673 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8674 /// while executing the actual API request.
8675 ///
8676 /// ````text
8677 /// It should be used to handle progress information, and to implement a certain level of resilience.
8678 /// ````
8679 ///
8680 /// Sets the *delegate* property to the given value.
8681 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChildGetCall<'a, C> {
8682 self._delegate = Some(new_value);
8683 self
8684 }
8685
8686 /// Set any additional parameter of the query string used in the request.
8687 /// It should be used to set parameters which are not yet available through their own
8688 /// setters.
8689 ///
8690 /// Please note that this method must not be used to set any of the known parameters
8691 /// which have their own setter method. If done anyway, the request will fail.
8692 ///
8693 /// # Additional Parameters
8694 ///
8695 /// * *$.xgafv* (query-string) - V1 error format.
8696 /// * *access_token* (query-string) - OAuth access token.
8697 /// * *alt* (query-string) - Data format for response.
8698 /// * *callback* (query-string) - JSONP
8699 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8700 /// * *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.
8701 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8702 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8703 /// * *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.
8704 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8705 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8706 pub fn param<T>(mut self, name: T, value: T) -> ChildGetCall<'a, C>
8707 where
8708 T: AsRef<str>,
8709 {
8710 self._additional_params
8711 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8712 self
8713 }
8714
8715 /// Identifies the authorization scope for the method you are building.
8716 ///
8717 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8718 /// [`Scope::MeetReadonly`].
8719 ///
8720 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8721 /// tokens for more than one scope.
8722 ///
8723 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8724 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8725 /// sufficient, a read-write scope will do as well.
8726 pub fn add_scope<St>(mut self, scope: St) -> ChildGetCall<'a, C>
8727 where
8728 St: AsRef<str>,
8729 {
8730 self._scopes.insert(String::from(scope.as_ref()));
8731 self
8732 }
8733 /// Identifies the authorization scope(s) for the method you are building.
8734 ///
8735 /// See [`Self::add_scope()`] for details.
8736 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChildGetCall<'a, C>
8737 where
8738 I: IntoIterator<Item = St>,
8739 St: AsRef<str>,
8740 {
8741 self._scopes
8742 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8743 self
8744 }
8745
8746 /// Removes all scopes, and no default scope will be used either.
8747 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8748 /// for details).
8749 pub fn clear_scopes(mut self) -> ChildGetCall<'a, C> {
8750 self._scopes.clear();
8751 self
8752 }
8753}
8754
8755/// Inserts a file into a folder.
8756///
8757/// A builder for the *insert* method supported by a *child* resource.
8758/// It is not used directly, but through a [`ChildMethods`] instance.
8759///
8760/// # Example
8761///
8762/// Instantiate a resource method builder
8763///
8764/// ```test_harness,no_run
8765/// # extern crate hyper;
8766/// # extern crate hyper_rustls;
8767/// # extern crate google_drive2 as drive2;
8768/// use drive2::api::ChildReference;
8769/// # async fn dox() {
8770/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8771///
8772/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8773/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8774/// # .with_native_roots()
8775/// # .unwrap()
8776/// # .https_only()
8777/// # .enable_http2()
8778/// # .build();
8779///
8780/// # let executor = hyper_util::rt::TokioExecutor::new();
8781/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8782/// # secret,
8783/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8784/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8785/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8786/// # ),
8787/// # ).build().await.unwrap();
8788///
8789/// # let client = hyper_util::client::legacy::Client::builder(
8790/// # hyper_util::rt::TokioExecutor::new()
8791/// # )
8792/// # .build(
8793/// # hyper_rustls::HttpsConnectorBuilder::new()
8794/// # .with_native_roots()
8795/// # .unwrap()
8796/// # .https_or_http()
8797/// # .enable_http2()
8798/// # .build()
8799/// # );
8800/// # let mut hub = DriveHub::new(client, auth);
8801/// // As the method needs a request, you would usually fill it with the desired information
8802/// // into the respective structure. Some of the parts shown here might not be applicable !
8803/// // Values shown here are possibly random and not representative !
8804/// let mut req = ChildReference::default();
8805///
8806/// // You can configure optional parameters by calling the respective setters at will, and
8807/// // execute the final call using `doit()`.
8808/// // Values shown here are possibly random and not representative !
8809/// let result = hub.children().insert(req, "folderId")
8810/// .supports_team_drives(true)
8811/// .supports_all_drives(false)
8812/// .enforce_single_parent(false)
8813/// .doit().await;
8814/// # }
8815/// ```
8816pub struct ChildInsertCall<'a, C>
8817where
8818 C: 'a,
8819{
8820 hub: &'a DriveHub<C>,
8821 _request: ChildReference,
8822 _folder_id: String,
8823 _supports_team_drives: Option<bool>,
8824 _supports_all_drives: Option<bool>,
8825 _enforce_single_parent: Option<bool>,
8826 _delegate: Option<&'a mut dyn common::Delegate>,
8827 _additional_params: HashMap<String, String>,
8828 _scopes: BTreeSet<String>,
8829}
8830
8831impl<'a, C> common::CallBuilder for ChildInsertCall<'a, C> {}
8832
8833impl<'a, C> ChildInsertCall<'a, C>
8834where
8835 C: common::Connector,
8836{
8837 /// Perform the operation you have build so far.
8838 pub async fn doit(mut self) -> common::Result<(common::Response, ChildReference)> {
8839 use std::borrow::Cow;
8840 use std::io::{Read, Seek};
8841
8842 use common::{url::Params, ToParts};
8843 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8844
8845 let mut dd = common::DefaultDelegate;
8846 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8847 dlg.begin(common::MethodInfo {
8848 id: "drive.children.insert",
8849 http_method: hyper::Method::POST,
8850 });
8851
8852 for &field in [
8853 "alt",
8854 "folderId",
8855 "supportsTeamDrives",
8856 "supportsAllDrives",
8857 "enforceSingleParent",
8858 ]
8859 .iter()
8860 {
8861 if self._additional_params.contains_key(field) {
8862 dlg.finished(false);
8863 return Err(common::Error::FieldClash(field));
8864 }
8865 }
8866
8867 let mut params = Params::with_capacity(7 + self._additional_params.len());
8868 params.push("folderId", self._folder_id);
8869 if let Some(value) = self._supports_team_drives.as_ref() {
8870 params.push("supportsTeamDrives", value.to_string());
8871 }
8872 if let Some(value) = self._supports_all_drives.as_ref() {
8873 params.push("supportsAllDrives", value.to_string());
8874 }
8875 if let Some(value) = self._enforce_single_parent.as_ref() {
8876 params.push("enforceSingleParent", value.to_string());
8877 }
8878
8879 params.extend(self._additional_params.iter());
8880
8881 params.push("alt", "json");
8882 let mut url = self.hub._base_url.clone() + "files/{folderId}/children";
8883 if self._scopes.is_empty() {
8884 self._scopes.insert(Scope::Full.as_ref().to_string());
8885 }
8886
8887 #[allow(clippy::single_element_loop)]
8888 for &(find_this, param_name) in [("{folderId}", "folderId")].iter() {
8889 url = params.uri_replacement(url, param_name, find_this, false);
8890 }
8891 {
8892 let to_remove = ["folderId"];
8893 params.remove_params(&to_remove);
8894 }
8895
8896 let url = params.parse_with_url(&url);
8897
8898 let mut json_mime_type = mime::APPLICATION_JSON;
8899 let mut request_value_reader = {
8900 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8901 common::remove_json_null_values(&mut value);
8902 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8903 serde_json::to_writer(&mut dst, &value).unwrap();
8904 dst
8905 };
8906 let request_size = request_value_reader
8907 .seek(std::io::SeekFrom::End(0))
8908 .unwrap();
8909 request_value_reader
8910 .seek(std::io::SeekFrom::Start(0))
8911 .unwrap();
8912
8913 loop {
8914 let token = match self
8915 .hub
8916 .auth
8917 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8918 .await
8919 {
8920 Ok(token) => token,
8921 Err(e) => match dlg.token(e) {
8922 Ok(token) => token,
8923 Err(e) => {
8924 dlg.finished(false);
8925 return Err(common::Error::MissingToken(e));
8926 }
8927 },
8928 };
8929 request_value_reader
8930 .seek(std::io::SeekFrom::Start(0))
8931 .unwrap();
8932 let mut req_result = {
8933 let client = &self.hub.client;
8934 dlg.pre_request();
8935 let mut req_builder = hyper::Request::builder()
8936 .method(hyper::Method::POST)
8937 .uri(url.as_str())
8938 .header(USER_AGENT, self.hub._user_agent.clone());
8939
8940 if let Some(token) = token.as_ref() {
8941 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8942 }
8943
8944 let request = req_builder
8945 .header(CONTENT_TYPE, json_mime_type.to_string())
8946 .header(CONTENT_LENGTH, request_size as u64)
8947 .body(common::to_body(
8948 request_value_reader.get_ref().clone().into(),
8949 ));
8950
8951 client.request(request.unwrap()).await
8952 };
8953
8954 match req_result {
8955 Err(err) => {
8956 if let common::Retry::After(d) = dlg.http_error(&err) {
8957 sleep(d).await;
8958 continue;
8959 }
8960 dlg.finished(false);
8961 return Err(common::Error::HttpError(err));
8962 }
8963 Ok(res) => {
8964 let (mut parts, body) = res.into_parts();
8965 let mut body = common::Body::new(body);
8966 if !parts.status.is_success() {
8967 let bytes = common::to_bytes(body).await.unwrap_or_default();
8968 let error = serde_json::from_str(&common::to_string(&bytes));
8969 let response = common::to_response(parts, bytes.into());
8970
8971 if let common::Retry::After(d) =
8972 dlg.http_failure(&response, error.as_ref().ok())
8973 {
8974 sleep(d).await;
8975 continue;
8976 }
8977
8978 dlg.finished(false);
8979
8980 return Err(match error {
8981 Ok(value) => common::Error::BadRequest(value),
8982 _ => common::Error::Failure(response),
8983 });
8984 }
8985 let response = {
8986 let bytes = common::to_bytes(body).await.unwrap_or_default();
8987 let encoded = common::to_string(&bytes);
8988 match serde_json::from_str(&encoded) {
8989 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8990 Err(error) => {
8991 dlg.response_json_decode_error(&encoded, &error);
8992 return Err(common::Error::JsonDecodeError(
8993 encoded.to_string(),
8994 error,
8995 ));
8996 }
8997 }
8998 };
8999
9000 dlg.finished(true);
9001 return Ok(response);
9002 }
9003 }
9004 }
9005 }
9006
9007 ///
9008 /// Sets the *request* property to the given value.
9009 ///
9010 /// Even though the property as already been set when instantiating this call,
9011 /// we provide this method for API completeness.
9012 pub fn request(mut self, new_value: ChildReference) -> ChildInsertCall<'a, C> {
9013 self._request = new_value;
9014 self
9015 }
9016 /// The ID of the folder.
9017 ///
9018 /// Sets the *folder id* path property to the given value.
9019 ///
9020 /// Even though the property as already been set when instantiating this call,
9021 /// we provide this method for API completeness.
9022 pub fn folder_id(mut self, new_value: &str) -> ChildInsertCall<'a, C> {
9023 self._folder_id = new_value.to_string();
9024 self
9025 }
9026 /// Deprecated: Use `supportsAllDrives` instead.
9027 ///
9028 /// Sets the *supports team drives* query property to the given value.
9029 pub fn supports_team_drives(mut self, new_value: bool) -> ChildInsertCall<'a, C> {
9030 self._supports_team_drives = Some(new_value);
9031 self
9032 }
9033 /// Whether the requesting application supports both My Drives and shared drives.
9034 ///
9035 /// Sets the *supports all drives* query property to the given value.
9036 pub fn supports_all_drives(mut self, new_value: bool) -> ChildInsertCall<'a, C> {
9037 self._supports_all_drives = Some(new_value);
9038 self
9039 }
9040 /// Deprecated: Adding files to multiple folders is no longer supported. Use `shortcuts` instead.
9041 ///
9042 /// Sets the *enforce single parent* query property to the given value.
9043 pub fn enforce_single_parent(mut self, new_value: bool) -> ChildInsertCall<'a, C> {
9044 self._enforce_single_parent = Some(new_value);
9045 self
9046 }
9047 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9048 /// while executing the actual API request.
9049 ///
9050 /// ````text
9051 /// It should be used to handle progress information, and to implement a certain level of resilience.
9052 /// ````
9053 ///
9054 /// Sets the *delegate* property to the given value.
9055 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChildInsertCall<'a, C> {
9056 self._delegate = Some(new_value);
9057 self
9058 }
9059
9060 /// Set any additional parameter of the query string used in the request.
9061 /// It should be used to set parameters which are not yet available through their own
9062 /// setters.
9063 ///
9064 /// Please note that this method must not be used to set any of the known parameters
9065 /// which have their own setter method. If done anyway, the request will fail.
9066 ///
9067 /// # Additional Parameters
9068 ///
9069 /// * *$.xgafv* (query-string) - V1 error format.
9070 /// * *access_token* (query-string) - OAuth access token.
9071 /// * *alt* (query-string) - Data format for response.
9072 /// * *callback* (query-string) - JSONP
9073 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9074 /// * *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.
9075 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9076 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9077 /// * *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.
9078 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9079 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9080 pub fn param<T>(mut self, name: T, value: T) -> ChildInsertCall<'a, C>
9081 where
9082 T: AsRef<str>,
9083 {
9084 self._additional_params
9085 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9086 self
9087 }
9088
9089 /// Identifies the authorization scope for the method you are building.
9090 ///
9091 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9092 /// [`Scope::Full`].
9093 ///
9094 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9095 /// tokens for more than one scope.
9096 ///
9097 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9098 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9099 /// sufficient, a read-write scope will do as well.
9100 pub fn add_scope<St>(mut self, scope: St) -> ChildInsertCall<'a, C>
9101 where
9102 St: AsRef<str>,
9103 {
9104 self._scopes.insert(String::from(scope.as_ref()));
9105 self
9106 }
9107 /// Identifies the authorization scope(s) for the method you are building.
9108 ///
9109 /// See [`Self::add_scope()`] for details.
9110 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChildInsertCall<'a, C>
9111 where
9112 I: IntoIterator<Item = St>,
9113 St: AsRef<str>,
9114 {
9115 self._scopes
9116 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9117 self
9118 }
9119
9120 /// Removes all scopes, and no default scope will be used either.
9121 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9122 /// for details).
9123 pub fn clear_scopes(mut self) -> ChildInsertCall<'a, C> {
9124 self._scopes.clear();
9125 self
9126 }
9127}
9128
9129/// Lists a folder's children.
9130///
9131/// A builder for the *list* method supported by a *child* resource.
9132/// It is not used directly, but through a [`ChildMethods`] instance.
9133///
9134/// # Example
9135///
9136/// Instantiate a resource method builder
9137///
9138/// ```test_harness,no_run
9139/// # extern crate hyper;
9140/// # extern crate hyper_rustls;
9141/// # extern crate google_drive2 as drive2;
9142/// # async fn dox() {
9143/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9144///
9145/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9146/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9147/// # .with_native_roots()
9148/// # .unwrap()
9149/// # .https_only()
9150/// # .enable_http2()
9151/// # .build();
9152///
9153/// # let executor = hyper_util::rt::TokioExecutor::new();
9154/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9155/// # secret,
9156/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9157/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9158/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9159/// # ),
9160/// # ).build().await.unwrap();
9161///
9162/// # let client = hyper_util::client::legacy::Client::builder(
9163/// # hyper_util::rt::TokioExecutor::new()
9164/// # )
9165/// # .build(
9166/// # hyper_rustls::HttpsConnectorBuilder::new()
9167/// # .with_native_roots()
9168/// # .unwrap()
9169/// # .https_or_http()
9170/// # .enable_http2()
9171/// # .build()
9172/// # );
9173/// # let mut hub = DriveHub::new(client, auth);
9174/// // You can configure optional parameters by calling the respective setters at will, and
9175/// // execute the final call using `doit()`.
9176/// // Values shown here are possibly random and not representative !
9177/// let result = hub.children().list("folderId")
9178/// .q("eirmod")
9179/// .page_token("Lorem")
9180/// .order_by("accusam")
9181/// .max_results(-47)
9182/// .doit().await;
9183/// # }
9184/// ```
9185pub struct ChildListCall<'a, C>
9186where
9187 C: 'a,
9188{
9189 hub: &'a DriveHub<C>,
9190 _folder_id: String,
9191 _q: Option<String>,
9192 _page_token: Option<String>,
9193 _order_by: Option<String>,
9194 _max_results: Option<i32>,
9195 _delegate: Option<&'a mut dyn common::Delegate>,
9196 _additional_params: HashMap<String, String>,
9197 _scopes: BTreeSet<String>,
9198}
9199
9200impl<'a, C> common::CallBuilder for ChildListCall<'a, C> {}
9201
9202impl<'a, C> ChildListCall<'a, C>
9203where
9204 C: common::Connector,
9205{
9206 /// Perform the operation you have build so far.
9207 pub async fn doit(mut self) -> common::Result<(common::Response, ChildList)> {
9208 use std::borrow::Cow;
9209 use std::io::{Read, Seek};
9210
9211 use common::{url::Params, ToParts};
9212 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9213
9214 let mut dd = common::DefaultDelegate;
9215 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9216 dlg.begin(common::MethodInfo {
9217 id: "drive.children.list",
9218 http_method: hyper::Method::GET,
9219 });
9220
9221 for &field in ["alt", "folderId", "q", "pageToken", "orderBy", "maxResults"].iter() {
9222 if self._additional_params.contains_key(field) {
9223 dlg.finished(false);
9224 return Err(common::Error::FieldClash(field));
9225 }
9226 }
9227
9228 let mut params = Params::with_capacity(7 + self._additional_params.len());
9229 params.push("folderId", self._folder_id);
9230 if let Some(value) = self._q.as_ref() {
9231 params.push("q", value);
9232 }
9233 if let Some(value) = self._page_token.as_ref() {
9234 params.push("pageToken", value);
9235 }
9236 if let Some(value) = self._order_by.as_ref() {
9237 params.push("orderBy", value);
9238 }
9239 if let Some(value) = self._max_results.as_ref() {
9240 params.push("maxResults", value.to_string());
9241 }
9242
9243 params.extend(self._additional_params.iter());
9244
9245 params.push("alt", "json");
9246 let mut url = self.hub._base_url.clone() + "files/{folderId}/children";
9247 if self._scopes.is_empty() {
9248 self._scopes
9249 .insert(Scope::MeetReadonly.as_ref().to_string());
9250 }
9251
9252 #[allow(clippy::single_element_loop)]
9253 for &(find_this, param_name) in [("{folderId}", "folderId")].iter() {
9254 url = params.uri_replacement(url, param_name, find_this, false);
9255 }
9256 {
9257 let to_remove = ["folderId"];
9258 params.remove_params(&to_remove);
9259 }
9260
9261 let url = params.parse_with_url(&url);
9262
9263 loop {
9264 let token = match self
9265 .hub
9266 .auth
9267 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9268 .await
9269 {
9270 Ok(token) => token,
9271 Err(e) => match dlg.token(e) {
9272 Ok(token) => token,
9273 Err(e) => {
9274 dlg.finished(false);
9275 return Err(common::Error::MissingToken(e));
9276 }
9277 },
9278 };
9279 let mut req_result = {
9280 let client = &self.hub.client;
9281 dlg.pre_request();
9282 let mut req_builder = hyper::Request::builder()
9283 .method(hyper::Method::GET)
9284 .uri(url.as_str())
9285 .header(USER_AGENT, self.hub._user_agent.clone());
9286
9287 if let Some(token) = token.as_ref() {
9288 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9289 }
9290
9291 let request = req_builder
9292 .header(CONTENT_LENGTH, 0_u64)
9293 .body(common::to_body::<String>(None));
9294
9295 client.request(request.unwrap()).await
9296 };
9297
9298 match req_result {
9299 Err(err) => {
9300 if let common::Retry::After(d) = dlg.http_error(&err) {
9301 sleep(d).await;
9302 continue;
9303 }
9304 dlg.finished(false);
9305 return Err(common::Error::HttpError(err));
9306 }
9307 Ok(res) => {
9308 let (mut parts, body) = res.into_parts();
9309 let mut body = common::Body::new(body);
9310 if !parts.status.is_success() {
9311 let bytes = common::to_bytes(body).await.unwrap_or_default();
9312 let error = serde_json::from_str(&common::to_string(&bytes));
9313 let response = common::to_response(parts, bytes.into());
9314
9315 if let common::Retry::After(d) =
9316 dlg.http_failure(&response, error.as_ref().ok())
9317 {
9318 sleep(d).await;
9319 continue;
9320 }
9321
9322 dlg.finished(false);
9323
9324 return Err(match error {
9325 Ok(value) => common::Error::BadRequest(value),
9326 _ => common::Error::Failure(response),
9327 });
9328 }
9329 let response = {
9330 let bytes = common::to_bytes(body).await.unwrap_or_default();
9331 let encoded = common::to_string(&bytes);
9332 match serde_json::from_str(&encoded) {
9333 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9334 Err(error) => {
9335 dlg.response_json_decode_error(&encoded, &error);
9336 return Err(common::Error::JsonDecodeError(
9337 encoded.to_string(),
9338 error,
9339 ));
9340 }
9341 }
9342 };
9343
9344 dlg.finished(true);
9345 return Ok(response);
9346 }
9347 }
9348 }
9349 }
9350
9351 /// The ID of the folder.
9352 ///
9353 /// Sets the *folder id* path property to the given value.
9354 ///
9355 /// Even though the property as already been set when instantiating this call,
9356 /// we provide this method for API completeness.
9357 pub fn folder_id(mut self, new_value: &str) -> ChildListCall<'a, C> {
9358 self._folder_id = new_value.to_string();
9359 self
9360 }
9361 /// Query string for searching children.
9362 ///
9363 /// Sets the *q* query property to the given value.
9364 pub fn q(mut self, new_value: &str) -> ChildListCall<'a, C> {
9365 self._q = Some(new_value.to_string());
9366 self
9367 }
9368 /// Page token for children.
9369 ///
9370 /// Sets the *page token* query property to the given value.
9371 pub fn page_token(mut self, new_value: &str) -> ChildListCall<'a, C> {
9372 self._page_token = Some(new_value.to_string());
9373 self
9374 }
9375 /// 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.
9376 ///
9377 /// Sets the *order by* query property to the given value.
9378 pub fn order_by(mut self, new_value: &str) -> ChildListCall<'a, C> {
9379 self._order_by = Some(new_value.to_string());
9380 self
9381 }
9382 /// Maximum number of children to return.
9383 ///
9384 /// Sets the *max results* query property to the given value.
9385 pub fn max_results(mut self, new_value: i32) -> ChildListCall<'a, C> {
9386 self._max_results = Some(new_value);
9387 self
9388 }
9389 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9390 /// while executing the actual API request.
9391 ///
9392 /// ````text
9393 /// It should be used to handle progress information, and to implement a certain level of resilience.
9394 /// ````
9395 ///
9396 /// Sets the *delegate* property to the given value.
9397 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChildListCall<'a, C> {
9398 self._delegate = Some(new_value);
9399 self
9400 }
9401
9402 /// Set any additional parameter of the query string used in the request.
9403 /// It should be used to set parameters which are not yet available through their own
9404 /// setters.
9405 ///
9406 /// Please note that this method must not be used to set any of the known parameters
9407 /// which have their own setter method. If done anyway, the request will fail.
9408 ///
9409 /// # Additional Parameters
9410 ///
9411 /// * *$.xgafv* (query-string) - V1 error format.
9412 /// * *access_token* (query-string) - OAuth access token.
9413 /// * *alt* (query-string) - Data format for response.
9414 /// * *callback* (query-string) - JSONP
9415 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9416 /// * *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.
9417 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9418 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9419 /// * *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.
9420 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9421 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9422 pub fn param<T>(mut self, name: T, value: T) -> ChildListCall<'a, C>
9423 where
9424 T: AsRef<str>,
9425 {
9426 self._additional_params
9427 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9428 self
9429 }
9430
9431 /// Identifies the authorization scope for the method you are building.
9432 ///
9433 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9434 /// [`Scope::MeetReadonly`].
9435 ///
9436 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9437 /// tokens for more than one scope.
9438 ///
9439 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9440 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9441 /// sufficient, a read-write scope will do as well.
9442 pub fn add_scope<St>(mut self, scope: St) -> ChildListCall<'a, C>
9443 where
9444 St: AsRef<str>,
9445 {
9446 self._scopes.insert(String::from(scope.as_ref()));
9447 self
9448 }
9449 /// Identifies the authorization scope(s) for the method you are building.
9450 ///
9451 /// See [`Self::add_scope()`] for details.
9452 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChildListCall<'a, C>
9453 where
9454 I: IntoIterator<Item = St>,
9455 St: AsRef<str>,
9456 {
9457 self._scopes
9458 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9459 self
9460 }
9461
9462 /// Removes all scopes, and no default scope will be used either.
9463 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9464 /// for details).
9465 pub fn clear_scopes(mut self) -> ChildListCall<'a, C> {
9466 self._scopes.clear();
9467 self
9468 }
9469}
9470
9471/// Deletes a comment.
9472///
9473/// A builder for the *delete* method supported by a *comment* resource.
9474/// It is not used directly, but through a [`CommentMethods`] instance.
9475///
9476/// # Example
9477///
9478/// Instantiate a resource method builder
9479///
9480/// ```test_harness,no_run
9481/// # extern crate hyper;
9482/// # extern crate hyper_rustls;
9483/// # extern crate google_drive2 as drive2;
9484/// # async fn dox() {
9485/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9486///
9487/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9488/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9489/// # .with_native_roots()
9490/// # .unwrap()
9491/// # .https_only()
9492/// # .enable_http2()
9493/// # .build();
9494///
9495/// # let executor = hyper_util::rt::TokioExecutor::new();
9496/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9497/// # secret,
9498/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9499/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9500/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9501/// # ),
9502/// # ).build().await.unwrap();
9503///
9504/// # let client = hyper_util::client::legacy::Client::builder(
9505/// # hyper_util::rt::TokioExecutor::new()
9506/// # )
9507/// # .build(
9508/// # hyper_rustls::HttpsConnectorBuilder::new()
9509/// # .with_native_roots()
9510/// # .unwrap()
9511/// # .https_or_http()
9512/// # .enable_http2()
9513/// # .build()
9514/// # );
9515/// # let mut hub = DriveHub::new(client, auth);
9516/// // You can configure optional parameters by calling the respective setters at will, and
9517/// // execute the final call using `doit()`.
9518/// // Values shown here are possibly random and not representative !
9519/// let result = hub.comments().delete("fileId", "commentId")
9520/// .doit().await;
9521/// # }
9522/// ```
9523pub struct CommentDeleteCall<'a, C>
9524where
9525 C: 'a,
9526{
9527 hub: &'a DriveHub<C>,
9528 _file_id: String,
9529 _comment_id: String,
9530 _delegate: Option<&'a mut dyn common::Delegate>,
9531 _additional_params: HashMap<String, String>,
9532 _scopes: BTreeSet<String>,
9533}
9534
9535impl<'a, C> common::CallBuilder for CommentDeleteCall<'a, C> {}
9536
9537impl<'a, C> CommentDeleteCall<'a, C>
9538where
9539 C: common::Connector,
9540{
9541 /// Perform the operation you have build so far.
9542 pub async fn doit(mut self) -> common::Result<common::Response> {
9543 use std::borrow::Cow;
9544 use std::io::{Read, Seek};
9545
9546 use common::{url::Params, ToParts};
9547 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9548
9549 let mut dd = common::DefaultDelegate;
9550 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9551 dlg.begin(common::MethodInfo {
9552 id: "drive.comments.delete",
9553 http_method: hyper::Method::DELETE,
9554 });
9555
9556 for &field in ["fileId", "commentId"].iter() {
9557 if self._additional_params.contains_key(field) {
9558 dlg.finished(false);
9559 return Err(common::Error::FieldClash(field));
9560 }
9561 }
9562
9563 let mut params = Params::with_capacity(3 + self._additional_params.len());
9564 params.push("fileId", self._file_id);
9565 params.push("commentId", self._comment_id);
9566
9567 params.extend(self._additional_params.iter());
9568
9569 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}";
9570 if self._scopes.is_empty() {
9571 self._scopes.insert(Scope::Full.as_ref().to_string());
9572 }
9573
9574 #[allow(clippy::single_element_loop)]
9575 for &(find_this, param_name) in
9576 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
9577 {
9578 url = params.uri_replacement(url, param_name, find_this, false);
9579 }
9580 {
9581 let to_remove = ["commentId", "fileId"];
9582 params.remove_params(&to_remove);
9583 }
9584
9585 let url = params.parse_with_url(&url);
9586
9587 loop {
9588 let token = match self
9589 .hub
9590 .auth
9591 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9592 .await
9593 {
9594 Ok(token) => token,
9595 Err(e) => match dlg.token(e) {
9596 Ok(token) => token,
9597 Err(e) => {
9598 dlg.finished(false);
9599 return Err(common::Error::MissingToken(e));
9600 }
9601 },
9602 };
9603 let mut req_result = {
9604 let client = &self.hub.client;
9605 dlg.pre_request();
9606 let mut req_builder = hyper::Request::builder()
9607 .method(hyper::Method::DELETE)
9608 .uri(url.as_str())
9609 .header(USER_AGENT, self.hub._user_agent.clone());
9610
9611 if let Some(token) = token.as_ref() {
9612 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9613 }
9614
9615 let request = req_builder
9616 .header(CONTENT_LENGTH, 0_u64)
9617 .body(common::to_body::<String>(None));
9618
9619 client.request(request.unwrap()).await
9620 };
9621
9622 match req_result {
9623 Err(err) => {
9624 if let common::Retry::After(d) = dlg.http_error(&err) {
9625 sleep(d).await;
9626 continue;
9627 }
9628 dlg.finished(false);
9629 return Err(common::Error::HttpError(err));
9630 }
9631 Ok(res) => {
9632 let (mut parts, body) = res.into_parts();
9633 let mut body = common::Body::new(body);
9634 if !parts.status.is_success() {
9635 let bytes = common::to_bytes(body).await.unwrap_or_default();
9636 let error = serde_json::from_str(&common::to_string(&bytes));
9637 let response = common::to_response(parts, bytes.into());
9638
9639 if let common::Retry::After(d) =
9640 dlg.http_failure(&response, error.as_ref().ok())
9641 {
9642 sleep(d).await;
9643 continue;
9644 }
9645
9646 dlg.finished(false);
9647
9648 return Err(match error {
9649 Ok(value) => common::Error::BadRequest(value),
9650 _ => common::Error::Failure(response),
9651 });
9652 }
9653 let response = common::Response::from_parts(parts, body);
9654
9655 dlg.finished(true);
9656 return Ok(response);
9657 }
9658 }
9659 }
9660 }
9661
9662 /// The ID of the file.
9663 ///
9664 /// Sets the *file id* path property to the given value.
9665 ///
9666 /// Even though the property as already been set when instantiating this call,
9667 /// we provide this method for API completeness.
9668 pub fn file_id(mut self, new_value: &str) -> CommentDeleteCall<'a, C> {
9669 self._file_id = new_value.to_string();
9670 self
9671 }
9672 /// The ID of the comment.
9673 ///
9674 /// Sets the *comment id* path property to the given value.
9675 ///
9676 /// Even though the property as already been set when instantiating this call,
9677 /// we provide this method for API completeness.
9678 pub fn comment_id(mut self, new_value: &str) -> CommentDeleteCall<'a, C> {
9679 self._comment_id = new_value.to_string();
9680 self
9681 }
9682 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9683 /// while executing the actual API request.
9684 ///
9685 /// ````text
9686 /// It should be used to handle progress information, and to implement a certain level of resilience.
9687 /// ````
9688 ///
9689 /// Sets the *delegate* property to the given value.
9690 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentDeleteCall<'a, C> {
9691 self._delegate = Some(new_value);
9692 self
9693 }
9694
9695 /// Set any additional parameter of the query string used in the request.
9696 /// It should be used to set parameters which are not yet available through their own
9697 /// setters.
9698 ///
9699 /// Please note that this method must not be used to set any of the known parameters
9700 /// which have their own setter method. If done anyway, the request will fail.
9701 ///
9702 /// # Additional Parameters
9703 ///
9704 /// * *$.xgafv* (query-string) - V1 error format.
9705 /// * *access_token* (query-string) - OAuth access token.
9706 /// * *alt* (query-string) - Data format for response.
9707 /// * *callback* (query-string) - JSONP
9708 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9709 /// * *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.
9710 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9711 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9712 /// * *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.
9713 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9714 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9715 pub fn param<T>(mut self, name: T, value: T) -> CommentDeleteCall<'a, C>
9716 where
9717 T: AsRef<str>,
9718 {
9719 self._additional_params
9720 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9721 self
9722 }
9723
9724 /// Identifies the authorization scope for the method you are building.
9725 ///
9726 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9727 /// [`Scope::Full`].
9728 ///
9729 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9730 /// tokens for more than one scope.
9731 ///
9732 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9733 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9734 /// sufficient, a read-write scope will do as well.
9735 pub fn add_scope<St>(mut self, scope: St) -> CommentDeleteCall<'a, C>
9736 where
9737 St: AsRef<str>,
9738 {
9739 self._scopes.insert(String::from(scope.as_ref()));
9740 self
9741 }
9742 /// Identifies the authorization scope(s) for the method you are building.
9743 ///
9744 /// See [`Self::add_scope()`] for details.
9745 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentDeleteCall<'a, C>
9746 where
9747 I: IntoIterator<Item = St>,
9748 St: AsRef<str>,
9749 {
9750 self._scopes
9751 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9752 self
9753 }
9754
9755 /// Removes all scopes, and no default scope will be used either.
9756 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9757 /// for details).
9758 pub fn clear_scopes(mut self) -> CommentDeleteCall<'a, C> {
9759 self._scopes.clear();
9760 self
9761 }
9762}
9763
9764/// Gets a comment by ID.
9765///
9766/// A builder for the *get* method supported by a *comment* resource.
9767/// It is not used directly, but through a [`CommentMethods`] instance.
9768///
9769/// # Example
9770///
9771/// Instantiate a resource method builder
9772///
9773/// ```test_harness,no_run
9774/// # extern crate hyper;
9775/// # extern crate hyper_rustls;
9776/// # extern crate google_drive2 as drive2;
9777/// # async fn dox() {
9778/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9779///
9780/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9781/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9782/// # .with_native_roots()
9783/// # .unwrap()
9784/// # .https_only()
9785/// # .enable_http2()
9786/// # .build();
9787///
9788/// # let executor = hyper_util::rt::TokioExecutor::new();
9789/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9790/// # secret,
9791/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9792/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9793/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9794/// # ),
9795/// # ).build().await.unwrap();
9796///
9797/// # let client = hyper_util::client::legacy::Client::builder(
9798/// # hyper_util::rt::TokioExecutor::new()
9799/// # )
9800/// # .build(
9801/// # hyper_rustls::HttpsConnectorBuilder::new()
9802/// # .with_native_roots()
9803/// # .unwrap()
9804/// # .https_or_http()
9805/// # .enable_http2()
9806/// # .build()
9807/// # );
9808/// # let mut hub = DriveHub::new(client, auth);
9809/// // You can configure optional parameters by calling the respective setters at will, and
9810/// // execute the final call using `doit()`.
9811/// // Values shown here are possibly random and not representative !
9812/// let result = hub.comments().get("fileId", "commentId")
9813/// .include_deleted(true)
9814/// .doit().await;
9815/// # }
9816/// ```
9817pub struct CommentGetCall<'a, C>
9818where
9819 C: 'a,
9820{
9821 hub: &'a DriveHub<C>,
9822 _file_id: String,
9823 _comment_id: String,
9824 _include_deleted: Option<bool>,
9825 _delegate: Option<&'a mut dyn common::Delegate>,
9826 _additional_params: HashMap<String, String>,
9827 _scopes: BTreeSet<String>,
9828}
9829
9830impl<'a, C> common::CallBuilder for CommentGetCall<'a, C> {}
9831
9832impl<'a, C> CommentGetCall<'a, C>
9833where
9834 C: common::Connector,
9835{
9836 /// Perform the operation you have build so far.
9837 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
9838 use std::borrow::Cow;
9839 use std::io::{Read, Seek};
9840
9841 use common::{url::Params, ToParts};
9842 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9843
9844 let mut dd = common::DefaultDelegate;
9845 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9846 dlg.begin(common::MethodInfo {
9847 id: "drive.comments.get",
9848 http_method: hyper::Method::GET,
9849 });
9850
9851 for &field in ["alt", "fileId", "commentId", "includeDeleted"].iter() {
9852 if self._additional_params.contains_key(field) {
9853 dlg.finished(false);
9854 return Err(common::Error::FieldClash(field));
9855 }
9856 }
9857
9858 let mut params = Params::with_capacity(5 + self._additional_params.len());
9859 params.push("fileId", self._file_id);
9860 params.push("commentId", self._comment_id);
9861 if let Some(value) = self._include_deleted.as_ref() {
9862 params.push("includeDeleted", value.to_string());
9863 }
9864
9865 params.extend(self._additional_params.iter());
9866
9867 params.push("alt", "json");
9868 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}";
9869 if self._scopes.is_empty() {
9870 self._scopes
9871 .insert(Scope::MeetReadonly.as_ref().to_string());
9872 }
9873
9874 #[allow(clippy::single_element_loop)]
9875 for &(find_this, param_name) in
9876 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
9877 {
9878 url = params.uri_replacement(url, param_name, find_this, false);
9879 }
9880 {
9881 let to_remove = ["commentId", "fileId"];
9882 params.remove_params(&to_remove);
9883 }
9884
9885 let url = params.parse_with_url(&url);
9886
9887 loop {
9888 let token = match self
9889 .hub
9890 .auth
9891 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9892 .await
9893 {
9894 Ok(token) => token,
9895 Err(e) => match dlg.token(e) {
9896 Ok(token) => token,
9897 Err(e) => {
9898 dlg.finished(false);
9899 return Err(common::Error::MissingToken(e));
9900 }
9901 },
9902 };
9903 let mut req_result = {
9904 let client = &self.hub.client;
9905 dlg.pre_request();
9906 let mut req_builder = hyper::Request::builder()
9907 .method(hyper::Method::GET)
9908 .uri(url.as_str())
9909 .header(USER_AGENT, self.hub._user_agent.clone());
9910
9911 if let Some(token) = token.as_ref() {
9912 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9913 }
9914
9915 let request = req_builder
9916 .header(CONTENT_LENGTH, 0_u64)
9917 .body(common::to_body::<String>(None));
9918
9919 client.request(request.unwrap()).await
9920 };
9921
9922 match req_result {
9923 Err(err) => {
9924 if let common::Retry::After(d) = dlg.http_error(&err) {
9925 sleep(d).await;
9926 continue;
9927 }
9928 dlg.finished(false);
9929 return Err(common::Error::HttpError(err));
9930 }
9931 Ok(res) => {
9932 let (mut parts, body) = res.into_parts();
9933 let mut body = common::Body::new(body);
9934 if !parts.status.is_success() {
9935 let bytes = common::to_bytes(body).await.unwrap_or_default();
9936 let error = serde_json::from_str(&common::to_string(&bytes));
9937 let response = common::to_response(parts, bytes.into());
9938
9939 if let common::Retry::After(d) =
9940 dlg.http_failure(&response, error.as_ref().ok())
9941 {
9942 sleep(d).await;
9943 continue;
9944 }
9945
9946 dlg.finished(false);
9947
9948 return Err(match error {
9949 Ok(value) => common::Error::BadRequest(value),
9950 _ => common::Error::Failure(response),
9951 });
9952 }
9953 let response = {
9954 let bytes = common::to_bytes(body).await.unwrap_or_default();
9955 let encoded = common::to_string(&bytes);
9956 match serde_json::from_str(&encoded) {
9957 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9958 Err(error) => {
9959 dlg.response_json_decode_error(&encoded, &error);
9960 return Err(common::Error::JsonDecodeError(
9961 encoded.to_string(),
9962 error,
9963 ));
9964 }
9965 }
9966 };
9967
9968 dlg.finished(true);
9969 return Ok(response);
9970 }
9971 }
9972 }
9973 }
9974
9975 /// The ID of the file.
9976 ///
9977 /// Sets the *file id* path property to the given value.
9978 ///
9979 /// Even though the property as already been set when instantiating this call,
9980 /// we provide this method for API completeness.
9981 pub fn file_id(mut self, new_value: &str) -> CommentGetCall<'a, C> {
9982 self._file_id = new_value.to_string();
9983 self
9984 }
9985 /// The ID of the comment.
9986 ///
9987 /// Sets the *comment id* path property to the given value.
9988 ///
9989 /// Even though the property as already been set when instantiating this call,
9990 /// we provide this method for API completeness.
9991 pub fn comment_id(mut self, new_value: &str) -> CommentGetCall<'a, C> {
9992 self._comment_id = new_value.to_string();
9993 self
9994 }
9995 /// If set, this will succeed when retrieving a deleted comment, and will include any deleted replies.
9996 ///
9997 /// Sets the *include deleted* query property to the given value.
9998 pub fn include_deleted(mut self, new_value: bool) -> CommentGetCall<'a, C> {
9999 self._include_deleted = Some(new_value);
10000 self
10001 }
10002 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10003 /// while executing the actual API request.
10004 ///
10005 /// ````text
10006 /// It should be used to handle progress information, and to implement a certain level of resilience.
10007 /// ````
10008 ///
10009 /// Sets the *delegate* property to the given value.
10010 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentGetCall<'a, C> {
10011 self._delegate = Some(new_value);
10012 self
10013 }
10014
10015 /// Set any additional parameter of the query string used in the request.
10016 /// It should be used to set parameters which are not yet available through their own
10017 /// setters.
10018 ///
10019 /// Please note that this method must not be used to set any of the known parameters
10020 /// which have their own setter method. If done anyway, the request will fail.
10021 ///
10022 /// # Additional Parameters
10023 ///
10024 /// * *$.xgafv* (query-string) - V1 error format.
10025 /// * *access_token* (query-string) - OAuth access token.
10026 /// * *alt* (query-string) - Data format for response.
10027 /// * *callback* (query-string) - JSONP
10028 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10029 /// * *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.
10030 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10031 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10032 /// * *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.
10033 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10034 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10035 pub fn param<T>(mut self, name: T, value: T) -> CommentGetCall<'a, C>
10036 where
10037 T: AsRef<str>,
10038 {
10039 self._additional_params
10040 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10041 self
10042 }
10043
10044 /// Identifies the authorization scope for the method you are building.
10045 ///
10046 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10047 /// [`Scope::MeetReadonly`].
10048 ///
10049 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10050 /// tokens for more than one scope.
10051 ///
10052 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10053 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10054 /// sufficient, a read-write scope will do as well.
10055 pub fn add_scope<St>(mut self, scope: St) -> CommentGetCall<'a, C>
10056 where
10057 St: AsRef<str>,
10058 {
10059 self._scopes.insert(String::from(scope.as_ref()));
10060 self
10061 }
10062 /// Identifies the authorization scope(s) for the method you are building.
10063 ///
10064 /// See [`Self::add_scope()`] for details.
10065 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentGetCall<'a, C>
10066 where
10067 I: IntoIterator<Item = St>,
10068 St: AsRef<str>,
10069 {
10070 self._scopes
10071 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10072 self
10073 }
10074
10075 /// Removes all scopes, and no default scope will be used either.
10076 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10077 /// for details).
10078 pub fn clear_scopes(mut self) -> CommentGetCall<'a, C> {
10079 self._scopes.clear();
10080 self
10081 }
10082}
10083
10084/// Creates a new comment on the given file.
10085///
10086/// A builder for the *insert* method supported by a *comment* resource.
10087/// It is not used directly, but through a [`CommentMethods`] instance.
10088///
10089/// # Example
10090///
10091/// Instantiate a resource method builder
10092///
10093/// ```test_harness,no_run
10094/// # extern crate hyper;
10095/// # extern crate hyper_rustls;
10096/// # extern crate google_drive2 as drive2;
10097/// use drive2::api::Comment;
10098/// # async fn dox() {
10099/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10100///
10101/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10102/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10103/// # .with_native_roots()
10104/// # .unwrap()
10105/// # .https_only()
10106/// # .enable_http2()
10107/// # .build();
10108///
10109/// # let executor = hyper_util::rt::TokioExecutor::new();
10110/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10111/// # secret,
10112/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10113/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10114/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10115/// # ),
10116/// # ).build().await.unwrap();
10117///
10118/// # let client = hyper_util::client::legacy::Client::builder(
10119/// # hyper_util::rt::TokioExecutor::new()
10120/// # )
10121/// # .build(
10122/// # hyper_rustls::HttpsConnectorBuilder::new()
10123/// # .with_native_roots()
10124/// # .unwrap()
10125/// # .https_or_http()
10126/// # .enable_http2()
10127/// # .build()
10128/// # );
10129/// # let mut hub = DriveHub::new(client, auth);
10130/// // As the method needs a request, you would usually fill it with the desired information
10131/// // into the respective structure. Some of the parts shown here might not be applicable !
10132/// // Values shown here are possibly random and not representative !
10133/// let mut req = Comment::default();
10134///
10135/// // You can configure optional parameters by calling the respective setters at will, and
10136/// // execute the final call using `doit()`.
10137/// // Values shown here are possibly random and not representative !
10138/// let result = hub.comments().insert(req, "fileId")
10139/// .doit().await;
10140/// # }
10141/// ```
10142pub struct CommentInsertCall<'a, C>
10143where
10144 C: 'a,
10145{
10146 hub: &'a DriveHub<C>,
10147 _request: Comment,
10148 _file_id: String,
10149 _delegate: Option<&'a mut dyn common::Delegate>,
10150 _additional_params: HashMap<String, String>,
10151 _scopes: BTreeSet<String>,
10152}
10153
10154impl<'a, C> common::CallBuilder for CommentInsertCall<'a, C> {}
10155
10156impl<'a, C> CommentInsertCall<'a, C>
10157where
10158 C: common::Connector,
10159{
10160 /// Perform the operation you have build so far.
10161 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
10162 use std::borrow::Cow;
10163 use std::io::{Read, Seek};
10164
10165 use common::{url::Params, ToParts};
10166 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10167
10168 let mut dd = common::DefaultDelegate;
10169 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10170 dlg.begin(common::MethodInfo {
10171 id: "drive.comments.insert",
10172 http_method: hyper::Method::POST,
10173 });
10174
10175 for &field in ["alt", "fileId"].iter() {
10176 if self._additional_params.contains_key(field) {
10177 dlg.finished(false);
10178 return Err(common::Error::FieldClash(field));
10179 }
10180 }
10181
10182 let mut params = Params::with_capacity(4 + self._additional_params.len());
10183 params.push("fileId", self._file_id);
10184
10185 params.extend(self._additional_params.iter());
10186
10187 params.push("alt", "json");
10188 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments";
10189 if self._scopes.is_empty() {
10190 self._scopes.insert(Scope::Full.as_ref().to_string());
10191 }
10192
10193 #[allow(clippy::single_element_loop)]
10194 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
10195 url = params.uri_replacement(url, param_name, find_this, false);
10196 }
10197 {
10198 let to_remove = ["fileId"];
10199 params.remove_params(&to_remove);
10200 }
10201
10202 let url = params.parse_with_url(&url);
10203
10204 let mut json_mime_type = mime::APPLICATION_JSON;
10205 let mut request_value_reader = {
10206 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10207 common::remove_json_null_values(&mut value);
10208 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10209 serde_json::to_writer(&mut dst, &value).unwrap();
10210 dst
10211 };
10212 let request_size = request_value_reader
10213 .seek(std::io::SeekFrom::End(0))
10214 .unwrap();
10215 request_value_reader
10216 .seek(std::io::SeekFrom::Start(0))
10217 .unwrap();
10218
10219 loop {
10220 let token = match self
10221 .hub
10222 .auth
10223 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10224 .await
10225 {
10226 Ok(token) => token,
10227 Err(e) => match dlg.token(e) {
10228 Ok(token) => token,
10229 Err(e) => {
10230 dlg.finished(false);
10231 return Err(common::Error::MissingToken(e));
10232 }
10233 },
10234 };
10235 request_value_reader
10236 .seek(std::io::SeekFrom::Start(0))
10237 .unwrap();
10238 let mut req_result = {
10239 let client = &self.hub.client;
10240 dlg.pre_request();
10241 let mut req_builder = hyper::Request::builder()
10242 .method(hyper::Method::POST)
10243 .uri(url.as_str())
10244 .header(USER_AGENT, self.hub._user_agent.clone());
10245
10246 if let Some(token) = token.as_ref() {
10247 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10248 }
10249
10250 let request = req_builder
10251 .header(CONTENT_TYPE, json_mime_type.to_string())
10252 .header(CONTENT_LENGTH, request_size as u64)
10253 .body(common::to_body(
10254 request_value_reader.get_ref().clone().into(),
10255 ));
10256
10257 client.request(request.unwrap()).await
10258 };
10259
10260 match req_result {
10261 Err(err) => {
10262 if let common::Retry::After(d) = dlg.http_error(&err) {
10263 sleep(d).await;
10264 continue;
10265 }
10266 dlg.finished(false);
10267 return Err(common::Error::HttpError(err));
10268 }
10269 Ok(res) => {
10270 let (mut parts, body) = res.into_parts();
10271 let mut body = common::Body::new(body);
10272 if !parts.status.is_success() {
10273 let bytes = common::to_bytes(body).await.unwrap_or_default();
10274 let error = serde_json::from_str(&common::to_string(&bytes));
10275 let response = common::to_response(parts, bytes.into());
10276
10277 if let common::Retry::After(d) =
10278 dlg.http_failure(&response, error.as_ref().ok())
10279 {
10280 sleep(d).await;
10281 continue;
10282 }
10283
10284 dlg.finished(false);
10285
10286 return Err(match error {
10287 Ok(value) => common::Error::BadRequest(value),
10288 _ => common::Error::Failure(response),
10289 });
10290 }
10291 let response = {
10292 let bytes = common::to_bytes(body).await.unwrap_or_default();
10293 let encoded = common::to_string(&bytes);
10294 match serde_json::from_str(&encoded) {
10295 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10296 Err(error) => {
10297 dlg.response_json_decode_error(&encoded, &error);
10298 return Err(common::Error::JsonDecodeError(
10299 encoded.to_string(),
10300 error,
10301 ));
10302 }
10303 }
10304 };
10305
10306 dlg.finished(true);
10307 return Ok(response);
10308 }
10309 }
10310 }
10311 }
10312
10313 ///
10314 /// Sets the *request* property to the given value.
10315 ///
10316 /// Even though the property as already been set when instantiating this call,
10317 /// we provide this method for API completeness.
10318 pub fn request(mut self, new_value: Comment) -> CommentInsertCall<'a, C> {
10319 self._request = new_value;
10320 self
10321 }
10322 /// The ID of the file.
10323 ///
10324 /// Sets the *file id* path property to the given value.
10325 ///
10326 /// Even though the property as already been set when instantiating this call,
10327 /// we provide this method for API completeness.
10328 pub fn file_id(mut self, new_value: &str) -> CommentInsertCall<'a, C> {
10329 self._file_id = new_value.to_string();
10330 self
10331 }
10332 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10333 /// while executing the actual API request.
10334 ///
10335 /// ````text
10336 /// It should be used to handle progress information, and to implement a certain level of resilience.
10337 /// ````
10338 ///
10339 /// Sets the *delegate* property to the given value.
10340 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentInsertCall<'a, C> {
10341 self._delegate = Some(new_value);
10342 self
10343 }
10344
10345 /// Set any additional parameter of the query string used in the request.
10346 /// It should be used to set parameters which are not yet available through their own
10347 /// setters.
10348 ///
10349 /// Please note that this method must not be used to set any of the known parameters
10350 /// which have their own setter method. If done anyway, the request will fail.
10351 ///
10352 /// # Additional Parameters
10353 ///
10354 /// * *$.xgafv* (query-string) - V1 error format.
10355 /// * *access_token* (query-string) - OAuth access token.
10356 /// * *alt* (query-string) - Data format for response.
10357 /// * *callback* (query-string) - JSONP
10358 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10359 /// * *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.
10360 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10361 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10362 /// * *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.
10363 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10364 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10365 pub fn param<T>(mut self, name: T, value: T) -> CommentInsertCall<'a, C>
10366 where
10367 T: AsRef<str>,
10368 {
10369 self._additional_params
10370 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10371 self
10372 }
10373
10374 /// Identifies the authorization scope for the method you are building.
10375 ///
10376 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10377 /// [`Scope::Full`].
10378 ///
10379 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10380 /// tokens for more than one scope.
10381 ///
10382 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10383 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10384 /// sufficient, a read-write scope will do as well.
10385 pub fn add_scope<St>(mut self, scope: St) -> CommentInsertCall<'a, C>
10386 where
10387 St: AsRef<str>,
10388 {
10389 self._scopes.insert(String::from(scope.as_ref()));
10390 self
10391 }
10392 /// Identifies the authorization scope(s) for the method you are building.
10393 ///
10394 /// See [`Self::add_scope()`] for details.
10395 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentInsertCall<'a, C>
10396 where
10397 I: IntoIterator<Item = St>,
10398 St: AsRef<str>,
10399 {
10400 self._scopes
10401 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10402 self
10403 }
10404
10405 /// Removes all scopes, and no default scope will be used either.
10406 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10407 /// for details).
10408 pub fn clear_scopes(mut self) -> CommentInsertCall<'a, C> {
10409 self._scopes.clear();
10410 self
10411 }
10412}
10413
10414/// Lists a file's comments.
10415///
10416/// A builder for the *list* method supported by a *comment* resource.
10417/// It is not used directly, but through a [`CommentMethods`] instance.
10418///
10419/// # Example
10420///
10421/// Instantiate a resource method builder
10422///
10423/// ```test_harness,no_run
10424/// # extern crate hyper;
10425/// # extern crate hyper_rustls;
10426/// # extern crate google_drive2 as drive2;
10427/// # async fn dox() {
10428/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10429///
10430/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10431/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10432/// # .with_native_roots()
10433/// # .unwrap()
10434/// # .https_only()
10435/// # .enable_http2()
10436/// # .build();
10437///
10438/// # let executor = hyper_util::rt::TokioExecutor::new();
10439/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10440/// # secret,
10441/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10442/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10443/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10444/// # ),
10445/// # ).build().await.unwrap();
10446///
10447/// # let client = hyper_util::client::legacy::Client::builder(
10448/// # hyper_util::rt::TokioExecutor::new()
10449/// # )
10450/// # .build(
10451/// # hyper_rustls::HttpsConnectorBuilder::new()
10452/// # .with_native_roots()
10453/// # .unwrap()
10454/// # .https_or_http()
10455/// # .enable_http2()
10456/// # .build()
10457/// # );
10458/// # let mut hub = DriveHub::new(client, auth);
10459/// // You can configure optional parameters by calling the respective setters at will, and
10460/// // execute the final call using `doit()`.
10461/// // Values shown here are possibly random and not representative !
10462/// let result = hub.comments().list("fileId")
10463/// .updated_min("At")
10464/// .page_token("dolor")
10465/// .max_results(-22)
10466/// .include_deleted(true)
10467/// .doit().await;
10468/// # }
10469/// ```
10470pub struct CommentListCall<'a, C>
10471where
10472 C: 'a,
10473{
10474 hub: &'a DriveHub<C>,
10475 _file_id: String,
10476 _updated_min: Option<String>,
10477 _page_token: Option<String>,
10478 _max_results: Option<i32>,
10479 _include_deleted: Option<bool>,
10480 _delegate: Option<&'a mut dyn common::Delegate>,
10481 _additional_params: HashMap<String, String>,
10482 _scopes: BTreeSet<String>,
10483}
10484
10485impl<'a, C> common::CallBuilder for CommentListCall<'a, C> {}
10486
10487impl<'a, C> CommentListCall<'a, C>
10488where
10489 C: common::Connector,
10490{
10491 /// Perform the operation you have build so far.
10492 pub async fn doit(mut self) -> common::Result<(common::Response, CommentList)> {
10493 use std::borrow::Cow;
10494 use std::io::{Read, Seek};
10495
10496 use common::{url::Params, ToParts};
10497 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10498
10499 let mut dd = common::DefaultDelegate;
10500 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10501 dlg.begin(common::MethodInfo {
10502 id: "drive.comments.list",
10503 http_method: hyper::Method::GET,
10504 });
10505
10506 for &field in [
10507 "alt",
10508 "fileId",
10509 "updatedMin",
10510 "pageToken",
10511 "maxResults",
10512 "includeDeleted",
10513 ]
10514 .iter()
10515 {
10516 if self._additional_params.contains_key(field) {
10517 dlg.finished(false);
10518 return Err(common::Error::FieldClash(field));
10519 }
10520 }
10521
10522 let mut params = Params::with_capacity(7 + self._additional_params.len());
10523 params.push("fileId", self._file_id);
10524 if let Some(value) = self._updated_min.as_ref() {
10525 params.push("updatedMin", value);
10526 }
10527 if let Some(value) = self._page_token.as_ref() {
10528 params.push("pageToken", value);
10529 }
10530 if let Some(value) = self._max_results.as_ref() {
10531 params.push("maxResults", value.to_string());
10532 }
10533 if let Some(value) = self._include_deleted.as_ref() {
10534 params.push("includeDeleted", value.to_string());
10535 }
10536
10537 params.extend(self._additional_params.iter());
10538
10539 params.push("alt", "json");
10540 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments";
10541 if self._scopes.is_empty() {
10542 self._scopes
10543 .insert(Scope::MeetReadonly.as_ref().to_string());
10544 }
10545
10546 #[allow(clippy::single_element_loop)]
10547 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
10548 url = params.uri_replacement(url, param_name, find_this, false);
10549 }
10550 {
10551 let to_remove = ["fileId"];
10552 params.remove_params(&to_remove);
10553 }
10554
10555 let url = params.parse_with_url(&url);
10556
10557 loop {
10558 let token = match self
10559 .hub
10560 .auth
10561 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10562 .await
10563 {
10564 Ok(token) => token,
10565 Err(e) => match dlg.token(e) {
10566 Ok(token) => token,
10567 Err(e) => {
10568 dlg.finished(false);
10569 return Err(common::Error::MissingToken(e));
10570 }
10571 },
10572 };
10573 let mut req_result = {
10574 let client = &self.hub.client;
10575 dlg.pre_request();
10576 let mut req_builder = hyper::Request::builder()
10577 .method(hyper::Method::GET)
10578 .uri(url.as_str())
10579 .header(USER_AGENT, self.hub._user_agent.clone());
10580
10581 if let Some(token) = token.as_ref() {
10582 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10583 }
10584
10585 let request = req_builder
10586 .header(CONTENT_LENGTH, 0_u64)
10587 .body(common::to_body::<String>(None));
10588
10589 client.request(request.unwrap()).await
10590 };
10591
10592 match req_result {
10593 Err(err) => {
10594 if let common::Retry::After(d) = dlg.http_error(&err) {
10595 sleep(d).await;
10596 continue;
10597 }
10598 dlg.finished(false);
10599 return Err(common::Error::HttpError(err));
10600 }
10601 Ok(res) => {
10602 let (mut parts, body) = res.into_parts();
10603 let mut body = common::Body::new(body);
10604 if !parts.status.is_success() {
10605 let bytes = common::to_bytes(body).await.unwrap_or_default();
10606 let error = serde_json::from_str(&common::to_string(&bytes));
10607 let response = common::to_response(parts, bytes.into());
10608
10609 if let common::Retry::After(d) =
10610 dlg.http_failure(&response, error.as_ref().ok())
10611 {
10612 sleep(d).await;
10613 continue;
10614 }
10615
10616 dlg.finished(false);
10617
10618 return Err(match error {
10619 Ok(value) => common::Error::BadRequest(value),
10620 _ => common::Error::Failure(response),
10621 });
10622 }
10623 let response = {
10624 let bytes = common::to_bytes(body).await.unwrap_or_default();
10625 let encoded = common::to_string(&bytes);
10626 match serde_json::from_str(&encoded) {
10627 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10628 Err(error) => {
10629 dlg.response_json_decode_error(&encoded, &error);
10630 return Err(common::Error::JsonDecodeError(
10631 encoded.to_string(),
10632 error,
10633 ));
10634 }
10635 }
10636 };
10637
10638 dlg.finished(true);
10639 return Ok(response);
10640 }
10641 }
10642 }
10643 }
10644
10645 /// The ID of the file.
10646 ///
10647 /// Sets the *file id* path property to the given value.
10648 ///
10649 /// Even though the property as already been set when instantiating this call,
10650 /// we provide this method for API completeness.
10651 pub fn file_id(mut self, new_value: &str) -> CommentListCall<'a, C> {
10652 self._file_id = new_value.to_string();
10653 self
10654 }
10655 /// Only discussions that were updated after this timestamp will be returned. Formatted as an RFC 3339 timestamp.
10656 ///
10657 /// Sets the *updated min* query property to the given value.
10658 pub fn updated_min(mut self, new_value: &str) -> CommentListCall<'a, C> {
10659 self._updated_min = Some(new_value.to_string());
10660 self
10661 }
10662 /// 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.
10663 ///
10664 /// Sets the *page token* query property to the given value.
10665 pub fn page_token(mut self, new_value: &str) -> CommentListCall<'a, C> {
10666 self._page_token = Some(new_value.to_string());
10667 self
10668 }
10669 /// The maximum number of discussions to include in the response, used for paging.
10670 ///
10671 /// Sets the *max results* query property to the given value.
10672 pub fn max_results(mut self, new_value: i32) -> CommentListCall<'a, C> {
10673 self._max_results = Some(new_value);
10674 self
10675 }
10676 /// If set, all comments and replies, including deleted comments and replies (with content stripped) will be returned.
10677 ///
10678 /// Sets the *include deleted* query property to the given value.
10679 pub fn include_deleted(mut self, new_value: bool) -> CommentListCall<'a, C> {
10680 self._include_deleted = Some(new_value);
10681 self
10682 }
10683 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10684 /// while executing the actual API request.
10685 ///
10686 /// ````text
10687 /// It should be used to handle progress information, and to implement a certain level of resilience.
10688 /// ````
10689 ///
10690 /// Sets the *delegate* property to the given value.
10691 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentListCall<'a, C> {
10692 self._delegate = Some(new_value);
10693 self
10694 }
10695
10696 /// Set any additional parameter of the query string used in the request.
10697 /// It should be used to set parameters which are not yet available through their own
10698 /// setters.
10699 ///
10700 /// Please note that this method must not be used to set any of the known parameters
10701 /// which have their own setter method. If done anyway, the request will fail.
10702 ///
10703 /// # Additional Parameters
10704 ///
10705 /// * *$.xgafv* (query-string) - V1 error format.
10706 /// * *access_token* (query-string) - OAuth access token.
10707 /// * *alt* (query-string) - Data format for response.
10708 /// * *callback* (query-string) - JSONP
10709 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10710 /// * *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.
10711 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10712 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10713 /// * *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.
10714 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10715 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10716 pub fn param<T>(mut self, name: T, value: T) -> CommentListCall<'a, C>
10717 where
10718 T: AsRef<str>,
10719 {
10720 self._additional_params
10721 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10722 self
10723 }
10724
10725 /// Identifies the authorization scope for the method you are building.
10726 ///
10727 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10728 /// [`Scope::MeetReadonly`].
10729 ///
10730 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10731 /// tokens for more than one scope.
10732 ///
10733 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10734 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10735 /// sufficient, a read-write scope will do as well.
10736 pub fn add_scope<St>(mut self, scope: St) -> CommentListCall<'a, C>
10737 where
10738 St: AsRef<str>,
10739 {
10740 self._scopes.insert(String::from(scope.as_ref()));
10741 self
10742 }
10743 /// Identifies the authorization scope(s) for the method you are building.
10744 ///
10745 /// See [`Self::add_scope()`] for details.
10746 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentListCall<'a, C>
10747 where
10748 I: IntoIterator<Item = St>,
10749 St: AsRef<str>,
10750 {
10751 self._scopes
10752 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10753 self
10754 }
10755
10756 /// Removes all scopes, and no default scope will be used either.
10757 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10758 /// for details).
10759 pub fn clear_scopes(mut self) -> CommentListCall<'a, C> {
10760 self._scopes.clear();
10761 self
10762 }
10763}
10764
10765/// Updates an existing comment.
10766///
10767/// A builder for the *patch* method supported by a *comment* resource.
10768/// It is not used directly, but through a [`CommentMethods`] instance.
10769///
10770/// # Example
10771///
10772/// Instantiate a resource method builder
10773///
10774/// ```test_harness,no_run
10775/// # extern crate hyper;
10776/// # extern crate hyper_rustls;
10777/// # extern crate google_drive2 as drive2;
10778/// use drive2::api::Comment;
10779/// # async fn dox() {
10780/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10781///
10782/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10783/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10784/// # .with_native_roots()
10785/// # .unwrap()
10786/// # .https_only()
10787/// # .enable_http2()
10788/// # .build();
10789///
10790/// # let executor = hyper_util::rt::TokioExecutor::new();
10791/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10792/// # secret,
10793/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10794/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10795/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10796/// # ),
10797/// # ).build().await.unwrap();
10798///
10799/// # let client = hyper_util::client::legacy::Client::builder(
10800/// # hyper_util::rt::TokioExecutor::new()
10801/// # )
10802/// # .build(
10803/// # hyper_rustls::HttpsConnectorBuilder::new()
10804/// # .with_native_roots()
10805/// # .unwrap()
10806/// # .https_or_http()
10807/// # .enable_http2()
10808/// # .build()
10809/// # );
10810/// # let mut hub = DriveHub::new(client, auth);
10811/// // As the method needs a request, you would usually fill it with the desired information
10812/// // into the respective structure. Some of the parts shown here might not be applicable !
10813/// // Values shown here are possibly random and not representative !
10814/// let mut req = Comment::default();
10815///
10816/// // You can configure optional parameters by calling the respective setters at will, and
10817/// // execute the final call using `doit()`.
10818/// // Values shown here are possibly random and not representative !
10819/// let result = hub.comments().patch(req, "fileId", "commentId")
10820/// .doit().await;
10821/// # }
10822/// ```
10823pub struct CommentPatchCall<'a, C>
10824where
10825 C: 'a,
10826{
10827 hub: &'a DriveHub<C>,
10828 _request: Comment,
10829 _file_id: String,
10830 _comment_id: String,
10831 _delegate: Option<&'a mut dyn common::Delegate>,
10832 _additional_params: HashMap<String, String>,
10833 _scopes: BTreeSet<String>,
10834}
10835
10836impl<'a, C> common::CallBuilder for CommentPatchCall<'a, C> {}
10837
10838impl<'a, C> CommentPatchCall<'a, C>
10839where
10840 C: common::Connector,
10841{
10842 /// Perform the operation you have build so far.
10843 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
10844 use std::borrow::Cow;
10845 use std::io::{Read, Seek};
10846
10847 use common::{url::Params, ToParts};
10848 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10849
10850 let mut dd = common::DefaultDelegate;
10851 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10852 dlg.begin(common::MethodInfo {
10853 id: "drive.comments.patch",
10854 http_method: hyper::Method::PATCH,
10855 });
10856
10857 for &field in ["alt", "fileId", "commentId"].iter() {
10858 if self._additional_params.contains_key(field) {
10859 dlg.finished(false);
10860 return Err(common::Error::FieldClash(field));
10861 }
10862 }
10863
10864 let mut params = Params::with_capacity(5 + self._additional_params.len());
10865 params.push("fileId", self._file_id);
10866 params.push("commentId", self._comment_id);
10867
10868 params.extend(self._additional_params.iter());
10869
10870 params.push("alt", "json");
10871 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}";
10872 if self._scopes.is_empty() {
10873 self._scopes.insert(Scope::Full.as_ref().to_string());
10874 }
10875
10876 #[allow(clippy::single_element_loop)]
10877 for &(find_this, param_name) in
10878 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
10879 {
10880 url = params.uri_replacement(url, param_name, find_this, false);
10881 }
10882 {
10883 let to_remove = ["commentId", "fileId"];
10884 params.remove_params(&to_remove);
10885 }
10886
10887 let url = params.parse_with_url(&url);
10888
10889 let mut json_mime_type = mime::APPLICATION_JSON;
10890 let mut request_value_reader = {
10891 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10892 common::remove_json_null_values(&mut value);
10893 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10894 serde_json::to_writer(&mut dst, &value).unwrap();
10895 dst
10896 };
10897 let request_size = request_value_reader
10898 .seek(std::io::SeekFrom::End(0))
10899 .unwrap();
10900 request_value_reader
10901 .seek(std::io::SeekFrom::Start(0))
10902 .unwrap();
10903
10904 loop {
10905 let token = match self
10906 .hub
10907 .auth
10908 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10909 .await
10910 {
10911 Ok(token) => token,
10912 Err(e) => match dlg.token(e) {
10913 Ok(token) => token,
10914 Err(e) => {
10915 dlg.finished(false);
10916 return Err(common::Error::MissingToken(e));
10917 }
10918 },
10919 };
10920 request_value_reader
10921 .seek(std::io::SeekFrom::Start(0))
10922 .unwrap();
10923 let mut req_result = {
10924 let client = &self.hub.client;
10925 dlg.pre_request();
10926 let mut req_builder = hyper::Request::builder()
10927 .method(hyper::Method::PATCH)
10928 .uri(url.as_str())
10929 .header(USER_AGENT, self.hub._user_agent.clone());
10930
10931 if let Some(token) = token.as_ref() {
10932 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10933 }
10934
10935 let request = req_builder
10936 .header(CONTENT_TYPE, json_mime_type.to_string())
10937 .header(CONTENT_LENGTH, request_size as u64)
10938 .body(common::to_body(
10939 request_value_reader.get_ref().clone().into(),
10940 ));
10941
10942 client.request(request.unwrap()).await
10943 };
10944
10945 match req_result {
10946 Err(err) => {
10947 if let common::Retry::After(d) = dlg.http_error(&err) {
10948 sleep(d).await;
10949 continue;
10950 }
10951 dlg.finished(false);
10952 return Err(common::Error::HttpError(err));
10953 }
10954 Ok(res) => {
10955 let (mut parts, body) = res.into_parts();
10956 let mut body = common::Body::new(body);
10957 if !parts.status.is_success() {
10958 let bytes = common::to_bytes(body).await.unwrap_or_default();
10959 let error = serde_json::from_str(&common::to_string(&bytes));
10960 let response = common::to_response(parts, bytes.into());
10961
10962 if let common::Retry::After(d) =
10963 dlg.http_failure(&response, error.as_ref().ok())
10964 {
10965 sleep(d).await;
10966 continue;
10967 }
10968
10969 dlg.finished(false);
10970
10971 return Err(match error {
10972 Ok(value) => common::Error::BadRequest(value),
10973 _ => common::Error::Failure(response),
10974 });
10975 }
10976 let response = {
10977 let bytes = common::to_bytes(body).await.unwrap_or_default();
10978 let encoded = common::to_string(&bytes);
10979 match serde_json::from_str(&encoded) {
10980 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10981 Err(error) => {
10982 dlg.response_json_decode_error(&encoded, &error);
10983 return Err(common::Error::JsonDecodeError(
10984 encoded.to_string(),
10985 error,
10986 ));
10987 }
10988 }
10989 };
10990
10991 dlg.finished(true);
10992 return Ok(response);
10993 }
10994 }
10995 }
10996 }
10997
10998 ///
10999 /// Sets the *request* property to the given value.
11000 ///
11001 /// Even though the property as already been set when instantiating this call,
11002 /// we provide this method for API completeness.
11003 pub fn request(mut self, new_value: Comment) -> CommentPatchCall<'a, C> {
11004 self._request = new_value;
11005 self
11006 }
11007 /// The ID of the file.
11008 ///
11009 /// Sets the *file id* path property to the given value.
11010 ///
11011 /// Even though the property as already been set when instantiating this call,
11012 /// we provide this method for API completeness.
11013 pub fn file_id(mut self, new_value: &str) -> CommentPatchCall<'a, C> {
11014 self._file_id = new_value.to_string();
11015 self
11016 }
11017 /// The ID of the comment.
11018 ///
11019 /// Sets the *comment id* path property to the given value.
11020 ///
11021 /// Even though the property as already been set when instantiating this call,
11022 /// we provide this method for API completeness.
11023 pub fn comment_id(mut self, new_value: &str) -> CommentPatchCall<'a, C> {
11024 self._comment_id = new_value.to_string();
11025 self
11026 }
11027 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11028 /// while executing the actual API request.
11029 ///
11030 /// ````text
11031 /// It should be used to handle progress information, and to implement a certain level of resilience.
11032 /// ````
11033 ///
11034 /// Sets the *delegate* property to the given value.
11035 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentPatchCall<'a, C> {
11036 self._delegate = Some(new_value);
11037 self
11038 }
11039
11040 /// Set any additional parameter of the query string used in the request.
11041 /// It should be used to set parameters which are not yet available through their own
11042 /// setters.
11043 ///
11044 /// Please note that this method must not be used to set any of the known parameters
11045 /// which have their own setter method. If done anyway, the request will fail.
11046 ///
11047 /// # Additional Parameters
11048 ///
11049 /// * *$.xgafv* (query-string) - V1 error format.
11050 /// * *access_token* (query-string) - OAuth access token.
11051 /// * *alt* (query-string) - Data format for response.
11052 /// * *callback* (query-string) - JSONP
11053 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11054 /// * *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.
11055 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11056 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11057 /// * *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.
11058 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11059 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11060 pub fn param<T>(mut self, name: T, value: T) -> CommentPatchCall<'a, C>
11061 where
11062 T: AsRef<str>,
11063 {
11064 self._additional_params
11065 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11066 self
11067 }
11068
11069 /// Identifies the authorization scope for the method you are building.
11070 ///
11071 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11072 /// [`Scope::Full`].
11073 ///
11074 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11075 /// tokens for more than one scope.
11076 ///
11077 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11078 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11079 /// sufficient, a read-write scope will do as well.
11080 pub fn add_scope<St>(mut self, scope: St) -> CommentPatchCall<'a, C>
11081 where
11082 St: AsRef<str>,
11083 {
11084 self._scopes.insert(String::from(scope.as_ref()));
11085 self
11086 }
11087 /// Identifies the authorization scope(s) for the method you are building.
11088 ///
11089 /// See [`Self::add_scope()`] for details.
11090 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentPatchCall<'a, C>
11091 where
11092 I: IntoIterator<Item = St>,
11093 St: AsRef<str>,
11094 {
11095 self._scopes
11096 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11097 self
11098 }
11099
11100 /// Removes all scopes, and no default scope will be used either.
11101 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11102 /// for details).
11103 pub fn clear_scopes(mut self) -> CommentPatchCall<'a, C> {
11104 self._scopes.clear();
11105 self
11106 }
11107}
11108
11109/// Updates an existing comment.
11110///
11111/// A builder for the *update* method supported by a *comment* resource.
11112/// It is not used directly, but through a [`CommentMethods`] instance.
11113///
11114/// # Example
11115///
11116/// Instantiate a resource method builder
11117///
11118/// ```test_harness,no_run
11119/// # extern crate hyper;
11120/// # extern crate hyper_rustls;
11121/// # extern crate google_drive2 as drive2;
11122/// use drive2::api::Comment;
11123/// # async fn dox() {
11124/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11125///
11126/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11127/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11128/// # .with_native_roots()
11129/// # .unwrap()
11130/// # .https_only()
11131/// # .enable_http2()
11132/// # .build();
11133///
11134/// # let executor = hyper_util::rt::TokioExecutor::new();
11135/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11136/// # secret,
11137/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11138/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11139/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11140/// # ),
11141/// # ).build().await.unwrap();
11142///
11143/// # let client = hyper_util::client::legacy::Client::builder(
11144/// # hyper_util::rt::TokioExecutor::new()
11145/// # )
11146/// # .build(
11147/// # hyper_rustls::HttpsConnectorBuilder::new()
11148/// # .with_native_roots()
11149/// # .unwrap()
11150/// # .https_or_http()
11151/// # .enable_http2()
11152/// # .build()
11153/// # );
11154/// # let mut hub = DriveHub::new(client, auth);
11155/// // As the method needs a request, you would usually fill it with the desired information
11156/// // into the respective structure. Some of the parts shown here might not be applicable !
11157/// // Values shown here are possibly random and not representative !
11158/// let mut req = Comment::default();
11159///
11160/// // You can configure optional parameters by calling the respective setters at will, and
11161/// // execute the final call using `doit()`.
11162/// // Values shown here are possibly random and not representative !
11163/// let result = hub.comments().update(req, "fileId", "commentId")
11164/// .doit().await;
11165/// # }
11166/// ```
11167pub struct CommentUpdateCall<'a, C>
11168where
11169 C: 'a,
11170{
11171 hub: &'a DriveHub<C>,
11172 _request: Comment,
11173 _file_id: String,
11174 _comment_id: String,
11175 _delegate: Option<&'a mut dyn common::Delegate>,
11176 _additional_params: HashMap<String, String>,
11177 _scopes: BTreeSet<String>,
11178}
11179
11180impl<'a, C> common::CallBuilder for CommentUpdateCall<'a, C> {}
11181
11182impl<'a, C> CommentUpdateCall<'a, C>
11183where
11184 C: common::Connector,
11185{
11186 /// Perform the operation you have build so far.
11187 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
11188 use std::borrow::Cow;
11189 use std::io::{Read, Seek};
11190
11191 use common::{url::Params, ToParts};
11192 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11193
11194 let mut dd = common::DefaultDelegate;
11195 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11196 dlg.begin(common::MethodInfo {
11197 id: "drive.comments.update",
11198 http_method: hyper::Method::PUT,
11199 });
11200
11201 for &field in ["alt", "fileId", "commentId"].iter() {
11202 if self._additional_params.contains_key(field) {
11203 dlg.finished(false);
11204 return Err(common::Error::FieldClash(field));
11205 }
11206 }
11207
11208 let mut params = Params::with_capacity(5 + self._additional_params.len());
11209 params.push("fileId", self._file_id);
11210 params.push("commentId", self._comment_id);
11211
11212 params.extend(self._additional_params.iter());
11213
11214 params.push("alt", "json");
11215 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}";
11216 if self._scopes.is_empty() {
11217 self._scopes.insert(Scope::Full.as_ref().to_string());
11218 }
11219
11220 #[allow(clippy::single_element_loop)]
11221 for &(find_this, param_name) in
11222 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
11223 {
11224 url = params.uri_replacement(url, param_name, find_this, false);
11225 }
11226 {
11227 let to_remove = ["commentId", "fileId"];
11228 params.remove_params(&to_remove);
11229 }
11230
11231 let url = params.parse_with_url(&url);
11232
11233 let mut json_mime_type = mime::APPLICATION_JSON;
11234 let mut request_value_reader = {
11235 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11236 common::remove_json_null_values(&mut value);
11237 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11238 serde_json::to_writer(&mut dst, &value).unwrap();
11239 dst
11240 };
11241 let request_size = request_value_reader
11242 .seek(std::io::SeekFrom::End(0))
11243 .unwrap();
11244 request_value_reader
11245 .seek(std::io::SeekFrom::Start(0))
11246 .unwrap();
11247
11248 loop {
11249 let token = match self
11250 .hub
11251 .auth
11252 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11253 .await
11254 {
11255 Ok(token) => token,
11256 Err(e) => match dlg.token(e) {
11257 Ok(token) => token,
11258 Err(e) => {
11259 dlg.finished(false);
11260 return Err(common::Error::MissingToken(e));
11261 }
11262 },
11263 };
11264 request_value_reader
11265 .seek(std::io::SeekFrom::Start(0))
11266 .unwrap();
11267 let mut req_result = {
11268 let client = &self.hub.client;
11269 dlg.pre_request();
11270 let mut req_builder = hyper::Request::builder()
11271 .method(hyper::Method::PUT)
11272 .uri(url.as_str())
11273 .header(USER_AGENT, self.hub._user_agent.clone());
11274
11275 if let Some(token) = token.as_ref() {
11276 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11277 }
11278
11279 let request = req_builder
11280 .header(CONTENT_TYPE, json_mime_type.to_string())
11281 .header(CONTENT_LENGTH, request_size as u64)
11282 .body(common::to_body(
11283 request_value_reader.get_ref().clone().into(),
11284 ));
11285
11286 client.request(request.unwrap()).await
11287 };
11288
11289 match req_result {
11290 Err(err) => {
11291 if let common::Retry::After(d) = dlg.http_error(&err) {
11292 sleep(d).await;
11293 continue;
11294 }
11295 dlg.finished(false);
11296 return Err(common::Error::HttpError(err));
11297 }
11298 Ok(res) => {
11299 let (mut parts, body) = res.into_parts();
11300 let mut body = common::Body::new(body);
11301 if !parts.status.is_success() {
11302 let bytes = common::to_bytes(body).await.unwrap_or_default();
11303 let error = serde_json::from_str(&common::to_string(&bytes));
11304 let response = common::to_response(parts, bytes.into());
11305
11306 if let common::Retry::After(d) =
11307 dlg.http_failure(&response, error.as_ref().ok())
11308 {
11309 sleep(d).await;
11310 continue;
11311 }
11312
11313 dlg.finished(false);
11314
11315 return Err(match error {
11316 Ok(value) => common::Error::BadRequest(value),
11317 _ => common::Error::Failure(response),
11318 });
11319 }
11320 let response = {
11321 let bytes = common::to_bytes(body).await.unwrap_or_default();
11322 let encoded = common::to_string(&bytes);
11323 match serde_json::from_str(&encoded) {
11324 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11325 Err(error) => {
11326 dlg.response_json_decode_error(&encoded, &error);
11327 return Err(common::Error::JsonDecodeError(
11328 encoded.to_string(),
11329 error,
11330 ));
11331 }
11332 }
11333 };
11334
11335 dlg.finished(true);
11336 return Ok(response);
11337 }
11338 }
11339 }
11340 }
11341
11342 ///
11343 /// Sets the *request* property to the given value.
11344 ///
11345 /// Even though the property as already been set when instantiating this call,
11346 /// we provide this method for API completeness.
11347 pub fn request(mut self, new_value: Comment) -> CommentUpdateCall<'a, C> {
11348 self._request = new_value;
11349 self
11350 }
11351 /// The ID of the file.
11352 ///
11353 /// Sets the *file id* path property to the given value.
11354 ///
11355 /// Even though the property as already been set when instantiating this call,
11356 /// we provide this method for API completeness.
11357 pub fn file_id(mut self, new_value: &str) -> CommentUpdateCall<'a, C> {
11358 self._file_id = new_value.to_string();
11359 self
11360 }
11361 /// The ID of the comment.
11362 ///
11363 /// Sets the *comment id* path property to the given value.
11364 ///
11365 /// Even though the property as already been set when instantiating this call,
11366 /// we provide this method for API completeness.
11367 pub fn comment_id(mut self, new_value: &str) -> CommentUpdateCall<'a, C> {
11368 self._comment_id = new_value.to_string();
11369 self
11370 }
11371 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11372 /// while executing the actual API request.
11373 ///
11374 /// ````text
11375 /// It should be used to handle progress information, and to implement a certain level of resilience.
11376 /// ````
11377 ///
11378 /// Sets the *delegate* property to the given value.
11379 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentUpdateCall<'a, C> {
11380 self._delegate = Some(new_value);
11381 self
11382 }
11383
11384 /// Set any additional parameter of the query string used in the request.
11385 /// It should be used to set parameters which are not yet available through their own
11386 /// setters.
11387 ///
11388 /// Please note that this method must not be used to set any of the known parameters
11389 /// which have their own setter method. If done anyway, the request will fail.
11390 ///
11391 /// # Additional Parameters
11392 ///
11393 /// * *$.xgafv* (query-string) - V1 error format.
11394 /// * *access_token* (query-string) - OAuth access token.
11395 /// * *alt* (query-string) - Data format for response.
11396 /// * *callback* (query-string) - JSONP
11397 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11398 /// * *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.
11399 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11400 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11401 /// * *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.
11402 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11403 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11404 pub fn param<T>(mut self, name: T, value: T) -> CommentUpdateCall<'a, C>
11405 where
11406 T: AsRef<str>,
11407 {
11408 self._additional_params
11409 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11410 self
11411 }
11412
11413 /// Identifies the authorization scope for the method you are building.
11414 ///
11415 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11416 /// [`Scope::Full`].
11417 ///
11418 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11419 /// tokens for more than one scope.
11420 ///
11421 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11422 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11423 /// sufficient, a read-write scope will do as well.
11424 pub fn add_scope<St>(mut self, scope: St) -> CommentUpdateCall<'a, C>
11425 where
11426 St: AsRef<str>,
11427 {
11428 self._scopes.insert(String::from(scope.as_ref()));
11429 self
11430 }
11431 /// Identifies the authorization scope(s) for the method you are building.
11432 ///
11433 /// See [`Self::add_scope()`] for details.
11434 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentUpdateCall<'a, C>
11435 where
11436 I: IntoIterator<Item = St>,
11437 St: AsRef<str>,
11438 {
11439 self._scopes
11440 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11441 self
11442 }
11443
11444 /// Removes all scopes, and no default scope will be used either.
11445 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11446 /// for details).
11447 pub fn clear_scopes(mut self) -> CommentUpdateCall<'a, C> {
11448 self._scopes.clear();
11449 self
11450 }
11451}
11452
11453/// Permanently deletes a shared drive for which the user is an `organizer`. The shared drive cannot contain any untrashed items.
11454///
11455/// A builder for the *delete* method supported by a *drive* resource.
11456/// It is not used directly, but through a [`DriveMethods`] instance.
11457///
11458/// # Example
11459///
11460/// Instantiate a resource method builder
11461///
11462/// ```test_harness,no_run
11463/// # extern crate hyper;
11464/// # extern crate hyper_rustls;
11465/// # extern crate google_drive2 as drive2;
11466/// # async fn dox() {
11467/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11468///
11469/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11470/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11471/// # .with_native_roots()
11472/// # .unwrap()
11473/// # .https_only()
11474/// # .enable_http2()
11475/// # .build();
11476///
11477/// # let executor = hyper_util::rt::TokioExecutor::new();
11478/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11479/// # secret,
11480/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11481/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11482/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11483/// # ),
11484/// # ).build().await.unwrap();
11485///
11486/// # let client = hyper_util::client::legacy::Client::builder(
11487/// # hyper_util::rt::TokioExecutor::new()
11488/// # )
11489/// # .build(
11490/// # hyper_rustls::HttpsConnectorBuilder::new()
11491/// # .with_native_roots()
11492/// # .unwrap()
11493/// # .https_or_http()
11494/// # .enable_http2()
11495/// # .build()
11496/// # );
11497/// # let mut hub = DriveHub::new(client, auth);
11498/// // You can configure optional parameters by calling the respective setters at will, and
11499/// // execute the final call using `doit()`.
11500/// // Values shown here are possibly random and not representative !
11501/// let result = hub.drives().delete("driveId")
11502/// .use_domain_admin_access(true)
11503/// .allow_item_deletion(false)
11504/// .doit().await;
11505/// # }
11506/// ```
11507pub struct DriveDeleteCall<'a, C>
11508where
11509 C: 'a,
11510{
11511 hub: &'a DriveHub<C>,
11512 _drive_id: String,
11513 _use_domain_admin_access: Option<bool>,
11514 _allow_item_deletion: Option<bool>,
11515 _delegate: Option<&'a mut dyn common::Delegate>,
11516 _additional_params: HashMap<String, String>,
11517 _scopes: BTreeSet<String>,
11518}
11519
11520impl<'a, C> common::CallBuilder for DriveDeleteCall<'a, C> {}
11521
11522impl<'a, C> DriveDeleteCall<'a, C>
11523where
11524 C: common::Connector,
11525{
11526 /// Perform the operation you have build so far.
11527 pub async fn doit(mut self) -> common::Result<common::Response> {
11528 use std::borrow::Cow;
11529 use std::io::{Read, Seek};
11530
11531 use common::{url::Params, ToParts};
11532 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11533
11534 let mut dd = common::DefaultDelegate;
11535 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11536 dlg.begin(common::MethodInfo {
11537 id: "drive.drives.delete",
11538 http_method: hyper::Method::DELETE,
11539 });
11540
11541 for &field in ["driveId", "useDomainAdminAccess", "allowItemDeletion"].iter() {
11542 if self._additional_params.contains_key(field) {
11543 dlg.finished(false);
11544 return Err(common::Error::FieldClash(field));
11545 }
11546 }
11547
11548 let mut params = Params::with_capacity(4 + self._additional_params.len());
11549 params.push("driveId", self._drive_id);
11550 if let Some(value) = self._use_domain_admin_access.as_ref() {
11551 params.push("useDomainAdminAccess", value.to_string());
11552 }
11553 if let Some(value) = self._allow_item_deletion.as_ref() {
11554 params.push("allowItemDeletion", value.to_string());
11555 }
11556
11557 params.extend(self._additional_params.iter());
11558
11559 let mut url = self.hub._base_url.clone() + "drives/{driveId}";
11560 if self._scopes.is_empty() {
11561 self._scopes.insert(Scope::Full.as_ref().to_string());
11562 }
11563
11564 #[allow(clippy::single_element_loop)]
11565 for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
11566 url = params.uri_replacement(url, param_name, find_this, false);
11567 }
11568 {
11569 let to_remove = ["driveId"];
11570 params.remove_params(&to_remove);
11571 }
11572
11573 let url = params.parse_with_url(&url);
11574
11575 loop {
11576 let token = match self
11577 .hub
11578 .auth
11579 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11580 .await
11581 {
11582 Ok(token) => token,
11583 Err(e) => match dlg.token(e) {
11584 Ok(token) => token,
11585 Err(e) => {
11586 dlg.finished(false);
11587 return Err(common::Error::MissingToken(e));
11588 }
11589 },
11590 };
11591 let mut req_result = {
11592 let client = &self.hub.client;
11593 dlg.pre_request();
11594 let mut req_builder = hyper::Request::builder()
11595 .method(hyper::Method::DELETE)
11596 .uri(url.as_str())
11597 .header(USER_AGENT, self.hub._user_agent.clone());
11598
11599 if let Some(token) = token.as_ref() {
11600 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11601 }
11602
11603 let request = req_builder
11604 .header(CONTENT_LENGTH, 0_u64)
11605 .body(common::to_body::<String>(None));
11606
11607 client.request(request.unwrap()).await
11608 };
11609
11610 match req_result {
11611 Err(err) => {
11612 if let common::Retry::After(d) = dlg.http_error(&err) {
11613 sleep(d).await;
11614 continue;
11615 }
11616 dlg.finished(false);
11617 return Err(common::Error::HttpError(err));
11618 }
11619 Ok(res) => {
11620 let (mut parts, body) = res.into_parts();
11621 let mut body = common::Body::new(body);
11622 if !parts.status.is_success() {
11623 let bytes = common::to_bytes(body).await.unwrap_or_default();
11624 let error = serde_json::from_str(&common::to_string(&bytes));
11625 let response = common::to_response(parts, bytes.into());
11626
11627 if let common::Retry::After(d) =
11628 dlg.http_failure(&response, error.as_ref().ok())
11629 {
11630 sleep(d).await;
11631 continue;
11632 }
11633
11634 dlg.finished(false);
11635
11636 return Err(match error {
11637 Ok(value) => common::Error::BadRequest(value),
11638 _ => common::Error::Failure(response),
11639 });
11640 }
11641 let response = common::Response::from_parts(parts, body);
11642
11643 dlg.finished(true);
11644 return Ok(response);
11645 }
11646 }
11647 }
11648 }
11649
11650 /// The ID of the shared drive.
11651 ///
11652 /// Sets the *drive id* path property to the given value.
11653 ///
11654 /// Even though the property as already been set when instantiating this call,
11655 /// we provide this method for API completeness.
11656 pub fn drive_id(mut self, new_value: &str) -> DriveDeleteCall<'a, C> {
11657 self._drive_id = new_value.to_string();
11658 self
11659 }
11660 /// 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.
11661 ///
11662 /// Sets the *use domain admin access* query property to the given value.
11663 pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveDeleteCall<'a, C> {
11664 self._use_domain_admin_access = Some(new_value);
11665 self
11666 }
11667 /// Whether any items inside the shared drive should also be deleted. This option is only supported when `useDomainAdminAccess` is also set to `true`.
11668 ///
11669 /// Sets the *allow item deletion* query property to the given value.
11670 pub fn allow_item_deletion(mut self, new_value: bool) -> DriveDeleteCall<'a, C> {
11671 self._allow_item_deletion = Some(new_value);
11672 self
11673 }
11674 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11675 /// while executing the actual API request.
11676 ///
11677 /// ````text
11678 /// It should be used to handle progress information, and to implement a certain level of resilience.
11679 /// ````
11680 ///
11681 /// Sets the *delegate* property to the given value.
11682 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveDeleteCall<'a, C> {
11683 self._delegate = Some(new_value);
11684 self
11685 }
11686
11687 /// Set any additional parameter of the query string used in the request.
11688 /// It should be used to set parameters which are not yet available through their own
11689 /// setters.
11690 ///
11691 /// Please note that this method must not be used to set any of the known parameters
11692 /// which have their own setter method. If done anyway, the request will fail.
11693 ///
11694 /// # Additional Parameters
11695 ///
11696 /// * *$.xgafv* (query-string) - V1 error format.
11697 /// * *access_token* (query-string) - OAuth access token.
11698 /// * *alt* (query-string) - Data format for response.
11699 /// * *callback* (query-string) - JSONP
11700 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11701 /// * *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.
11702 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11703 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11704 /// * *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.
11705 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11706 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11707 pub fn param<T>(mut self, name: T, value: T) -> DriveDeleteCall<'a, C>
11708 where
11709 T: AsRef<str>,
11710 {
11711 self._additional_params
11712 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11713 self
11714 }
11715
11716 /// Identifies the authorization scope for the method you are building.
11717 ///
11718 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11719 /// [`Scope::Full`].
11720 ///
11721 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11722 /// tokens for more than one scope.
11723 ///
11724 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11725 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11726 /// sufficient, a read-write scope will do as well.
11727 pub fn add_scope<St>(mut self, scope: St) -> DriveDeleteCall<'a, C>
11728 where
11729 St: AsRef<str>,
11730 {
11731 self._scopes.insert(String::from(scope.as_ref()));
11732 self
11733 }
11734 /// Identifies the authorization scope(s) for the method you are building.
11735 ///
11736 /// See [`Self::add_scope()`] for details.
11737 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveDeleteCall<'a, C>
11738 where
11739 I: IntoIterator<Item = St>,
11740 St: AsRef<str>,
11741 {
11742 self._scopes
11743 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11744 self
11745 }
11746
11747 /// Removes all scopes, and no default scope will be used either.
11748 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11749 /// for details).
11750 pub fn clear_scopes(mut self) -> DriveDeleteCall<'a, C> {
11751 self._scopes.clear();
11752 self
11753 }
11754}
11755
11756/// Gets a shared drive's metadata by ID.
11757///
11758/// A builder for the *get* method supported by a *drive* resource.
11759/// It is not used directly, but through a [`DriveMethods`] instance.
11760///
11761/// # Example
11762///
11763/// Instantiate a resource method builder
11764///
11765/// ```test_harness,no_run
11766/// # extern crate hyper;
11767/// # extern crate hyper_rustls;
11768/// # extern crate google_drive2 as drive2;
11769/// # async fn dox() {
11770/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11771///
11772/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11773/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11774/// # .with_native_roots()
11775/// # .unwrap()
11776/// # .https_only()
11777/// # .enable_http2()
11778/// # .build();
11779///
11780/// # let executor = hyper_util::rt::TokioExecutor::new();
11781/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11782/// # secret,
11783/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11784/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11785/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11786/// # ),
11787/// # ).build().await.unwrap();
11788///
11789/// # let client = hyper_util::client::legacy::Client::builder(
11790/// # hyper_util::rt::TokioExecutor::new()
11791/// # )
11792/// # .build(
11793/// # hyper_rustls::HttpsConnectorBuilder::new()
11794/// # .with_native_roots()
11795/// # .unwrap()
11796/// # .https_or_http()
11797/// # .enable_http2()
11798/// # .build()
11799/// # );
11800/// # let mut hub = DriveHub::new(client, auth);
11801/// // You can configure optional parameters by calling the respective setters at will, and
11802/// // execute the final call using `doit()`.
11803/// // Values shown here are possibly random and not representative !
11804/// let result = hub.drives().get("driveId")
11805/// .use_domain_admin_access(false)
11806/// .doit().await;
11807/// # }
11808/// ```
11809pub struct DriveGetCall<'a, C>
11810where
11811 C: 'a,
11812{
11813 hub: &'a DriveHub<C>,
11814 _drive_id: String,
11815 _use_domain_admin_access: Option<bool>,
11816 _delegate: Option<&'a mut dyn common::Delegate>,
11817 _additional_params: HashMap<String, String>,
11818 _scopes: BTreeSet<String>,
11819}
11820
11821impl<'a, C> common::CallBuilder for DriveGetCall<'a, C> {}
11822
11823impl<'a, C> DriveGetCall<'a, C>
11824where
11825 C: common::Connector,
11826{
11827 /// Perform the operation you have build so far.
11828 pub async fn doit(mut self) -> common::Result<(common::Response, Drive)> {
11829 use std::borrow::Cow;
11830 use std::io::{Read, Seek};
11831
11832 use common::{url::Params, ToParts};
11833 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11834
11835 let mut dd = common::DefaultDelegate;
11836 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11837 dlg.begin(common::MethodInfo {
11838 id: "drive.drives.get",
11839 http_method: hyper::Method::GET,
11840 });
11841
11842 for &field in ["alt", "driveId", "useDomainAdminAccess"].iter() {
11843 if self._additional_params.contains_key(field) {
11844 dlg.finished(false);
11845 return Err(common::Error::FieldClash(field));
11846 }
11847 }
11848
11849 let mut params = Params::with_capacity(4 + self._additional_params.len());
11850 params.push("driveId", self._drive_id);
11851 if let Some(value) = self._use_domain_admin_access.as_ref() {
11852 params.push("useDomainAdminAccess", value.to_string());
11853 }
11854
11855 params.extend(self._additional_params.iter());
11856
11857 params.push("alt", "json");
11858 let mut url = self.hub._base_url.clone() + "drives/{driveId}";
11859 if self._scopes.is_empty() {
11860 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11861 }
11862
11863 #[allow(clippy::single_element_loop)]
11864 for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
11865 url = params.uri_replacement(url, param_name, find_this, false);
11866 }
11867 {
11868 let to_remove = ["driveId"];
11869 params.remove_params(&to_remove);
11870 }
11871
11872 let url = params.parse_with_url(&url);
11873
11874 loop {
11875 let token = match self
11876 .hub
11877 .auth
11878 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11879 .await
11880 {
11881 Ok(token) => token,
11882 Err(e) => match dlg.token(e) {
11883 Ok(token) => token,
11884 Err(e) => {
11885 dlg.finished(false);
11886 return Err(common::Error::MissingToken(e));
11887 }
11888 },
11889 };
11890 let mut req_result = {
11891 let client = &self.hub.client;
11892 dlg.pre_request();
11893 let mut req_builder = hyper::Request::builder()
11894 .method(hyper::Method::GET)
11895 .uri(url.as_str())
11896 .header(USER_AGENT, self.hub._user_agent.clone());
11897
11898 if let Some(token) = token.as_ref() {
11899 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11900 }
11901
11902 let request = req_builder
11903 .header(CONTENT_LENGTH, 0_u64)
11904 .body(common::to_body::<String>(None));
11905
11906 client.request(request.unwrap()).await
11907 };
11908
11909 match req_result {
11910 Err(err) => {
11911 if let common::Retry::After(d) = dlg.http_error(&err) {
11912 sleep(d).await;
11913 continue;
11914 }
11915 dlg.finished(false);
11916 return Err(common::Error::HttpError(err));
11917 }
11918 Ok(res) => {
11919 let (mut parts, body) = res.into_parts();
11920 let mut body = common::Body::new(body);
11921 if !parts.status.is_success() {
11922 let bytes = common::to_bytes(body).await.unwrap_or_default();
11923 let error = serde_json::from_str(&common::to_string(&bytes));
11924 let response = common::to_response(parts, bytes.into());
11925
11926 if let common::Retry::After(d) =
11927 dlg.http_failure(&response, error.as_ref().ok())
11928 {
11929 sleep(d).await;
11930 continue;
11931 }
11932
11933 dlg.finished(false);
11934
11935 return Err(match error {
11936 Ok(value) => common::Error::BadRequest(value),
11937 _ => common::Error::Failure(response),
11938 });
11939 }
11940 let response = {
11941 let bytes = common::to_bytes(body).await.unwrap_or_default();
11942 let encoded = common::to_string(&bytes);
11943 match serde_json::from_str(&encoded) {
11944 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11945 Err(error) => {
11946 dlg.response_json_decode_error(&encoded, &error);
11947 return Err(common::Error::JsonDecodeError(
11948 encoded.to_string(),
11949 error,
11950 ));
11951 }
11952 }
11953 };
11954
11955 dlg.finished(true);
11956 return Ok(response);
11957 }
11958 }
11959 }
11960 }
11961
11962 /// The ID of the shared drive.
11963 ///
11964 /// Sets the *drive id* path property to the given value.
11965 ///
11966 /// Even though the property as already been set when instantiating this call,
11967 /// we provide this method for API completeness.
11968 pub fn drive_id(mut self, new_value: &str) -> DriveGetCall<'a, C> {
11969 self._drive_id = new_value.to_string();
11970 self
11971 }
11972 /// 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.
11973 ///
11974 /// Sets the *use domain admin access* query property to the given value.
11975 pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveGetCall<'a, C> {
11976 self._use_domain_admin_access = Some(new_value);
11977 self
11978 }
11979 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11980 /// while executing the actual API request.
11981 ///
11982 /// ````text
11983 /// It should be used to handle progress information, and to implement a certain level of resilience.
11984 /// ````
11985 ///
11986 /// Sets the *delegate* property to the given value.
11987 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveGetCall<'a, C> {
11988 self._delegate = Some(new_value);
11989 self
11990 }
11991
11992 /// Set any additional parameter of the query string used in the request.
11993 /// It should be used to set parameters which are not yet available through their own
11994 /// setters.
11995 ///
11996 /// Please note that this method must not be used to set any of the known parameters
11997 /// which have their own setter method. If done anyway, the request will fail.
11998 ///
11999 /// # Additional Parameters
12000 ///
12001 /// * *$.xgafv* (query-string) - V1 error format.
12002 /// * *access_token* (query-string) - OAuth access token.
12003 /// * *alt* (query-string) - Data format for response.
12004 /// * *callback* (query-string) - JSONP
12005 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12006 /// * *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.
12007 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12008 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12009 /// * *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.
12010 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12011 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12012 pub fn param<T>(mut self, name: T, value: T) -> DriveGetCall<'a, C>
12013 where
12014 T: AsRef<str>,
12015 {
12016 self._additional_params
12017 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12018 self
12019 }
12020
12021 /// Identifies the authorization scope for the method you are building.
12022 ///
12023 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12024 /// [`Scope::Readonly`].
12025 ///
12026 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12027 /// tokens for more than one scope.
12028 ///
12029 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12030 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12031 /// sufficient, a read-write scope will do as well.
12032 pub fn add_scope<St>(mut self, scope: St) -> DriveGetCall<'a, C>
12033 where
12034 St: AsRef<str>,
12035 {
12036 self._scopes.insert(String::from(scope.as_ref()));
12037 self
12038 }
12039 /// Identifies the authorization scope(s) for the method you are building.
12040 ///
12041 /// See [`Self::add_scope()`] for details.
12042 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveGetCall<'a, C>
12043 where
12044 I: IntoIterator<Item = St>,
12045 St: AsRef<str>,
12046 {
12047 self._scopes
12048 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12049 self
12050 }
12051
12052 /// Removes all scopes, and no default scope will be used either.
12053 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12054 /// for details).
12055 pub fn clear_scopes(mut self) -> DriveGetCall<'a, C> {
12056 self._scopes.clear();
12057 self
12058 }
12059}
12060
12061/// Hides a shared drive from the default view.
12062///
12063/// A builder for the *hide* method supported by a *drive* resource.
12064/// It is not used directly, but through a [`DriveMethods`] instance.
12065///
12066/// # Example
12067///
12068/// Instantiate a resource method builder
12069///
12070/// ```test_harness,no_run
12071/// # extern crate hyper;
12072/// # extern crate hyper_rustls;
12073/// # extern crate google_drive2 as drive2;
12074/// # async fn dox() {
12075/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12076///
12077/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12078/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12079/// # .with_native_roots()
12080/// # .unwrap()
12081/// # .https_only()
12082/// # .enable_http2()
12083/// # .build();
12084///
12085/// # let executor = hyper_util::rt::TokioExecutor::new();
12086/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12087/// # secret,
12088/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12089/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12090/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12091/// # ),
12092/// # ).build().await.unwrap();
12093///
12094/// # let client = hyper_util::client::legacy::Client::builder(
12095/// # hyper_util::rt::TokioExecutor::new()
12096/// # )
12097/// # .build(
12098/// # hyper_rustls::HttpsConnectorBuilder::new()
12099/// # .with_native_roots()
12100/// # .unwrap()
12101/// # .https_or_http()
12102/// # .enable_http2()
12103/// # .build()
12104/// # );
12105/// # let mut hub = DriveHub::new(client, auth);
12106/// // You can configure optional parameters by calling the respective setters at will, and
12107/// // execute the final call using `doit()`.
12108/// // Values shown here are possibly random and not representative !
12109/// let result = hub.drives().hide("driveId")
12110/// .doit().await;
12111/// # }
12112/// ```
12113pub struct DriveHideCall<'a, C>
12114where
12115 C: 'a,
12116{
12117 hub: &'a DriveHub<C>,
12118 _drive_id: String,
12119 _delegate: Option<&'a mut dyn common::Delegate>,
12120 _additional_params: HashMap<String, String>,
12121 _scopes: BTreeSet<String>,
12122}
12123
12124impl<'a, C> common::CallBuilder for DriveHideCall<'a, C> {}
12125
12126impl<'a, C> DriveHideCall<'a, C>
12127where
12128 C: common::Connector,
12129{
12130 /// Perform the operation you have build so far.
12131 pub async fn doit(mut self) -> common::Result<(common::Response, Drive)> {
12132 use std::borrow::Cow;
12133 use std::io::{Read, Seek};
12134
12135 use common::{url::Params, ToParts};
12136 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12137
12138 let mut dd = common::DefaultDelegate;
12139 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12140 dlg.begin(common::MethodInfo {
12141 id: "drive.drives.hide",
12142 http_method: hyper::Method::POST,
12143 });
12144
12145 for &field in ["alt", "driveId"].iter() {
12146 if self._additional_params.contains_key(field) {
12147 dlg.finished(false);
12148 return Err(common::Error::FieldClash(field));
12149 }
12150 }
12151
12152 let mut params = Params::with_capacity(3 + self._additional_params.len());
12153 params.push("driveId", self._drive_id);
12154
12155 params.extend(self._additional_params.iter());
12156
12157 params.push("alt", "json");
12158 let mut url = self.hub._base_url.clone() + "drives/{driveId}/hide";
12159 if self._scopes.is_empty() {
12160 self._scopes.insert(Scope::Full.as_ref().to_string());
12161 }
12162
12163 #[allow(clippy::single_element_loop)]
12164 for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
12165 url = params.uri_replacement(url, param_name, find_this, false);
12166 }
12167 {
12168 let to_remove = ["driveId"];
12169 params.remove_params(&to_remove);
12170 }
12171
12172 let url = params.parse_with_url(&url);
12173
12174 loop {
12175 let token = match self
12176 .hub
12177 .auth
12178 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12179 .await
12180 {
12181 Ok(token) => token,
12182 Err(e) => match dlg.token(e) {
12183 Ok(token) => token,
12184 Err(e) => {
12185 dlg.finished(false);
12186 return Err(common::Error::MissingToken(e));
12187 }
12188 },
12189 };
12190 let mut req_result = {
12191 let client = &self.hub.client;
12192 dlg.pre_request();
12193 let mut req_builder = hyper::Request::builder()
12194 .method(hyper::Method::POST)
12195 .uri(url.as_str())
12196 .header(USER_AGENT, self.hub._user_agent.clone());
12197
12198 if let Some(token) = token.as_ref() {
12199 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12200 }
12201
12202 let request = req_builder
12203 .header(CONTENT_LENGTH, 0_u64)
12204 .body(common::to_body::<String>(None));
12205
12206 client.request(request.unwrap()).await
12207 };
12208
12209 match req_result {
12210 Err(err) => {
12211 if let common::Retry::After(d) = dlg.http_error(&err) {
12212 sleep(d).await;
12213 continue;
12214 }
12215 dlg.finished(false);
12216 return Err(common::Error::HttpError(err));
12217 }
12218 Ok(res) => {
12219 let (mut parts, body) = res.into_parts();
12220 let mut body = common::Body::new(body);
12221 if !parts.status.is_success() {
12222 let bytes = common::to_bytes(body).await.unwrap_or_default();
12223 let error = serde_json::from_str(&common::to_string(&bytes));
12224 let response = common::to_response(parts, bytes.into());
12225
12226 if let common::Retry::After(d) =
12227 dlg.http_failure(&response, error.as_ref().ok())
12228 {
12229 sleep(d).await;
12230 continue;
12231 }
12232
12233 dlg.finished(false);
12234
12235 return Err(match error {
12236 Ok(value) => common::Error::BadRequest(value),
12237 _ => common::Error::Failure(response),
12238 });
12239 }
12240 let response = {
12241 let bytes = common::to_bytes(body).await.unwrap_or_default();
12242 let encoded = common::to_string(&bytes);
12243 match serde_json::from_str(&encoded) {
12244 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12245 Err(error) => {
12246 dlg.response_json_decode_error(&encoded, &error);
12247 return Err(common::Error::JsonDecodeError(
12248 encoded.to_string(),
12249 error,
12250 ));
12251 }
12252 }
12253 };
12254
12255 dlg.finished(true);
12256 return Ok(response);
12257 }
12258 }
12259 }
12260 }
12261
12262 /// The ID of the shared drive.
12263 ///
12264 /// Sets the *drive id* path property to the given value.
12265 ///
12266 /// Even though the property as already been set when instantiating this call,
12267 /// we provide this method for API completeness.
12268 pub fn drive_id(mut self, new_value: &str) -> DriveHideCall<'a, C> {
12269 self._drive_id = new_value.to_string();
12270 self
12271 }
12272 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12273 /// while executing the actual API request.
12274 ///
12275 /// ````text
12276 /// It should be used to handle progress information, and to implement a certain level of resilience.
12277 /// ````
12278 ///
12279 /// Sets the *delegate* property to the given value.
12280 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveHideCall<'a, C> {
12281 self._delegate = Some(new_value);
12282 self
12283 }
12284
12285 /// Set any additional parameter of the query string used in the request.
12286 /// It should be used to set parameters which are not yet available through their own
12287 /// setters.
12288 ///
12289 /// Please note that this method must not be used to set any of the known parameters
12290 /// which have their own setter method. If done anyway, the request will fail.
12291 ///
12292 /// # Additional Parameters
12293 ///
12294 /// * *$.xgafv* (query-string) - V1 error format.
12295 /// * *access_token* (query-string) - OAuth access token.
12296 /// * *alt* (query-string) - Data format for response.
12297 /// * *callback* (query-string) - JSONP
12298 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12299 /// * *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.
12300 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12301 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12302 /// * *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.
12303 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12304 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12305 pub fn param<T>(mut self, name: T, value: T) -> DriveHideCall<'a, C>
12306 where
12307 T: AsRef<str>,
12308 {
12309 self._additional_params
12310 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12311 self
12312 }
12313
12314 /// Identifies the authorization scope for the method you are building.
12315 ///
12316 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12317 /// [`Scope::Full`].
12318 ///
12319 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12320 /// tokens for more than one scope.
12321 ///
12322 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12323 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12324 /// sufficient, a read-write scope will do as well.
12325 pub fn add_scope<St>(mut self, scope: St) -> DriveHideCall<'a, C>
12326 where
12327 St: AsRef<str>,
12328 {
12329 self._scopes.insert(String::from(scope.as_ref()));
12330 self
12331 }
12332 /// Identifies the authorization scope(s) for the method you are building.
12333 ///
12334 /// See [`Self::add_scope()`] for details.
12335 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveHideCall<'a, C>
12336 where
12337 I: IntoIterator<Item = St>,
12338 St: AsRef<str>,
12339 {
12340 self._scopes
12341 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12342 self
12343 }
12344
12345 /// Removes all scopes, and no default scope will be used either.
12346 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12347 /// for details).
12348 pub fn clear_scopes(mut self) -> DriveHideCall<'a, C> {
12349 self._scopes.clear();
12350 self
12351 }
12352}
12353
12354/// Creates a new shared drive.
12355///
12356/// A builder for the *insert* method supported by a *drive* resource.
12357/// It is not used directly, but through a [`DriveMethods`] instance.
12358///
12359/// # Example
12360///
12361/// Instantiate a resource method builder
12362///
12363/// ```test_harness,no_run
12364/// # extern crate hyper;
12365/// # extern crate hyper_rustls;
12366/// # extern crate google_drive2 as drive2;
12367/// use drive2::api::Drive;
12368/// # async fn dox() {
12369/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12370///
12371/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12372/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12373/// # .with_native_roots()
12374/// # .unwrap()
12375/// # .https_only()
12376/// # .enable_http2()
12377/// # .build();
12378///
12379/// # let executor = hyper_util::rt::TokioExecutor::new();
12380/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12381/// # secret,
12382/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12383/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12384/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12385/// # ),
12386/// # ).build().await.unwrap();
12387///
12388/// # let client = hyper_util::client::legacy::Client::builder(
12389/// # hyper_util::rt::TokioExecutor::new()
12390/// # )
12391/// # .build(
12392/// # hyper_rustls::HttpsConnectorBuilder::new()
12393/// # .with_native_roots()
12394/// # .unwrap()
12395/// # .https_or_http()
12396/// # .enable_http2()
12397/// # .build()
12398/// # );
12399/// # let mut hub = DriveHub::new(client, auth);
12400/// // As the method needs a request, you would usually fill it with the desired information
12401/// // into the respective structure. Some of the parts shown here might not be applicable !
12402/// // Values shown here are possibly random and not representative !
12403/// let mut req = Drive::default();
12404///
12405/// // You can configure optional parameters by calling the respective setters at will, and
12406/// // execute the final call using `doit()`.
12407/// // Values shown here are possibly random and not representative !
12408/// let result = hub.drives().insert(req, "requestId")
12409/// .doit().await;
12410/// # }
12411/// ```
12412pub struct DriveInsertCall<'a, C>
12413where
12414 C: 'a,
12415{
12416 hub: &'a DriveHub<C>,
12417 _request: Drive,
12418 _request_id: String,
12419 _delegate: Option<&'a mut dyn common::Delegate>,
12420 _additional_params: HashMap<String, String>,
12421 _scopes: BTreeSet<String>,
12422}
12423
12424impl<'a, C> common::CallBuilder for DriveInsertCall<'a, C> {}
12425
12426impl<'a, C> DriveInsertCall<'a, C>
12427where
12428 C: common::Connector,
12429{
12430 /// Perform the operation you have build so far.
12431 pub async fn doit(mut self) -> common::Result<(common::Response, Drive)> {
12432 use std::borrow::Cow;
12433 use std::io::{Read, Seek};
12434
12435 use common::{url::Params, ToParts};
12436 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12437
12438 let mut dd = common::DefaultDelegate;
12439 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12440 dlg.begin(common::MethodInfo {
12441 id: "drive.drives.insert",
12442 http_method: hyper::Method::POST,
12443 });
12444
12445 for &field in ["alt", "requestId"].iter() {
12446 if self._additional_params.contains_key(field) {
12447 dlg.finished(false);
12448 return Err(common::Error::FieldClash(field));
12449 }
12450 }
12451
12452 let mut params = Params::with_capacity(4 + self._additional_params.len());
12453 params.push("requestId", self._request_id);
12454
12455 params.extend(self._additional_params.iter());
12456
12457 params.push("alt", "json");
12458 let mut url = self.hub._base_url.clone() + "drives";
12459 if self._scopes.is_empty() {
12460 self._scopes.insert(Scope::Full.as_ref().to_string());
12461 }
12462
12463 let url = params.parse_with_url(&url);
12464
12465 let mut json_mime_type = mime::APPLICATION_JSON;
12466 let mut request_value_reader = {
12467 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12468 common::remove_json_null_values(&mut value);
12469 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12470 serde_json::to_writer(&mut dst, &value).unwrap();
12471 dst
12472 };
12473 let request_size = request_value_reader
12474 .seek(std::io::SeekFrom::End(0))
12475 .unwrap();
12476 request_value_reader
12477 .seek(std::io::SeekFrom::Start(0))
12478 .unwrap();
12479
12480 loop {
12481 let token = match self
12482 .hub
12483 .auth
12484 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12485 .await
12486 {
12487 Ok(token) => token,
12488 Err(e) => match dlg.token(e) {
12489 Ok(token) => token,
12490 Err(e) => {
12491 dlg.finished(false);
12492 return Err(common::Error::MissingToken(e));
12493 }
12494 },
12495 };
12496 request_value_reader
12497 .seek(std::io::SeekFrom::Start(0))
12498 .unwrap();
12499 let mut req_result = {
12500 let client = &self.hub.client;
12501 dlg.pre_request();
12502 let mut req_builder = hyper::Request::builder()
12503 .method(hyper::Method::POST)
12504 .uri(url.as_str())
12505 .header(USER_AGENT, self.hub._user_agent.clone());
12506
12507 if let Some(token) = token.as_ref() {
12508 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12509 }
12510
12511 let request = req_builder
12512 .header(CONTENT_TYPE, json_mime_type.to_string())
12513 .header(CONTENT_LENGTH, request_size as u64)
12514 .body(common::to_body(
12515 request_value_reader.get_ref().clone().into(),
12516 ));
12517
12518 client.request(request.unwrap()).await
12519 };
12520
12521 match req_result {
12522 Err(err) => {
12523 if let common::Retry::After(d) = dlg.http_error(&err) {
12524 sleep(d).await;
12525 continue;
12526 }
12527 dlg.finished(false);
12528 return Err(common::Error::HttpError(err));
12529 }
12530 Ok(res) => {
12531 let (mut parts, body) = res.into_parts();
12532 let mut body = common::Body::new(body);
12533 if !parts.status.is_success() {
12534 let bytes = common::to_bytes(body).await.unwrap_or_default();
12535 let error = serde_json::from_str(&common::to_string(&bytes));
12536 let response = common::to_response(parts, bytes.into());
12537
12538 if let common::Retry::After(d) =
12539 dlg.http_failure(&response, error.as_ref().ok())
12540 {
12541 sleep(d).await;
12542 continue;
12543 }
12544
12545 dlg.finished(false);
12546
12547 return Err(match error {
12548 Ok(value) => common::Error::BadRequest(value),
12549 _ => common::Error::Failure(response),
12550 });
12551 }
12552 let response = {
12553 let bytes = common::to_bytes(body).await.unwrap_or_default();
12554 let encoded = common::to_string(&bytes);
12555 match serde_json::from_str(&encoded) {
12556 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12557 Err(error) => {
12558 dlg.response_json_decode_error(&encoded, &error);
12559 return Err(common::Error::JsonDecodeError(
12560 encoded.to_string(),
12561 error,
12562 ));
12563 }
12564 }
12565 };
12566
12567 dlg.finished(true);
12568 return Ok(response);
12569 }
12570 }
12571 }
12572 }
12573
12574 ///
12575 /// Sets the *request* property to the given value.
12576 ///
12577 /// Even though the property as already been set when instantiating this call,
12578 /// we provide this method for API completeness.
12579 pub fn request(mut self, new_value: Drive) -> DriveInsertCall<'a, C> {
12580 self._request = new_value;
12581 self
12582 }
12583 /// 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.
12584 ///
12585 /// Sets the *request id* query property to the given value.
12586 ///
12587 /// Even though the property as already been set when instantiating this call,
12588 /// we provide this method for API completeness.
12589 pub fn request_id(mut self, new_value: &str) -> DriveInsertCall<'a, C> {
12590 self._request_id = new_value.to_string();
12591 self
12592 }
12593 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12594 /// while executing the actual API request.
12595 ///
12596 /// ````text
12597 /// It should be used to handle progress information, and to implement a certain level of resilience.
12598 /// ````
12599 ///
12600 /// Sets the *delegate* property to the given value.
12601 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveInsertCall<'a, C> {
12602 self._delegate = Some(new_value);
12603 self
12604 }
12605
12606 /// Set any additional parameter of the query string used in the request.
12607 /// It should be used to set parameters which are not yet available through their own
12608 /// setters.
12609 ///
12610 /// Please note that this method must not be used to set any of the known parameters
12611 /// which have their own setter method. If done anyway, the request will fail.
12612 ///
12613 /// # Additional Parameters
12614 ///
12615 /// * *$.xgafv* (query-string) - V1 error format.
12616 /// * *access_token* (query-string) - OAuth access token.
12617 /// * *alt* (query-string) - Data format for response.
12618 /// * *callback* (query-string) - JSONP
12619 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12620 /// * *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.
12621 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12622 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12623 /// * *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.
12624 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12625 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12626 pub fn param<T>(mut self, name: T, value: T) -> DriveInsertCall<'a, C>
12627 where
12628 T: AsRef<str>,
12629 {
12630 self._additional_params
12631 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12632 self
12633 }
12634
12635 /// Identifies the authorization scope for the method you are building.
12636 ///
12637 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12638 /// [`Scope::Full`].
12639 ///
12640 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12641 /// tokens for more than one scope.
12642 ///
12643 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12644 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12645 /// sufficient, a read-write scope will do as well.
12646 pub fn add_scope<St>(mut self, scope: St) -> DriveInsertCall<'a, C>
12647 where
12648 St: AsRef<str>,
12649 {
12650 self._scopes.insert(String::from(scope.as_ref()));
12651 self
12652 }
12653 /// Identifies the authorization scope(s) for the method you are building.
12654 ///
12655 /// See [`Self::add_scope()`] for details.
12656 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveInsertCall<'a, C>
12657 where
12658 I: IntoIterator<Item = St>,
12659 St: AsRef<str>,
12660 {
12661 self._scopes
12662 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12663 self
12664 }
12665
12666 /// Removes all scopes, and no default scope will be used either.
12667 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12668 /// for details).
12669 pub fn clear_scopes(mut self) -> DriveInsertCall<'a, C> {
12670 self._scopes.clear();
12671 self
12672 }
12673}
12674
12675/// 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/workspace/drive/api/guides/search-shareddrives) guide.
12676///
12677/// A builder for the *list* method supported by a *drive* resource.
12678/// It is not used directly, but through a [`DriveMethods`] instance.
12679///
12680/// # Example
12681///
12682/// Instantiate a resource method builder
12683///
12684/// ```test_harness,no_run
12685/// # extern crate hyper;
12686/// # extern crate hyper_rustls;
12687/// # extern crate google_drive2 as drive2;
12688/// # async fn dox() {
12689/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12690///
12691/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12692/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12693/// # .with_native_roots()
12694/// # .unwrap()
12695/// # .https_only()
12696/// # .enable_http2()
12697/// # .build();
12698///
12699/// # let executor = hyper_util::rt::TokioExecutor::new();
12700/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12701/// # secret,
12702/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12703/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12704/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12705/// # ),
12706/// # ).build().await.unwrap();
12707///
12708/// # let client = hyper_util::client::legacy::Client::builder(
12709/// # hyper_util::rt::TokioExecutor::new()
12710/// # )
12711/// # .build(
12712/// # hyper_rustls::HttpsConnectorBuilder::new()
12713/// # .with_native_roots()
12714/// # .unwrap()
12715/// # .https_or_http()
12716/// # .enable_http2()
12717/// # .build()
12718/// # );
12719/// # let mut hub = DriveHub::new(client, auth);
12720/// // You can configure optional parameters by calling the respective setters at will, and
12721/// // execute the final call using `doit()`.
12722/// // Values shown here are possibly random and not representative !
12723/// let result = hub.drives().list()
12724/// .use_domain_admin_access(true)
12725/// .q("dolor")
12726/// .page_token("aliquyam")
12727/// .max_results(-61)
12728/// .doit().await;
12729/// # }
12730/// ```
12731pub struct DriveListCall<'a, C>
12732where
12733 C: 'a,
12734{
12735 hub: &'a DriveHub<C>,
12736 _use_domain_admin_access: Option<bool>,
12737 _q: Option<String>,
12738 _page_token: Option<String>,
12739 _max_results: Option<i32>,
12740 _delegate: Option<&'a mut dyn common::Delegate>,
12741 _additional_params: HashMap<String, String>,
12742 _scopes: BTreeSet<String>,
12743}
12744
12745impl<'a, C> common::CallBuilder for DriveListCall<'a, C> {}
12746
12747impl<'a, C> DriveListCall<'a, C>
12748where
12749 C: common::Connector,
12750{
12751 /// Perform the operation you have build so far.
12752 pub async fn doit(mut self) -> common::Result<(common::Response, DriveList)> {
12753 use std::borrow::Cow;
12754 use std::io::{Read, Seek};
12755
12756 use common::{url::Params, ToParts};
12757 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12758
12759 let mut dd = common::DefaultDelegate;
12760 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12761 dlg.begin(common::MethodInfo {
12762 id: "drive.drives.list",
12763 http_method: hyper::Method::GET,
12764 });
12765
12766 for &field in [
12767 "alt",
12768 "useDomainAdminAccess",
12769 "q",
12770 "pageToken",
12771 "maxResults",
12772 ]
12773 .iter()
12774 {
12775 if self._additional_params.contains_key(field) {
12776 dlg.finished(false);
12777 return Err(common::Error::FieldClash(field));
12778 }
12779 }
12780
12781 let mut params = Params::with_capacity(6 + self._additional_params.len());
12782 if let Some(value) = self._use_domain_admin_access.as_ref() {
12783 params.push("useDomainAdminAccess", value.to_string());
12784 }
12785 if let Some(value) = self._q.as_ref() {
12786 params.push("q", value);
12787 }
12788 if let Some(value) = self._page_token.as_ref() {
12789 params.push("pageToken", value);
12790 }
12791 if let Some(value) = self._max_results.as_ref() {
12792 params.push("maxResults", value.to_string());
12793 }
12794
12795 params.extend(self._additional_params.iter());
12796
12797 params.push("alt", "json");
12798 let mut url = self.hub._base_url.clone() + "drives";
12799 if self._scopes.is_empty() {
12800 self._scopes.insert(Scope::Readonly.as_ref().to_string());
12801 }
12802
12803 let url = params.parse_with_url(&url);
12804
12805 loop {
12806 let token = match self
12807 .hub
12808 .auth
12809 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12810 .await
12811 {
12812 Ok(token) => token,
12813 Err(e) => match dlg.token(e) {
12814 Ok(token) => token,
12815 Err(e) => {
12816 dlg.finished(false);
12817 return Err(common::Error::MissingToken(e));
12818 }
12819 },
12820 };
12821 let mut req_result = {
12822 let client = &self.hub.client;
12823 dlg.pre_request();
12824 let mut req_builder = hyper::Request::builder()
12825 .method(hyper::Method::GET)
12826 .uri(url.as_str())
12827 .header(USER_AGENT, self.hub._user_agent.clone());
12828
12829 if let Some(token) = token.as_ref() {
12830 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12831 }
12832
12833 let request = req_builder
12834 .header(CONTENT_LENGTH, 0_u64)
12835 .body(common::to_body::<String>(None));
12836
12837 client.request(request.unwrap()).await
12838 };
12839
12840 match req_result {
12841 Err(err) => {
12842 if let common::Retry::After(d) = dlg.http_error(&err) {
12843 sleep(d).await;
12844 continue;
12845 }
12846 dlg.finished(false);
12847 return Err(common::Error::HttpError(err));
12848 }
12849 Ok(res) => {
12850 let (mut parts, body) = res.into_parts();
12851 let mut body = common::Body::new(body);
12852 if !parts.status.is_success() {
12853 let bytes = common::to_bytes(body).await.unwrap_or_default();
12854 let error = serde_json::from_str(&common::to_string(&bytes));
12855 let response = common::to_response(parts, bytes.into());
12856
12857 if let common::Retry::After(d) =
12858 dlg.http_failure(&response, error.as_ref().ok())
12859 {
12860 sleep(d).await;
12861 continue;
12862 }
12863
12864 dlg.finished(false);
12865
12866 return Err(match error {
12867 Ok(value) => common::Error::BadRequest(value),
12868 _ => common::Error::Failure(response),
12869 });
12870 }
12871 let response = {
12872 let bytes = common::to_bytes(body).await.unwrap_or_default();
12873 let encoded = common::to_string(&bytes);
12874 match serde_json::from_str(&encoded) {
12875 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12876 Err(error) => {
12877 dlg.response_json_decode_error(&encoded, &error);
12878 return Err(common::Error::JsonDecodeError(
12879 encoded.to_string(),
12880 error,
12881 ));
12882 }
12883 }
12884 };
12885
12886 dlg.finished(true);
12887 return Ok(response);
12888 }
12889 }
12890 }
12891 }
12892
12893 /// 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.
12894 ///
12895 /// Sets the *use domain admin access* query property to the given value.
12896 pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveListCall<'a, C> {
12897 self._use_domain_admin_access = Some(new_value);
12898 self
12899 }
12900 /// Query string for searching shared drives.
12901 ///
12902 /// Sets the *q* query property to the given value.
12903 pub fn q(mut self, new_value: &str) -> DriveListCall<'a, C> {
12904 self._q = Some(new_value.to_string());
12905 self
12906 }
12907 /// Page token for shared drives.
12908 ///
12909 /// Sets the *page token* query property to the given value.
12910 pub fn page_token(mut self, new_value: &str) -> DriveListCall<'a, C> {
12911 self._page_token = Some(new_value.to_string());
12912 self
12913 }
12914 /// Maximum number of shared drives to return per page.
12915 ///
12916 /// Sets the *max results* query property to the given value.
12917 pub fn max_results(mut self, new_value: i32) -> DriveListCall<'a, C> {
12918 self._max_results = Some(new_value);
12919 self
12920 }
12921 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12922 /// while executing the actual API request.
12923 ///
12924 /// ````text
12925 /// It should be used to handle progress information, and to implement a certain level of resilience.
12926 /// ````
12927 ///
12928 /// Sets the *delegate* property to the given value.
12929 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveListCall<'a, C> {
12930 self._delegate = Some(new_value);
12931 self
12932 }
12933
12934 /// Set any additional parameter of the query string used in the request.
12935 /// It should be used to set parameters which are not yet available through their own
12936 /// setters.
12937 ///
12938 /// Please note that this method must not be used to set any of the known parameters
12939 /// which have their own setter method. If done anyway, the request will fail.
12940 ///
12941 /// # Additional Parameters
12942 ///
12943 /// * *$.xgafv* (query-string) - V1 error format.
12944 /// * *access_token* (query-string) - OAuth access token.
12945 /// * *alt* (query-string) - Data format for response.
12946 /// * *callback* (query-string) - JSONP
12947 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12948 /// * *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.
12949 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12950 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12951 /// * *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.
12952 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12953 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12954 pub fn param<T>(mut self, name: T, value: T) -> DriveListCall<'a, C>
12955 where
12956 T: AsRef<str>,
12957 {
12958 self._additional_params
12959 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12960 self
12961 }
12962
12963 /// Identifies the authorization scope for the method you are building.
12964 ///
12965 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12966 /// [`Scope::Readonly`].
12967 ///
12968 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12969 /// tokens for more than one scope.
12970 ///
12971 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12972 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12973 /// sufficient, a read-write scope will do as well.
12974 pub fn add_scope<St>(mut self, scope: St) -> DriveListCall<'a, C>
12975 where
12976 St: AsRef<str>,
12977 {
12978 self._scopes.insert(String::from(scope.as_ref()));
12979 self
12980 }
12981 /// Identifies the authorization scope(s) for the method you are building.
12982 ///
12983 /// See [`Self::add_scope()`] for details.
12984 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveListCall<'a, C>
12985 where
12986 I: IntoIterator<Item = St>,
12987 St: AsRef<str>,
12988 {
12989 self._scopes
12990 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12991 self
12992 }
12993
12994 /// Removes all scopes, and no default scope will be used either.
12995 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12996 /// for details).
12997 pub fn clear_scopes(mut self) -> DriveListCall<'a, C> {
12998 self._scopes.clear();
12999 self
13000 }
13001}
13002
13003/// Restores a shared drive to the default view.
13004///
13005/// A builder for the *unhide* method supported by a *drive* resource.
13006/// It is not used directly, but through a [`DriveMethods`] instance.
13007///
13008/// # Example
13009///
13010/// Instantiate a resource method builder
13011///
13012/// ```test_harness,no_run
13013/// # extern crate hyper;
13014/// # extern crate hyper_rustls;
13015/// # extern crate google_drive2 as drive2;
13016/// # async fn dox() {
13017/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13018///
13019/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13020/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13021/// # .with_native_roots()
13022/// # .unwrap()
13023/// # .https_only()
13024/// # .enable_http2()
13025/// # .build();
13026///
13027/// # let executor = hyper_util::rt::TokioExecutor::new();
13028/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13029/// # secret,
13030/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13031/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13032/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13033/// # ),
13034/// # ).build().await.unwrap();
13035///
13036/// # let client = hyper_util::client::legacy::Client::builder(
13037/// # hyper_util::rt::TokioExecutor::new()
13038/// # )
13039/// # .build(
13040/// # hyper_rustls::HttpsConnectorBuilder::new()
13041/// # .with_native_roots()
13042/// # .unwrap()
13043/// # .https_or_http()
13044/// # .enable_http2()
13045/// # .build()
13046/// # );
13047/// # let mut hub = DriveHub::new(client, auth);
13048/// // You can configure optional parameters by calling the respective setters at will, and
13049/// // execute the final call using `doit()`.
13050/// // Values shown here are possibly random and not representative !
13051/// let result = hub.drives().unhide("driveId")
13052/// .doit().await;
13053/// # }
13054/// ```
13055pub struct DriveUnhideCall<'a, C>
13056where
13057 C: 'a,
13058{
13059 hub: &'a DriveHub<C>,
13060 _drive_id: String,
13061 _delegate: Option<&'a mut dyn common::Delegate>,
13062 _additional_params: HashMap<String, String>,
13063 _scopes: BTreeSet<String>,
13064}
13065
13066impl<'a, C> common::CallBuilder for DriveUnhideCall<'a, C> {}
13067
13068impl<'a, C> DriveUnhideCall<'a, C>
13069where
13070 C: common::Connector,
13071{
13072 /// Perform the operation you have build so far.
13073 pub async fn doit(mut self) -> common::Result<(common::Response, Drive)> {
13074 use std::borrow::Cow;
13075 use std::io::{Read, Seek};
13076
13077 use common::{url::Params, ToParts};
13078 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13079
13080 let mut dd = common::DefaultDelegate;
13081 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13082 dlg.begin(common::MethodInfo {
13083 id: "drive.drives.unhide",
13084 http_method: hyper::Method::POST,
13085 });
13086
13087 for &field in ["alt", "driveId"].iter() {
13088 if self._additional_params.contains_key(field) {
13089 dlg.finished(false);
13090 return Err(common::Error::FieldClash(field));
13091 }
13092 }
13093
13094 let mut params = Params::with_capacity(3 + self._additional_params.len());
13095 params.push("driveId", self._drive_id);
13096
13097 params.extend(self._additional_params.iter());
13098
13099 params.push("alt", "json");
13100 let mut url = self.hub._base_url.clone() + "drives/{driveId}/unhide";
13101 if self._scopes.is_empty() {
13102 self._scopes.insert(Scope::Full.as_ref().to_string());
13103 }
13104
13105 #[allow(clippy::single_element_loop)]
13106 for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
13107 url = params.uri_replacement(url, param_name, find_this, false);
13108 }
13109 {
13110 let to_remove = ["driveId"];
13111 params.remove_params(&to_remove);
13112 }
13113
13114 let url = params.parse_with_url(&url);
13115
13116 loop {
13117 let token = match self
13118 .hub
13119 .auth
13120 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13121 .await
13122 {
13123 Ok(token) => token,
13124 Err(e) => match dlg.token(e) {
13125 Ok(token) => token,
13126 Err(e) => {
13127 dlg.finished(false);
13128 return Err(common::Error::MissingToken(e));
13129 }
13130 },
13131 };
13132 let mut req_result = {
13133 let client = &self.hub.client;
13134 dlg.pre_request();
13135 let mut req_builder = hyper::Request::builder()
13136 .method(hyper::Method::POST)
13137 .uri(url.as_str())
13138 .header(USER_AGENT, self.hub._user_agent.clone());
13139
13140 if let Some(token) = token.as_ref() {
13141 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13142 }
13143
13144 let request = req_builder
13145 .header(CONTENT_LENGTH, 0_u64)
13146 .body(common::to_body::<String>(None));
13147
13148 client.request(request.unwrap()).await
13149 };
13150
13151 match req_result {
13152 Err(err) => {
13153 if let common::Retry::After(d) = dlg.http_error(&err) {
13154 sleep(d).await;
13155 continue;
13156 }
13157 dlg.finished(false);
13158 return Err(common::Error::HttpError(err));
13159 }
13160 Ok(res) => {
13161 let (mut parts, body) = res.into_parts();
13162 let mut body = common::Body::new(body);
13163 if !parts.status.is_success() {
13164 let bytes = common::to_bytes(body).await.unwrap_or_default();
13165 let error = serde_json::from_str(&common::to_string(&bytes));
13166 let response = common::to_response(parts, bytes.into());
13167
13168 if let common::Retry::After(d) =
13169 dlg.http_failure(&response, error.as_ref().ok())
13170 {
13171 sleep(d).await;
13172 continue;
13173 }
13174
13175 dlg.finished(false);
13176
13177 return Err(match error {
13178 Ok(value) => common::Error::BadRequest(value),
13179 _ => common::Error::Failure(response),
13180 });
13181 }
13182 let response = {
13183 let bytes = common::to_bytes(body).await.unwrap_or_default();
13184 let encoded = common::to_string(&bytes);
13185 match serde_json::from_str(&encoded) {
13186 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13187 Err(error) => {
13188 dlg.response_json_decode_error(&encoded, &error);
13189 return Err(common::Error::JsonDecodeError(
13190 encoded.to_string(),
13191 error,
13192 ));
13193 }
13194 }
13195 };
13196
13197 dlg.finished(true);
13198 return Ok(response);
13199 }
13200 }
13201 }
13202 }
13203
13204 /// The ID of the shared drive.
13205 ///
13206 /// Sets the *drive id* path property to the given value.
13207 ///
13208 /// Even though the property as already been set when instantiating this call,
13209 /// we provide this method for API completeness.
13210 pub fn drive_id(mut self, new_value: &str) -> DriveUnhideCall<'a, C> {
13211 self._drive_id = new_value.to_string();
13212 self
13213 }
13214 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13215 /// while executing the actual API request.
13216 ///
13217 /// ````text
13218 /// It should be used to handle progress information, and to implement a certain level of resilience.
13219 /// ````
13220 ///
13221 /// Sets the *delegate* property to the given value.
13222 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveUnhideCall<'a, C> {
13223 self._delegate = Some(new_value);
13224 self
13225 }
13226
13227 /// Set any additional parameter of the query string used in the request.
13228 /// It should be used to set parameters which are not yet available through their own
13229 /// setters.
13230 ///
13231 /// Please note that this method must not be used to set any of the known parameters
13232 /// which have their own setter method. If done anyway, the request will fail.
13233 ///
13234 /// # Additional Parameters
13235 ///
13236 /// * *$.xgafv* (query-string) - V1 error format.
13237 /// * *access_token* (query-string) - OAuth access token.
13238 /// * *alt* (query-string) - Data format for response.
13239 /// * *callback* (query-string) - JSONP
13240 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13241 /// * *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.
13242 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13243 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13244 /// * *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.
13245 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13246 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13247 pub fn param<T>(mut self, name: T, value: T) -> DriveUnhideCall<'a, C>
13248 where
13249 T: AsRef<str>,
13250 {
13251 self._additional_params
13252 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13253 self
13254 }
13255
13256 /// Identifies the authorization scope for the method you are building.
13257 ///
13258 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13259 /// [`Scope::Full`].
13260 ///
13261 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13262 /// tokens for more than one scope.
13263 ///
13264 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13265 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13266 /// sufficient, a read-write scope will do as well.
13267 pub fn add_scope<St>(mut self, scope: St) -> DriveUnhideCall<'a, C>
13268 where
13269 St: AsRef<str>,
13270 {
13271 self._scopes.insert(String::from(scope.as_ref()));
13272 self
13273 }
13274 /// Identifies the authorization scope(s) for the method you are building.
13275 ///
13276 /// See [`Self::add_scope()`] for details.
13277 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveUnhideCall<'a, C>
13278 where
13279 I: IntoIterator<Item = St>,
13280 St: AsRef<str>,
13281 {
13282 self._scopes
13283 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13284 self
13285 }
13286
13287 /// Removes all scopes, and no default scope will be used either.
13288 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13289 /// for details).
13290 pub fn clear_scopes(mut self) -> DriveUnhideCall<'a, C> {
13291 self._scopes.clear();
13292 self
13293 }
13294}
13295
13296/// Updates the metadata for a shared drive.
13297///
13298/// A builder for the *update* method supported by a *drive* resource.
13299/// It is not used directly, but through a [`DriveMethods`] instance.
13300///
13301/// # Example
13302///
13303/// Instantiate a resource method builder
13304///
13305/// ```test_harness,no_run
13306/// # extern crate hyper;
13307/// # extern crate hyper_rustls;
13308/// # extern crate google_drive2 as drive2;
13309/// use drive2::api::Drive;
13310/// # async fn dox() {
13311/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13312///
13313/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13314/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13315/// # .with_native_roots()
13316/// # .unwrap()
13317/// # .https_only()
13318/// # .enable_http2()
13319/// # .build();
13320///
13321/// # let executor = hyper_util::rt::TokioExecutor::new();
13322/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13323/// # secret,
13324/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13325/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13326/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13327/// # ),
13328/// # ).build().await.unwrap();
13329///
13330/// # let client = hyper_util::client::legacy::Client::builder(
13331/// # hyper_util::rt::TokioExecutor::new()
13332/// # )
13333/// # .build(
13334/// # hyper_rustls::HttpsConnectorBuilder::new()
13335/// # .with_native_roots()
13336/// # .unwrap()
13337/// # .https_or_http()
13338/// # .enable_http2()
13339/// # .build()
13340/// # );
13341/// # let mut hub = DriveHub::new(client, auth);
13342/// // As the method needs a request, you would usually fill it with the desired information
13343/// // into the respective structure. Some of the parts shown here might not be applicable !
13344/// // Values shown here are possibly random and not representative !
13345/// let mut req = Drive::default();
13346///
13347/// // You can configure optional parameters by calling the respective setters at will, and
13348/// // execute the final call using `doit()`.
13349/// // Values shown here are possibly random and not representative !
13350/// let result = hub.drives().update(req, "driveId")
13351/// .use_domain_admin_access(true)
13352/// .doit().await;
13353/// # }
13354/// ```
13355pub struct DriveUpdateCall<'a, C>
13356where
13357 C: 'a,
13358{
13359 hub: &'a DriveHub<C>,
13360 _request: Drive,
13361 _drive_id: String,
13362 _use_domain_admin_access: Option<bool>,
13363 _delegate: Option<&'a mut dyn common::Delegate>,
13364 _additional_params: HashMap<String, String>,
13365 _scopes: BTreeSet<String>,
13366}
13367
13368impl<'a, C> common::CallBuilder for DriveUpdateCall<'a, C> {}
13369
13370impl<'a, C> DriveUpdateCall<'a, C>
13371where
13372 C: common::Connector,
13373{
13374 /// Perform the operation you have build so far.
13375 pub async fn doit(mut self) -> common::Result<(common::Response, Drive)> {
13376 use std::borrow::Cow;
13377 use std::io::{Read, Seek};
13378
13379 use common::{url::Params, ToParts};
13380 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13381
13382 let mut dd = common::DefaultDelegate;
13383 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13384 dlg.begin(common::MethodInfo {
13385 id: "drive.drives.update",
13386 http_method: hyper::Method::PUT,
13387 });
13388
13389 for &field in ["alt", "driveId", "useDomainAdminAccess"].iter() {
13390 if self._additional_params.contains_key(field) {
13391 dlg.finished(false);
13392 return Err(common::Error::FieldClash(field));
13393 }
13394 }
13395
13396 let mut params = Params::with_capacity(5 + self._additional_params.len());
13397 params.push("driveId", self._drive_id);
13398 if let Some(value) = self._use_domain_admin_access.as_ref() {
13399 params.push("useDomainAdminAccess", value.to_string());
13400 }
13401
13402 params.extend(self._additional_params.iter());
13403
13404 params.push("alt", "json");
13405 let mut url = self.hub._base_url.clone() + "drives/{driveId}";
13406 if self._scopes.is_empty() {
13407 self._scopes.insert(Scope::Full.as_ref().to_string());
13408 }
13409
13410 #[allow(clippy::single_element_loop)]
13411 for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
13412 url = params.uri_replacement(url, param_name, find_this, false);
13413 }
13414 {
13415 let to_remove = ["driveId"];
13416 params.remove_params(&to_remove);
13417 }
13418
13419 let url = params.parse_with_url(&url);
13420
13421 let mut json_mime_type = mime::APPLICATION_JSON;
13422 let mut request_value_reader = {
13423 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13424 common::remove_json_null_values(&mut value);
13425 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13426 serde_json::to_writer(&mut dst, &value).unwrap();
13427 dst
13428 };
13429 let request_size = request_value_reader
13430 .seek(std::io::SeekFrom::End(0))
13431 .unwrap();
13432 request_value_reader
13433 .seek(std::io::SeekFrom::Start(0))
13434 .unwrap();
13435
13436 loop {
13437 let token = match self
13438 .hub
13439 .auth
13440 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13441 .await
13442 {
13443 Ok(token) => token,
13444 Err(e) => match dlg.token(e) {
13445 Ok(token) => token,
13446 Err(e) => {
13447 dlg.finished(false);
13448 return Err(common::Error::MissingToken(e));
13449 }
13450 },
13451 };
13452 request_value_reader
13453 .seek(std::io::SeekFrom::Start(0))
13454 .unwrap();
13455 let mut req_result = {
13456 let client = &self.hub.client;
13457 dlg.pre_request();
13458 let mut req_builder = hyper::Request::builder()
13459 .method(hyper::Method::PUT)
13460 .uri(url.as_str())
13461 .header(USER_AGENT, self.hub._user_agent.clone());
13462
13463 if let Some(token) = token.as_ref() {
13464 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13465 }
13466
13467 let request = req_builder
13468 .header(CONTENT_TYPE, json_mime_type.to_string())
13469 .header(CONTENT_LENGTH, request_size as u64)
13470 .body(common::to_body(
13471 request_value_reader.get_ref().clone().into(),
13472 ));
13473
13474 client.request(request.unwrap()).await
13475 };
13476
13477 match req_result {
13478 Err(err) => {
13479 if let common::Retry::After(d) = dlg.http_error(&err) {
13480 sleep(d).await;
13481 continue;
13482 }
13483 dlg.finished(false);
13484 return Err(common::Error::HttpError(err));
13485 }
13486 Ok(res) => {
13487 let (mut parts, body) = res.into_parts();
13488 let mut body = common::Body::new(body);
13489 if !parts.status.is_success() {
13490 let bytes = common::to_bytes(body).await.unwrap_or_default();
13491 let error = serde_json::from_str(&common::to_string(&bytes));
13492 let response = common::to_response(parts, bytes.into());
13493
13494 if let common::Retry::After(d) =
13495 dlg.http_failure(&response, error.as_ref().ok())
13496 {
13497 sleep(d).await;
13498 continue;
13499 }
13500
13501 dlg.finished(false);
13502
13503 return Err(match error {
13504 Ok(value) => common::Error::BadRequest(value),
13505 _ => common::Error::Failure(response),
13506 });
13507 }
13508 let response = {
13509 let bytes = common::to_bytes(body).await.unwrap_or_default();
13510 let encoded = common::to_string(&bytes);
13511 match serde_json::from_str(&encoded) {
13512 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13513 Err(error) => {
13514 dlg.response_json_decode_error(&encoded, &error);
13515 return Err(common::Error::JsonDecodeError(
13516 encoded.to_string(),
13517 error,
13518 ));
13519 }
13520 }
13521 };
13522
13523 dlg.finished(true);
13524 return Ok(response);
13525 }
13526 }
13527 }
13528 }
13529
13530 ///
13531 /// Sets the *request* property to the given value.
13532 ///
13533 /// Even though the property as already been set when instantiating this call,
13534 /// we provide this method for API completeness.
13535 pub fn request(mut self, new_value: Drive) -> DriveUpdateCall<'a, C> {
13536 self._request = new_value;
13537 self
13538 }
13539 /// The ID of the shared drive.
13540 ///
13541 /// Sets the *drive id* path property to the given value.
13542 ///
13543 /// Even though the property as already been set when instantiating this call,
13544 /// we provide this method for API completeness.
13545 pub fn drive_id(mut self, new_value: &str) -> DriveUpdateCall<'a, C> {
13546 self._drive_id = new_value.to_string();
13547 self
13548 }
13549 /// 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.
13550 ///
13551 /// Sets the *use domain admin access* query property to the given value.
13552 pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveUpdateCall<'a, C> {
13553 self._use_domain_admin_access = Some(new_value);
13554 self
13555 }
13556 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13557 /// while executing the actual API request.
13558 ///
13559 /// ````text
13560 /// It should be used to handle progress information, and to implement a certain level of resilience.
13561 /// ````
13562 ///
13563 /// Sets the *delegate* property to the given value.
13564 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveUpdateCall<'a, C> {
13565 self._delegate = Some(new_value);
13566 self
13567 }
13568
13569 /// Set any additional parameter of the query string used in the request.
13570 /// It should be used to set parameters which are not yet available through their own
13571 /// setters.
13572 ///
13573 /// Please note that this method must not be used to set any of the known parameters
13574 /// which have their own setter method. If done anyway, the request will fail.
13575 ///
13576 /// # Additional Parameters
13577 ///
13578 /// * *$.xgafv* (query-string) - V1 error format.
13579 /// * *access_token* (query-string) - OAuth access token.
13580 /// * *alt* (query-string) - Data format for response.
13581 /// * *callback* (query-string) - JSONP
13582 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13583 /// * *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.
13584 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13585 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13586 /// * *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.
13587 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13588 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13589 pub fn param<T>(mut self, name: T, value: T) -> DriveUpdateCall<'a, C>
13590 where
13591 T: AsRef<str>,
13592 {
13593 self._additional_params
13594 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13595 self
13596 }
13597
13598 /// Identifies the authorization scope for the method you are building.
13599 ///
13600 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13601 /// [`Scope::Full`].
13602 ///
13603 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13604 /// tokens for more than one scope.
13605 ///
13606 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13607 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13608 /// sufficient, a read-write scope will do as well.
13609 pub fn add_scope<St>(mut self, scope: St) -> DriveUpdateCall<'a, C>
13610 where
13611 St: AsRef<str>,
13612 {
13613 self._scopes.insert(String::from(scope.as_ref()));
13614 self
13615 }
13616 /// Identifies the authorization scope(s) for the method you are building.
13617 ///
13618 /// See [`Self::add_scope()`] for details.
13619 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveUpdateCall<'a, C>
13620 where
13621 I: IntoIterator<Item = St>,
13622 St: AsRef<str>,
13623 {
13624 self._scopes
13625 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13626 self
13627 }
13628
13629 /// Removes all scopes, and no default scope will be used either.
13630 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13631 /// for details).
13632 pub fn clear_scopes(mut self) -> DriveUpdateCall<'a, C> {
13633 self._scopes.clear();
13634 self
13635 }
13636}
13637
13638/// Creates a copy of the specified file.
13639///
13640/// A builder for the *copy* method supported by a *file* resource.
13641/// It is not used directly, but through a [`FileMethods`] instance.
13642///
13643/// # Example
13644///
13645/// Instantiate a resource method builder
13646///
13647/// ```test_harness,no_run
13648/// # extern crate hyper;
13649/// # extern crate hyper_rustls;
13650/// # extern crate google_drive2 as drive2;
13651/// use drive2::api::File;
13652/// # async fn dox() {
13653/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13654///
13655/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13656/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13657/// # .with_native_roots()
13658/// # .unwrap()
13659/// # .https_only()
13660/// # .enable_http2()
13661/// # .build();
13662///
13663/// # let executor = hyper_util::rt::TokioExecutor::new();
13664/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13665/// # secret,
13666/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13667/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13668/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13669/// # ),
13670/// # ).build().await.unwrap();
13671///
13672/// # let client = hyper_util::client::legacy::Client::builder(
13673/// # hyper_util::rt::TokioExecutor::new()
13674/// # )
13675/// # .build(
13676/// # hyper_rustls::HttpsConnectorBuilder::new()
13677/// # .with_native_roots()
13678/// # .unwrap()
13679/// # .https_or_http()
13680/// # .enable_http2()
13681/// # .build()
13682/// # );
13683/// # let mut hub = DriveHub::new(client, auth);
13684/// // As the method needs a request, you would usually fill it with the desired information
13685/// // into the respective structure. Some of the parts shown here might not be applicable !
13686/// // Values shown here are possibly random and not representative !
13687/// let mut req = File::default();
13688///
13689/// // You can configure optional parameters by calling the respective setters at will, and
13690/// // execute the final call using `doit()`.
13691/// // Values shown here are possibly random and not representative !
13692/// let result = hub.files().copy(req, "fileId")
13693/// .visibility("gubergren")
13694/// .timed_text_track_name("sadipscing")
13695/// .timed_text_language("At")
13696/// .supports_team_drives(true)
13697/// .supports_all_drives(true)
13698/// .pinned(false)
13699/// .ocr_language("et")
13700/// .ocr(true)
13701/// .include_permissions_for_view("dolor")
13702/// .include_labels("Lorem")
13703/// .enforce_single_parent(false)
13704/// .convert(true)
13705/// .doit().await;
13706/// # }
13707/// ```
13708pub struct FileCopyCall<'a, C>
13709where
13710 C: 'a,
13711{
13712 hub: &'a DriveHub<C>,
13713 _request: File,
13714 _file_id: String,
13715 _visibility: Option<String>,
13716 _timed_text_track_name: Option<String>,
13717 _timed_text_language: Option<String>,
13718 _supports_team_drives: Option<bool>,
13719 _supports_all_drives: Option<bool>,
13720 _pinned: Option<bool>,
13721 _ocr_language: Option<String>,
13722 _ocr: Option<bool>,
13723 _include_permissions_for_view: Option<String>,
13724 _include_labels: Option<String>,
13725 _enforce_single_parent: Option<bool>,
13726 _convert: Option<bool>,
13727 _delegate: Option<&'a mut dyn common::Delegate>,
13728 _additional_params: HashMap<String, String>,
13729 _scopes: BTreeSet<String>,
13730}
13731
13732impl<'a, C> common::CallBuilder for FileCopyCall<'a, C> {}
13733
13734impl<'a, C> FileCopyCall<'a, C>
13735where
13736 C: common::Connector,
13737{
13738 /// Perform the operation you have build so far.
13739 pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
13740 use std::borrow::Cow;
13741 use std::io::{Read, Seek};
13742
13743 use common::{url::Params, ToParts};
13744 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13745
13746 let mut dd = common::DefaultDelegate;
13747 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13748 dlg.begin(common::MethodInfo {
13749 id: "drive.files.copy",
13750 http_method: hyper::Method::POST,
13751 });
13752
13753 for &field in [
13754 "alt",
13755 "fileId",
13756 "visibility",
13757 "timedTextTrackName",
13758 "timedTextLanguage",
13759 "supportsTeamDrives",
13760 "supportsAllDrives",
13761 "pinned",
13762 "ocrLanguage",
13763 "ocr",
13764 "includePermissionsForView",
13765 "includeLabels",
13766 "enforceSingleParent",
13767 "convert",
13768 ]
13769 .iter()
13770 {
13771 if self._additional_params.contains_key(field) {
13772 dlg.finished(false);
13773 return Err(common::Error::FieldClash(field));
13774 }
13775 }
13776
13777 let mut params = Params::with_capacity(16 + self._additional_params.len());
13778 params.push("fileId", self._file_id);
13779 if let Some(value) = self._visibility.as_ref() {
13780 params.push("visibility", value);
13781 }
13782 if let Some(value) = self._timed_text_track_name.as_ref() {
13783 params.push("timedTextTrackName", value);
13784 }
13785 if let Some(value) = self._timed_text_language.as_ref() {
13786 params.push("timedTextLanguage", value);
13787 }
13788 if let Some(value) = self._supports_team_drives.as_ref() {
13789 params.push("supportsTeamDrives", value.to_string());
13790 }
13791 if let Some(value) = self._supports_all_drives.as_ref() {
13792 params.push("supportsAllDrives", value.to_string());
13793 }
13794 if let Some(value) = self._pinned.as_ref() {
13795 params.push("pinned", value.to_string());
13796 }
13797 if let Some(value) = self._ocr_language.as_ref() {
13798 params.push("ocrLanguage", value);
13799 }
13800 if let Some(value) = self._ocr.as_ref() {
13801 params.push("ocr", value.to_string());
13802 }
13803 if let Some(value) = self._include_permissions_for_view.as_ref() {
13804 params.push("includePermissionsForView", value);
13805 }
13806 if let Some(value) = self._include_labels.as_ref() {
13807 params.push("includeLabels", value);
13808 }
13809 if let Some(value) = self._enforce_single_parent.as_ref() {
13810 params.push("enforceSingleParent", value.to_string());
13811 }
13812 if let Some(value) = self._convert.as_ref() {
13813 params.push("convert", value.to_string());
13814 }
13815
13816 params.extend(self._additional_params.iter());
13817
13818 params.push("alt", "json");
13819 let mut url = self.hub._base_url.clone() + "files/{fileId}/copy";
13820 if self._scopes.is_empty() {
13821 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
13822 }
13823
13824 #[allow(clippy::single_element_loop)]
13825 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
13826 url = params.uri_replacement(url, param_name, find_this, false);
13827 }
13828 {
13829 let to_remove = ["fileId"];
13830 params.remove_params(&to_remove);
13831 }
13832
13833 let url = params.parse_with_url(&url);
13834
13835 let mut json_mime_type = mime::APPLICATION_JSON;
13836 let mut request_value_reader = {
13837 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13838 common::remove_json_null_values(&mut value);
13839 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13840 serde_json::to_writer(&mut dst, &value).unwrap();
13841 dst
13842 };
13843 let request_size = request_value_reader
13844 .seek(std::io::SeekFrom::End(0))
13845 .unwrap();
13846 request_value_reader
13847 .seek(std::io::SeekFrom::Start(0))
13848 .unwrap();
13849
13850 loop {
13851 let token = match self
13852 .hub
13853 .auth
13854 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13855 .await
13856 {
13857 Ok(token) => token,
13858 Err(e) => match dlg.token(e) {
13859 Ok(token) => token,
13860 Err(e) => {
13861 dlg.finished(false);
13862 return Err(common::Error::MissingToken(e));
13863 }
13864 },
13865 };
13866 request_value_reader
13867 .seek(std::io::SeekFrom::Start(0))
13868 .unwrap();
13869 let mut req_result = {
13870 let client = &self.hub.client;
13871 dlg.pre_request();
13872 let mut req_builder = hyper::Request::builder()
13873 .method(hyper::Method::POST)
13874 .uri(url.as_str())
13875 .header(USER_AGENT, self.hub._user_agent.clone());
13876
13877 if let Some(token) = token.as_ref() {
13878 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13879 }
13880
13881 let request = req_builder
13882 .header(CONTENT_TYPE, json_mime_type.to_string())
13883 .header(CONTENT_LENGTH, request_size as u64)
13884 .body(common::to_body(
13885 request_value_reader.get_ref().clone().into(),
13886 ));
13887
13888 client.request(request.unwrap()).await
13889 };
13890
13891 match req_result {
13892 Err(err) => {
13893 if let common::Retry::After(d) = dlg.http_error(&err) {
13894 sleep(d).await;
13895 continue;
13896 }
13897 dlg.finished(false);
13898 return Err(common::Error::HttpError(err));
13899 }
13900 Ok(res) => {
13901 let (mut parts, body) = res.into_parts();
13902 let mut body = common::Body::new(body);
13903 if !parts.status.is_success() {
13904 let bytes = common::to_bytes(body).await.unwrap_or_default();
13905 let error = serde_json::from_str(&common::to_string(&bytes));
13906 let response = common::to_response(parts, bytes.into());
13907
13908 if let common::Retry::After(d) =
13909 dlg.http_failure(&response, error.as_ref().ok())
13910 {
13911 sleep(d).await;
13912 continue;
13913 }
13914
13915 dlg.finished(false);
13916
13917 return Err(match error {
13918 Ok(value) => common::Error::BadRequest(value),
13919 _ => common::Error::Failure(response),
13920 });
13921 }
13922 let response = {
13923 let bytes = common::to_bytes(body).await.unwrap_or_default();
13924 let encoded = common::to_string(&bytes);
13925 match serde_json::from_str(&encoded) {
13926 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13927 Err(error) => {
13928 dlg.response_json_decode_error(&encoded, &error);
13929 return Err(common::Error::JsonDecodeError(
13930 encoded.to_string(),
13931 error,
13932 ));
13933 }
13934 }
13935 };
13936
13937 dlg.finished(true);
13938 return Ok(response);
13939 }
13940 }
13941 }
13942 }
13943
13944 ///
13945 /// Sets the *request* property to the given value.
13946 ///
13947 /// Even though the property as already been set when instantiating this call,
13948 /// we provide this method for API completeness.
13949 pub fn request(mut self, new_value: File) -> FileCopyCall<'a, C> {
13950 self._request = new_value;
13951 self
13952 }
13953 /// The ID of the file to copy.
13954 ///
13955 /// Sets the *file id* path property to the given value.
13956 ///
13957 /// Even though the property as already been set when instantiating this call,
13958 /// we provide this method for API completeness.
13959 pub fn file_id(mut self, new_value: &str) -> FileCopyCall<'a, C> {
13960 self._file_id = new_value.to_string();
13961 self
13962 }
13963 /// The visibility of the new file. This parameter is only relevant when the source is not a native Google Doc and convert=false.
13964 ///
13965 /// Sets the *visibility* query property to the given value.
13966 pub fn visibility(mut self, new_value: &str) -> FileCopyCall<'a, C> {
13967 self._visibility = Some(new_value.to_string());
13968 self
13969 }
13970 /// The timed text track name.
13971 ///
13972 /// Sets the *timed text track name* query property to the given value.
13973 pub fn timed_text_track_name(mut self, new_value: &str) -> FileCopyCall<'a, C> {
13974 self._timed_text_track_name = Some(new_value.to_string());
13975 self
13976 }
13977 /// The language of the timed text.
13978 ///
13979 /// Sets the *timed text language* query property to the given value.
13980 pub fn timed_text_language(mut self, new_value: &str) -> FileCopyCall<'a, C> {
13981 self._timed_text_language = Some(new_value.to_string());
13982 self
13983 }
13984 /// Deprecated: Use `supportsAllDrives` instead.
13985 ///
13986 /// Sets the *supports team drives* query property to the given value.
13987 pub fn supports_team_drives(mut self, new_value: bool) -> FileCopyCall<'a, C> {
13988 self._supports_team_drives = Some(new_value);
13989 self
13990 }
13991 /// Whether the requesting application supports both My Drives and shared drives.
13992 ///
13993 /// Sets the *supports all drives* query property to the given value.
13994 pub fn supports_all_drives(mut self, new_value: bool) -> FileCopyCall<'a, C> {
13995 self._supports_all_drives = Some(new_value);
13996 self
13997 }
13998 /// Whether to pin the head revision of the new copy. A file can have a maximum of 200 pinned revisions.
13999 ///
14000 /// Sets the *pinned* query property to the given value.
14001 pub fn pinned(mut self, new_value: bool) -> FileCopyCall<'a, C> {
14002 self._pinned = Some(new_value);
14003 self
14004 }
14005 /// If `ocr` is true, hints at the language to use. Valid values are BCP 47 codes.
14006 ///
14007 /// Sets the *ocr language* query property to the given value.
14008 pub fn ocr_language(mut self, new_value: &str) -> FileCopyCall<'a, C> {
14009 self._ocr_language = Some(new_value.to_string());
14010 self
14011 }
14012 /// Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads.
14013 ///
14014 /// Sets the *ocr* query property to the given value.
14015 pub fn ocr(mut self, new_value: bool) -> FileCopyCall<'a, C> {
14016 self._ocr = Some(new_value);
14017 self
14018 }
14019 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
14020 ///
14021 /// Sets the *include permissions for view* query property to the given value.
14022 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileCopyCall<'a, C> {
14023 self._include_permissions_for_view = Some(new_value.to_string());
14024 self
14025 }
14026 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
14027 ///
14028 /// Sets the *include labels* query property to the given value.
14029 pub fn include_labels(mut self, new_value: &str) -> FileCopyCall<'a, C> {
14030 self._include_labels = Some(new_value.to_string());
14031 self
14032 }
14033 /// Deprecated: Copying files into multiple folders is no longer supported. Use shortcuts instead.
14034 ///
14035 /// Sets the *enforce single parent* query property to the given value.
14036 pub fn enforce_single_parent(mut self, new_value: bool) -> FileCopyCall<'a, C> {
14037 self._enforce_single_parent = Some(new_value);
14038 self
14039 }
14040 /// Whether to convert this file to the corresponding Docs Editors format.
14041 ///
14042 /// Sets the *convert* query property to the given value.
14043 pub fn convert(mut self, new_value: bool) -> FileCopyCall<'a, C> {
14044 self._convert = Some(new_value);
14045 self
14046 }
14047 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14048 /// while executing the actual API request.
14049 ///
14050 /// ````text
14051 /// It should be used to handle progress information, and to implement a certain level of resilience.
14052 /// ````
14053 ///
14054 /// Sets the *delegate* property to the given value.
14055 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileCopyCall<'a, C> {
14056 self._delegate = Some(new_value);
14057 self
14058 }
14059
14060 /// Set any additional parameter of the query string used in the request.
14061 /// It should be used to set parameters which are not yet available through their own
14062 /// setters.
14063 ///
14064 /// Please note that this method must not be used to set any of the known parameters
14065 /// which have their own setter method. If done anyway, the request will fail.
14066 ///
14067 /// # Additional Parameters
14068 ///
14069 /// * *$.xgafv* (query-string) - V1 error format.
14070 /// * *access_token* (query-string) - OAuth access token.
14071 /// * *alt* (query-string) - Data format for response.
14072 /// * *callback* (query-string) - JSONP
14073 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14074 /// * *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.
14075 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14076 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14077 /// * *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.
14078 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14079 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14080 pub fn param<T>(mut self, name: T, value: T) -> FileCopyCall<'a, C>
14081 where
14082 T: AsRef<str>,
14083 {
14084 self._additional_params
14085 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14086 self
14087 }
14088
14089 /// Identifies the authorization scope for the method you are building.
14090 ///
14091 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14092 /// [`Scope::AppReadonly`].
14093 ///
14094 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14095 /// tokens for more than one scope.
14096 ///
14097 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14098 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14099 /// sufficient, a read-write scope will do as well.
14100 pub fn add_scope<St>(mut self, scope: St) -> FileCopyCall<'a, C>
14101 where
14102 St: AsRef<str>,
14103 {
14104 self._scopes.insert(String::from(scope.as_ref()));
14105 self
14106 }
14107 /// Identifies the authorization scope(s) for the method you are building.
14108 ///
14109 /// See [`Self::add_scope()`] for details.
14110 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileCopyCall<'a, C>
14111 where
14112 I: IntoIterator<Item = St>,
14113 St: AsRef<str>,
14114 {
14115 self._scopes
14116 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14117 self
14118 }
14119
14120 /// Removes all scopes, and no default scope will be used either.
14121 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14122 /// for details).
14123 pub fn clear_scopes(mut self) -> FileCopyCall<'a, C> {
14124 self._scopes.clear();
14125 self
14126 }
14127}
14128
14129/// 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.
14130///
14131/// A builder for the *delete* method supported by a *file* resource.
14132/// It is not used directly, but through a [`FileMethods`] instance.
14133///
14134/// # Example
14135///
14136/// Instantiate a resource method builder
14137///
14138/// ```test_harness,no_run
14139/// # extern crate hyper;
14140/// # extern crate hyper_rustls;
14141/// # extern crate google_drive2 as drive2;
14142/// # async fn dox() {
14143/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14144///
14145/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14146/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14147/// # .with_native_roots()
14148/// # .unwrap()
14149/// # .https_only()
14150/// # .enable_http2()
14151/// # .build();
14152///
14153/// # let executor = hyper_util::rt::TokioExecutor::new();
14154/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14155/// # secret,
14156/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14157/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14158/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14159/// # ),
14160/// # ).build().await.unwrap();
14161///
14162/// # let client = hyper_util::client::legacy::Client::builder(
14163/// # hyper_util::rt::TokioExecutor::new()
14164/// # )
14165/// # .build(
14166/// # hyper_rustls::HttpsConnectorBuilder::new()
14167/// # .with_native_roots()
14168/// # .unwrap()
14169/// # .https_or_http()
14170/// # .enable_http2()
14171/// # .build()
14172/// # );
14173/// # let mut hub = DriveHub::new(client, auth);
14174/// // You can configure optional parameters by calling the respective setters at will, and
14175/// // execute the final call using `doit()`.
14176/// // Values shown here are possibly random and not representative !
14177/// let result = hub.files().delete("fileId")
14178/// .supports_team_drives(false)
14179/// .supports_all_drives(true)
14180/// .enforce_single_parent(false)
14181/// .doit().await;
14182/// # }
14183/// ```
14184pub struct FileDeleteCall<'a, C>
14185where
14186 C: 'a,
14187{
14188 hub: &'a DriveHub<C>,
14189 _file_id: String,
14190 _supports_team_drives: Option<bool>,
14191 _supports_all_drives: Option<bool>,
14192 _enforce_single_parent: Option<bool>,
14193 _delegate: Option<&'a mut dyn common::Delegate>,
14194 _additional_params: HashMap<String, String>,
14195 _scopes: BTreeSet<String>,
14196}
14197
14198impl<'a, C> common::CallBuilder for FileDeleteCall<'a, C> {}
14199
14200impl<'a, C> FileDeleteCall<'a, C>
14201where
14202 C: common::Connector,
14203{
14204 /// Perform the operation you have build so far.
14205 pub async fn doit(mut self) -> common::Result<common::Response> {
14206 use std::borrow::Cow;
14207 use std::io::{Read, Seek};
14208
14209 use common::{url::Params, ToParts};
14210 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14211
14212 let mut dd = common::DefaultDelegate;
14213 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14214 dlg.begin(common::MethodInfo {
14215 id: "drive.files.delete",
14216 http_method: hyper::Method::DELETE,
14217 });
14218
14219 for &field in [
14220 "fileId",
14221 "supportsTeamDrives",
14222 "supportsAllDrives",
14223 "enforceSingleParent",
14224 ]
14225 .iter()
14226 {
14227 if self._additional_params.contains_key(field) {
14228 dlg.finished(false);
14229 return Err(common::Error::FieldClash(field));
14230 }
14231 }
14232
14233 let mut params = Params::with_capacity(5 + self._additional_params.len());
14234 params.push("fileId", self._file_id);
14235 if let Some(value) = self._supports_team_drives.as_ref() {
14236 params.push("supportsTeamDrives", value.to_string());
14237 }
14238 if let Some(value) = self._supports_all_drives.as_ref() {
14239 params.push("supportsAllDrives", value.to_string());
14240 }
14241 if let Some(value) = self._enforce_single_parent.as_ref() {
14242 params.push("enforceSingleParent", value.to_string());
14243 }
14244
14245 params.extend(self._additional_params.iter());
14246
14247 let mut url = self.hub._base_url.clone() + "files/{fileId}";
14248 if self._scopes.is_empty() {
14249 self._scopes.insert(Scope::Full.as_ref().to_string());
14250 }
14251
14252 #[allow(clippy::single_element_loop)]
14253 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
14254 url = params.uri_replacement(url, param_name, find_this, false);
14255 }
14256 {
14257 let to_remove = ["fileId"];
14258 params.remove_params(&to_remove);
14259 }
14260
14261 let url = params.parse_with_url(&url);
14262
14263 loop {
14264 let token = match self
14265 .hub
14266 .auth
14267 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14268 .await
14269 {
14270 Ok(token) => token,
14271 Err(e) => match dlg.token(e) {
14272 Ok(token) => token,
14273 Err(e) => {
14274 dlg.finished(false);
14275 return Err(common::Error::MissingToken(e));
14276 }
14277 },
14278 };
14279 let mut req_result = {
14280 let client = &self.hub.client;
14281 dlg.pre_request();
14282 let mut req_builder = hyper::Request::builder()
14283 .method(hyper::Method::DELETE)
14284 .uri(url.as_str())
14285 .header(USER_AGENT, self.hub._user_agent.clone());
14286
14287 if let Some(token) = token.as_ref() {
14288 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14289 }
14290
14291 let request = req_builder
14292 .header(CONTENT_LENGTH, 0_u64)
14293 .body(common::to_body::<String>(None));
14294
14295 client.request(request.unwrap()).await
14296 };
14297
14298 match req_result {
14299 Err(err) => {
14300 if let common::Retry::After(d) = dlg.http_error(&err) {
14301 sleep(d).await;
14302 continue;
14303 }
14304 dlg.finished(false);
14305 return Err(common::Error::HttpError(err));
14306 }
14307 Ok(res) => {
14308 let (mut parts, body) = res.into_parts();
14309 let mut body = common::Body::new(body);
14310 if !parts.status.is_success() {
14311 let bytes = common::to_bytes(body).await.unwrap_or_default();
14312 let error = serde_json::from_str(&common::to_string(&bytes));
14313 let response = common::to_response(parts, bytes.into());
14314
14315 if let common::Retry::After(d) =
14316 dlg.http_failure(&response, error.as_ref().ok())
14317 {
14318 sleep(d).await;
14319 continue;
14320 }
14321
14322 dlg.finished(false);
14323
14324 return Err(match error {
14325 Ok(value) => common::Error::BadRequest(value),
14326 _ => common::Error::Failure(response),
14327 });
14328 }
14329 let response = common::Response::from_parts(parts, body);
14330
14331 dlg.finished(true);
14332 return Ok(response);
14333 }
14334 }
14335 }
14336 }
14337
14338 /// The ID of the file to delete.
14339 ///
14340 /// Sets the *file id* path property to the given value.
14341 ///
14342 /// Even though the property as already been set when instantiating this call,
14343 /// we provide this method for API completeness.
14344 pub fn file_id(mut self, new_value: &str) -> FileDeleteCall<'a, C> {
14345 self._file_id = new_value.to_string();
14346 self
14347 }
14348 /// Deprecated: Use `supportsAllDrives` instead.
14349 ///
14350 /// Sets the *supports team drives* query property to the given value.
14351 pub fn supports_team_drives(mut self, new_value: bool) -> FileDeleteCall<'a, C> {
14352 self._supports_team_drives = Some(new_value);
14353 self
14354 }
14355 /// Whether the requesting application supports both My Drives and shared drives.
14356 ///
14357 /// Sets the *supports all drives* query property to the given value.
14358 pub fn supports_all_drives(mut self, new_value: bool) -> FileDeleteCall<'a, C> {
14359 self._supports_all_drives = Some(new_value);
14360 self
14361 }
14362 /// 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.
14363 ///
14364 /// Sets the *enforce single parent* query property to the given value.
14365 pub fn enforce_single_parent(mut self, new_value: bool) -> FileDeleteCall<'a, C> {
14366 self._enforce_single_parent = Some(new_value);
14367 self
14368 }
14369 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14370 /// while executing the actual API request.
14371 ///
14372 /// ````text
14373 /// It should be used to handle progress information, and to implement a certain level of resilience.
14374 /// ````
14375 ///
14376 /// Sets the *delegate* property to the given value.
14377 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileDeleteCall<'a, C> {
14378 self._delegate = Some(new_value);
14379 self
14380 }
14381
14382 /// Set any additional parameter of the query string used in the request.
14383 /// It should be used to set parameters which are not yet available through their own
14384 /// setters.
14385 ///
14386 /// Please note that this method must not be used to set any of the known parameters
14387 /// which have their own setter method. If done anyway, the request will fail.
14388 ///
14389 /// # Additional Parameters
14390 ///
14391 /// * *$.xgafv* (query-string) - V1 error format.
14392 /// * *access_token* (query-string) - OAuth access token.
14393 /// * *alt* (query-string) - Data format for response.
14394 /// * *callback* (query-string) - JSONP
14395 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14396 /// * *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.
14397 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14398 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14399 /// * *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.
14400 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14401 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14402 pub fn param<T>(mut self, name: T, value: T) -> FileDeleteCall<'a, C>
14403 where
14404 T: AsRef<str>,
14405 {
14406 self._additional_params
14407 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14408 self
14409 }
14410
14411 /// Identifies the authorization scope for the method you are building.
14412 ///
14413 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14414 /// [`Scope::Full`].
14415 ///
14416 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14417 /// tokens for more than one scope.
14418 ///
14419 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14420 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14421 /// sufficient, a read-write scope will do as well.
14422 pub fn add_scope<St>(mut self, scope: St) -> FileDeleteCall<'a, C>
14423 where
14424 St: AsRef<str>,
14425 {
14426 self._scopes.insert(String::from(scope.as_ref()));
14427 self
14428 }
14429 /// Identifies the authorization scope(s) for the method you are building.
14430 ///
14431 /// See [`Self::add_scope()`] for details.
14432 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileDeleteCall<'a, C>
14433 where
14434 I: IntoIterator<Item = St>,
14435 St: AsRef<str>,
14436 {
14437 self._scopes
14438 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14439 self
14440 }
14441
14442 /// Removes all scopes, and no default scope will be used either.
14443 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14444 /// for details).
14445 pub fn clear_scopes(mut self) -> FileDeleteCall<'a, C> {
14446 self._scopes.clear();
14447 self
14448 }
14449}
14450
14451/// Permanently deletes all of the user's trashed files.
14452///
14453/// A builder for the *emptyTrash* method supported by a *file* resource.
14454/// It is not used directly, but through a [`FileMethods`] instance.
14455///
14456/// # Example
14457///
14458/// Instantiate a resource method builder
14459///
14460/// ```test_harness,no_run
14461/// # extern crate hyper;
14462/// # extern crate hyper_rustls;
14463/// # extern crate google_drive2 as drive2;
14464/// # async fn dox() {
14465/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14466///
14467/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14468/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14469/// # .with_native_roots()
14470/// # .unwrap()
14471/// # .https_only()
14472/// # .enable_http2()
14473/// # .build();
14474///
14475/// # let executor = hyper_util::rt::TokioExecutor::new();
14476/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14477/// # secret,
14478/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14479/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14480/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14481/// # ),
14482/// # ).build().await.unwrap();
14483///
14484/// # let client = hyper_util::client::legacy::Client::builder(
14485/// # hyper_util::rt::TokioExecutor::new()
14486/// # )
14487/// # .build(
14488/// # hyper_rustls::HttpsConnectorBuilder::new()
14489/// # .with_native_roots()
14490/// # .unwrap()
14491/// # .https_or_http()
14492/// # .enable_http2()
14493/// # .build()
14494/// # );
14495/// # let mut hub = DriveHub::new(client, auth);
14496/// // You can configure optional parameters by calling the respective setters at will, and
14497/// // execute the final call using `doit()`.
14498/// // Values shown here are possibly random and not representative !
14499/// let result = hub.files().empty_trash()
14500/// .enforce_single_parent(true)
14501/// .drive_id("nonumy")
14502/// .doit().await;
14503/// # }
14504/// ```
14505pub struct FileEmptyTrashCall<'a, C>
14506where
14507 C: 'a,
14508{
14509 hub: &'a DriveHub<C>,
14510 _enforce_single_parent: Option<bool>,
14511 _drive_id: Option<String>,
14512 _delegate: Option<&'a mut dyn common::Delegate>,
14513 _additional_params: HashMap<String, String>,
14514 _scopes: BTreeSet<String>,
14515}
14516
14517impl<'a, C> common::CallBuilder for FileEmptyTrashCall<'a, C> {}
14518
14519impl<'a, C> FileEmptyTrashCall<'a, C>
14520where
14521 C: common::Connector,
14522{
14523 /// Perform the operation you have build so far.
14524 pub async fn doit(mut self) -> common::Result<common::Response> {
14525 use std::borrow::Cow;
14526 use std::io::{Read, Seek};
14527
14528 use common::{url::Params, ToParts};
14529 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14530
14531 let mut dd = common::DefaultDelegate;
14532 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14533 dlg.begin(common::MethodInfo {
14534 id: "drive.files.emptyTrash",
14535 http_method: hyper::Method::DELETE,
14536 });
14537
14538 for &field in ["enforceSingleParent", "driveId"].iter() {
14539 if self._additional_params.contains_key(field) {
14540 dlg.finished(false);
14541 return Err(common::Error::FieldClash(field));
14542 }
14543 }
14544
14545 let mut params = Params::with_capacity(3 + self._additional_params.len());
14546 if let Some(value) = self._enforce_single_parent.as_ref() {
14547 params.push("enforceSingleParent", value.to_string());
14548 }
14549 if let Some(value) = self._drive_id.as_ref() {
14550 params.push("driveId", value);
14551 }
14552
14553 params.extend(self._additional_params.iter());
14554
14555 let mut url = self.hub._base_url.clone() + "files/trash";
14556 if self._scopes.is_empty() {
14557 self._scopes.insert(Scope::Full.as_ref().to_string());
14558 }
14559
14560 let url = params.parse_with_url(&url);
14561
14562 loop {
14563 let token = match self
14564 .hub
14565 .auth
14566 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14567 .await
14568 {
14569 Ok(token) => token,
14570 Err(e) => match dlg.token(e) {
14571 Ok(token) => token,
14572 Err(e) => {
14573 dlg.finished(false);
14574 return Err(common::Error::MissingToken(e));
14575 }
14576 },
14577 };
14578 let mut req_result = {
14579 let client = &self.hub.client;
14580 dlg.pre_request();
14581 let mut req_builder = hyper::Request::builder()
14582 .method(hyper::Method::DELETE)
14583 .uri(url.as_str())
14584 .header(USER_AGENT, self.hub._user_agent.clone());
14585
14586 if let Some(token) = token.as_ref() {
14587 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14588 }
14589
14590 let request = req_builder
14591 .header(CONTENT_LENGTH, 0_u64)
14592 .body(common::to_body::<String>(None));
14593
14594 client.request(request.unwrap()).await
14595 };
14596
14597 match req_result {
14598 Err(err) => {
14599 if let common::Retry::After(d) = dlg.http_error(&err) {
14600 sleep(d).await;
14601 continue;
14602 }
14603 dlg.finished(false);
14604 return Err(common::Error::HttpError(err));
14605 }
14606 Ok(res) => {
14607 let (mut parts, body) = res.into_parts();
14608 let mut body = common::Body::new(body);
14609 if !parts.status.is_success() {
14610 let bytes = common::to_bytes(body).await.unwrap_or_default();
14611 let error = serde_json::from_str(&common::to_string(&bytes));
14612 let response = common::to_response(parts, bytes.into());
14613
14614 if let common::Retry::After(d) =
14615 dlg.http_failure(&response, error.as_ref().ok())
14616 {
14617 sleep(d).await;
14618 continue;
14619 }
14620
14621 dlg.finished(false);
14622
14623 return Err(match error {
14624 Ok(value) => common::Error::BadRequest(value),
14625 _ => common::Error::Failure(response),
14626 });
14627 }
14628 let response = common::Response::from_parts(parts, body);
14629
14630 dlg.finished(true);
14631 return Ok(response);
14632 }
14633 }
14634 }
14635 }
14636
14637 /// 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.
14638 ///
14639 /// Sets the *enforce single parent* query property to the given value.
14640 pub fn enforce_single_parent(mut self, new_value: bool) -> FileEmptyTrashCall<'a, C> {
14641 self._enforce_single_parent = Some(new_value);
14642 self
14643 }
14644 /// If set, empties the trash of the provided shared drive.
14645 ///
14646 /// Sets the *drive id* query property to the given value.
14647 pub fn drive_id(mut self, new_value: &str) -> FileEmptyTrashCall<'a, C> {
14648 self._drive_id = Some(new_value.to_string());
14649 self
14650 }
14651 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14652 /// while executing the actual API request.
14653 ///
14654 /// ````text
14655 /// It should be used to handle progress information, and to implement a certain level of resilience.
14656 /// ````
14657 ///
14658 /// Sets the *delegate* property to the given value.
14659 pub fn delegate(
14660 mut self,
14661 new_value: &'a mut dyn common::Delegate,
14662 ) -> FileEmptyTrashCall<'a, C> {
14663 self._delegate = Some(new_value);
14664 self
14665 }
14666
14667 /// Set any additional parameter of the query string used in the request.
14668 /// It should be used to set parameters which are not yet available through their own
14669 /// setters.
14670 ///
14671 /// Please note that this method must not be used to set any of the known parameters
14672 /// which have their own setter method. If done anyway, the request will fail.
14673 ///
14674 /// # Additional Parameters
14675 ///
14676 /// * *$.xgafv* (query-string) - V1 error format.
14677 /// * *access_token* (query-string) - OAuth access token.
14678 /// * *alt* (query-string) - Data format for response.
14679 /// * *callback* (query-string) - JSONP
14680 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14681 /// * *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.
14682 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14683 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14684 /// * *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.
14685 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14686 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14687 pub fn param<T>(mut self, name: T, value: T) -> FileEmptyTrashCall<'a, C>
14688 where
14689 T: AsRef<str>,
14690 {
14691 self._additional_params
14692 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14693 self
14694 }
14695
14696 /// Identifies the authorization scope for the method you are building.
14697 ///
14698 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14699 /// [`Scope::Full`].
14700 ///
14701 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14702 /// tokens for more than one scope.
14703 ///
14704 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14705 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14706 /// sufficient, a read-write scope will do as well.
14707 pub fn add_scope<St>(mut self, scope: St) -> FileEmptyTrashCall<'a, C>
14708 where
14709 St: AsRef<str>,
14710 {
14711 self._scopes.insert(String::from(scope.as_ref()));
14712 self
14713 }
14714 /// Identifies the authorization scope(s) for the method you are building.
14715 ///
14716 /// See [`Self::add_scope()`] for details.
14717 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileEmptyTrashCall<'a, C>
14718 where
14719 I: IntoIterator<Item = St>,
14720 St: AsRef<str>,
14721 {
14722 self._scopes
14723 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14724 self
14725 }
14726
14727 /// Removes all scopes, and no default scope will be used either.
14728 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14729 /// for details).
14730 pub fn clear_scopes(mut self) -> FileEmptyTrashCall<'a, C> {
14731 self._scopes.clear();
14732 self
14733 }
14734}
14735
14736/// Exports a Google Workspace document to the requested MIME type and returns exported byte content. Note that the exported content is limited to 10MB.
14737///
14738/// This method supports **media download**. To enable it, adjust the builder like this:
14739/// `.param("alt", "media")`.
14740///
14741/// A builder for the *export* method supported by a *file* resource.
14742/// It is not used directly, but through a [`FileMethods`] instance.
14743///
14744/// # Example
14745///
14746/// Instantiate a resource method builder
14747///
14748/// ```test_harness,no_run
14749/// # extern crate hyper;
14750/// # extern crate hyper_rustls;
14751/// # extern crate google_drive2 as drive2;
14752/// # async fn dox() {
14753/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14754///
14755/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14756/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14757/// # .with_native_roots()
14758/// # .unwrap()
14759/// # .https_only()
14760/// # .enable_http2()
14761/// # .build();
14762///
14763/// # let executor = hyper_util::rt::TokioExecutor::new();
14764/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14765/// # secret,
14766/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14767/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14768/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14769/// # ),
14770/// # ).build().await.unwrap();
14771///
14772/// # let client = hyper_util::client::legacy::Client::builder(
14773/// # hyper_util::rt::TokioExecutor::new()
14774/// # )
14775/// # .build(
14776/// # hyper_rustls::HttpsConnectorBuilder::new()
14777/// # .with_native_roots()
14778/// # .unwrap()
14779/// # .https_or_http()
14780/// # .enable_http2()
14781/// # .build()
14782/// # );
14783/// # let mut hub = DriveHub::new(client, auth);
14784/// // You can configure optional parameters by calling the respective setters at will, and
14785/// // execute the final call using `doit()`.
14786/// // Values shown here are possibly random and not representative !
14787/// let result = hub.files().export("fileId", "mimeType")
14788/// .doit().await;
14789/// # }
14790/// ```
14791pub struct FileExportCall<'a, C>
14792where
14793 C: 'a,
14794{
14795 hub: &'a DriveHub<C>,
14796 _file_id: String,
14797 _mime_type: String,
14798 _delegate: Option<&'a mut dyn common::Delegate>,
14799 _additional_params: HashMap<String, String>,
14800 _scopes: BTreeSet<String>,
14801}
14802
14803impl<'a, C> common::CallBuilder for FileExportCall<'a, C> {}
14804
14805impl<'a, C> FileExportCall<'a, C>
14806where
14807 C: common::Connector,
14808{
14809 /// Perform the operation you have build so far.
14810 pub async fn doit(mut self) -> common::Result<common::Response> {
14811 use std::borrow::Cow;
14812 use std::io::{Read, Seek};
14813
14814 use common::{url::Params, ToParts};
14815 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14816
14817 let mut dd = common::DefaultDelegate;
14818 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14819 dlg.begin(common::MethodInfo {
14820 id: "drive.files.export",
14821 http_method: hyper::Method::GET,
14822 });
14823
14824 for &field in ["fileId", "mimeType"].iter() {
14825 if self._additional_params.contains_key(field) {
14826 dlg.finished(false);
14827 return Err(common::Error::FieldClash(field));
14828 }
14829 }
14830
14831 let mut params = Params::with_capacity(3 + self._additional_params.len());
14832 params.push("fileId", self._file_id);
14833 params.push("mimeType", self._mime_type);
14834
14835 params.extend(self._additional_params.iter());
14836
14837 let mut url = self.hub._base_url.clone() + "files/{fileId}/export";
14838 if self._scopes.is_empty() {
14839 self._scopes
14840 .insert(Scope::MeetReadonly.as_ref().to_string());
14841 }
14842
14843 #[allow(clippy::single_element_loop)]
14844 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
14845 url = params.uri_replacement(url, param_name, find_this, false);
14846 }
14847 {
14848 let to_remove = ["fileId"];
14849 params.remove_params(&to_remove);
14850 }
14851
14852 let url = params.parse_with_url(&url);
14853
14854 loop {
14855 let token = match self
14856 .hub
14857 .auth
14858 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14859 .await
14860 {
14861 Ok(token) => token,
14862 Err(e) => match dlg.token(e) {
14863 Ok(token) => token,
14864 Err(e) => {
14865 dlg.finished(false);
14866 return Err(common::Error::MissingToken(e));
14867 }
14868 },
14869 };
14870 let mut req_result = {
14871 let client = &self.hub.client;
14872 dlg.pre_request();
14873 let mut req_builder = hyper::Request::builder()
14874 .method(hyper::Method::GET)
14875 .uri(url.as_str())
14876 .header(USER_AGENT, self.hub._user_agent.clone());
14877
14878 if let Some(token) = token.as_ref() {
14879 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14880 }
14881
14882 let request = req_builder
14883 .header(CONTENT_LENGTH, 0_u64)
14884 .body(common::to_body::<String>(None));
14885
14886 client.request(request.unwrap()).await
14887 };
14888
14889 match req_result {
14890 Err(err) => {
14891 if let common::Retry::After(d) = dlg.http_error(&err) {
14892 sleep(d).await;
14893 continue;
14894 }
14895 dlg.finished(false);
14896 return Err(common::Error::HttpError(err));
14897 }
14898 Ok(res) => {
14899 let (mut parts, body) = res.into_parts();
14900 let mut body = common::Body::new(body);
14901 if !parts.status.is_success() {
14902 let bytes = common::to_bytes(body).await.unwrap_or_default();
14903 let error = serde_json::from_str(&common::to_string(&bytes));
14904 let response = common::to_response(parts, bytes.into());
14905
14906 if let common::Retry::After(d) =
14907 dlg.http_failure(&response, error.as_ref().ok())
14908 {
14909 sleep(d).await;
14910 continue;
14911 }
14912
14913 dlg.finished(false);
14914
14915 return Err(match error {
14916 Ok(value) => common::Error::BadRequest(value),
14917 _ => common::Error::Failure(response),
14918 });
14919 }
14920 let response = common::Response::from_parts(parts, body);
14921
14922 dlg.finished(true);
14923 return Ok(response);
14924 }
14925 }
14926 }
14927 }
14928
14929 /// The ID of the file.
14930 ///
14931 /// Sets the *file id* path property to the given value.
14932 ///
14933 /// Even though the property as already been set when instantiating this call,
14934 /// we provide this method for API completeness.
14935 pub fn file_id(mut self, new_value: &str) -> FileExportCall<'a, C> {
14936 self._file_id = new_value.to_string();
14937 self
14938 }
14939 /// Required. The MIME type of the format requested for this export.
14940 ///
14941 /// Sets the *mime type* query property to the given value.
14942 ///
14943 /// Even though the property as already been set when instantiating this call,
14944 /// we provide this method for API completeness.
14945 pub fn mime_type(mut self, new_value: &str) -> FileExportCall<'a, C> {
14946 self._mime_type = new_value.to_string();
14947 self
14948 }
14949 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14950 /// while executing the actual API request.
14951 ///
14952 /// ````text
14953 /// It should be used to handle progress information, and to implement a certain level of resilience.
14954 /// ````
14955 ///
14956 /// Sets the *delegate* property to the given value.
14957 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileExportCall<'a, C> {
14958 self._delegate = Some(new_value);
14959 self
14960 }
14961
14962 /// Set any additional parameter of the query string used in the request.
14963 /// It should be used to set parameters which are not yet available through their own
14964 /// setters.
14965 ///
14966 /// Please note that this method must not be used to set any of the known parameters
14967 /// which have their own setter method. If done anyway, the request will fail.
14968 ///
14969 /// # Additional Parameters
14970 ///
14971 /// * *$.xgafv* (query-string) - V1 error format.
14972 /// * *access_token* (query-string) - OAuth access token.
14973 /// * *alt* (query-string) - Data format for response.
14974 /// * *callback* (query-string) - JSONP
14975 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14976 /// * *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.
14977 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14978 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14979 /// * *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.
14980 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14981 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14982 pub fn param<T>(mut self, name: T, value: T) -> FileExportCall<'a, C>
14983 where
14984 T: AsRef<str>,
14985 {
14986 self._additional_params
14987 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14988 self
14989 }
14990
14991 /// Identifies the authorization scope for the method you are building.
14992 ///
14993 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14994 /// [`Scope::MeetReadonly`].
14995 ///
14996 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14997 /// tokens for more than one scope.
14998 ///
14999 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15000 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15001 /// sufficient, a read-write scope will do as well.
15002 pub fn add_scope<St>(mut self, scope: St) -> FileExportCall<'a, C>
15003 where
15004 St: AsRef<str>,
15005 {
15006 self._scopes.insert(String::from(scope.as_ref()));
15007 self
15008 }
15009 /// Identifies the authorization scope(s) for the method you are building.
15010 ///
15011 /// See [`Self::add_scope()`] for details.
15012 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileExportCall<'a, C>
15013 where
15014 I: IntoIterator<Item = St>,
15015 St: AsRef<str>,
15016 {
15017 self._scopes
15018 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15019 self
15020 }
15021
15022 /// Removes all scopes, and no default scope will be used either.
15023 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15024 /// for details).
15025 pub fn clear_scopes(mut self) -> FileExportCall<'a, C> {
15026 self._scopes.clear();
15027 self
15028 }
15029}
15030
15031/// Generates a set of file IDs which can be provided in insert or copy requests.
15032///
15033/// A builder for the *generateIds* method supported by a *file* resource.
15034/// It is not used directly, but through a [`FileMethods`] instance.
15035///
15036/// # Example
15037///
15038/// Instantiate a resource method builder
15039///
15040/// ```test_harness,no_run
15041/// # extern crate hyper;
15042/// # extern crate hyper_rustls;
15043/// # extern crate google_drive2 as drive2;
15044/// # async fn dox() {
15045/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15046///
15047/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15048/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15049/// # .with_native_roots()
15050/// # .unwrap()
15051/// # .https_only()
15052/// # .enable_http2()
15053/// # .build();
15054///
15055/// # let executor = hyper_util::rt::TokioExecutor::new();
15056/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15057/// # secret,
15058/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15059/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15060/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15061/// # ),
15062/// # ).build().await.unwrap();
15063///
15064/// # let client = hyper_util::client::legacy::Client::builder(
15065/// # hyper_util::rt::TokioExecutor::new()
15066/// # )
15067/// # .build(
15068/// # hyper_rustls::HttpsConnectorBuilder::new()
15069/// # .with_native_roots()
15070/// # .unwrap()
15071/// # .https_or_http()
15072/// # .enable_http2()
15073/// # .build()
15074/// # );
15075/// # let mut hub = DriveHub::new(client, auth);
15076/// // You can configure optional parameters by calling the respective setters at will, and
15077/// // execute the final call using `doit()`.
15078/// // Values shown here are possibly random and not representative !
15079/// let result = hub.files().generate_ids()
15080/// .type_("dolore")
15081/// .space("eos")
15082/// .max_results(-52)
15083/// .doit().await;
15084/// # }
15085/// ```
15086pub struct FileGenerateIdCall<'a, C>
15087where
15088 C: 'a,
15089{
15090 hub: &'a DriveHub<C>,
15091 _type_: Option<String>,
15092 _space: Option<String>,
15093 _max_results: Option<i32>,
15094 _delegate: Option<&'a mut dyn common::Delegate>,
15095 _additional_params: HashMap<String, String>,
15096 _scopes: BTreeSet<String>,
15097}
15098
15099impl<'a, C> common::CallBuilder for FileGenerateIdCall<'a, C> {}
15100
15101impl<'a, C> FileGenerateIdCall<'a, C>
15102where
15103 C: common::Connector,
15104{
15105 /// Perform the operation you have build so far.
15106 pub async fn doit(mut self) -> common::Result<(common::Response, GeneratedIds)> {
15107 use std::borrow::Cow;
15108 use std::io::{Read, Seek};
15109
15110 use common::{url::Params, ToParts};
15111 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15112
15113 let mut dd = common::DefaultDelegate;
15114 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15115 dlg.begin(common::MethodInfo {
15116 id: "drive.files.generateIds",
15117 http_method: hyper::Method::GET,
15118 });
15119
15120 for &field in ["alt", "type", "space", "maxResults"].iter() {
15121 if self._additional_params.contains_key(field) {
15122 dlg.finished(false);
15123 return Err(common::Error::FieldClash(field));
15124 }
15125 }
15126
15127 let mut params = Params::with_capacity(5 + self._additional_params.len());
15128 if let Some(value) = self._type_.as_ref() {
15129 params.push("type", value);
15130 }
15131 if let Some(value) = self._space.as_ref() {
15132 params.push("space", value);
15133 }
15134 if let Some(value) = self._max_results.as_ref() {
15135 params.push("maxResults", value.to_string());
15136 }
15137
15138 params.extend(self._additional_params.iter());
15139
15140 params.push("alt", "json");
15141 let mut url = self.hub._base_url.clone() + "files/generateIds";
15142 if self._scopes.is_empty() {
15143 self._scopes.insert(Scope::Full.as_ref().to_string());
15144 }
15145
15146 let url = params.parse_with_url(&url);
15147
15148 loop {
15149 let token = match self
15150 .hub
15151 .auth
15152 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15153 .await
15154 {
15155 Ok(token) => token,
15156 Err(e) => match dlg.token(e) {
15157 Ok(token) => token,
15158 Err(e) => {
15159 dlg.finished(false);
15160 return Err(common::Error::MissingToken(e));
15161 }
15162 },
15163 };
15164 let mut req_result = {
15165 let client = &self.hub.client;
15166 dlg.pre_request();
15167 let mut req_builder = hyper::Request::builder()
15168 .method(hyper::Method::GET)
15169 .uri(url.as_str())
15170 .header(USER_AGENT, self.hub._user_agent.clone());
15171
15172 if let Some(token) = token.as_ref() {
15173 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15174 }
15175
15176 let request = req_builder
15177 .header(CONTENT_LENGTH, 0_u64)
15178 .body(common::to_body::<String>(None));
15179
15180 client.request(request.unwrap()).await
15181 };
15182
15183 match req_result {
15184 Err(err) => {
15185 if let common::Retry::After(d) = dlg.http_error(&err) {
15186 sleep(d).await;
15187 continue;
15188 }
15189 dlg.finished(false);
15190 return Err(common::Error::HttpError(err));
15191 }
15192 Ok(res) => {
15193 let (mut parts, body) = res.into_parts();
15194 let mut body = common::Body::new(body);
15195 if !parts.status.is_success() {
15196 let bytes = common::to_bytes(body).await.unwrap_or_default();
15197 let error = serde_json::from_str(&common::to_string(&bytes));
15198 let response = common::to_response(parts, bytes.into());
15199
15200 if let common::Retry::After(d) =
15201 dlg.http_failure(&response, error.as_ref().ok())
15202 {
15203 sleep(d).await;
15204 continue;
15205 }
15206
15207 dlg.finished(false);
15208
15209 return Err(match error {
15210 Ok(value) => common::Error::BadRequest(value),
15211 _ => common::Error::Failure(response),
15212 });
15213 }
15214 let response = {
15215 let bytes = common::to_bytes(body).await.unwrap_or_default();
15216 let encoded = common::to_string(&bytes);
15217 match serde_json::from_str(&encoded) {
15218 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15219 Err(error) => {
15220 dlg.response_json_decode_error(&encoded, &error);
15221 return Err(common::Error::JsonDecodeError(
15222 encoded.to_string(),
15223 error,
15224 ));
15225 }
15226 }
15227 };
15228
15229 dlg.finished(true);
15230 return Ok(response);
15231 }
15232 }
15233 }
15234 }
15235
15236 /// 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`)
15237 ///
15238 /// Sets the *type* query property to the given value.
15239 pub fn type_(mut self, new_value: &str) -> FileGenerateIdCall<'a, C> {
15240 self._type_ = Some(new_value.to_string());
15241 self
15242 }
15243 /// The space in which the IDs can be used to create new files. Supported values are `drive` and `appDataFolder`. (Default: `drive`)
15244 ///
15245 /// Sets the *space* query property to the given value.
15246 pub fn space(mut self, new_value: &str) -> FileGenerateIdCall<'a, C> {
15247 self._space = Some(new_value.to_string());
15248 self
15249 }
15250 /// Maximum number of IDs to return.
15251 ///
15252 /// Sets the *max results* query property to the given value.
15253 pub fn max_results(mut self, new_value: i32) -> FileGenerateIdCall<'a, C> {
15254 self._max_results = Some(new_value);
15255 self
15256 }
15257 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15258 /// while executing the actual API request.
15259 ///
15260 /// ````text
15261 /// It should be used to handle progress information, and to implement a certain level of resilience.
15262 /// ````
15263 ///
15264 /// Sets the *delegate* property to the given value.
15265 pub fn delegate(
15266 mut self,
15267 new_value: &'a mut dyn common::Delegate,
15268 ) -> FileGenerateIdCall<'a, C> {
15269 self._delegate = Some(new_value);
15270 self
15271 }
15272
15273 /// Set any additional parameter of the query string used in the request.
15274 /// It should be used to set parameters which are not yet available through their own
15275 /// setters.
15276 ///
15277 /// Please note that this method must not be used to set any of the known parameters
15278 /// which have their own setter method. If done anyway, the request will fail.
15279 ///
15280 /// # Additional Parameters
15281 ///
15282 /// * *$.xgafv* (query-string) - V1 error format.
15283 /// * *access_token* (query-string) - OAuth access token.
15284 /// * *alt* (query-string) - Data format for response.
15285 /// * *callback* (query-string) - JSONP
15286 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15287 /// * *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.
15288 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15289 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15290 /// * *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.
15291 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15292 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15293 pub fn param<T>(mut self, name: T, value: T) -> FileGenerateIdCall<'a, C>
15294 where
15295 T: AsRef<str>,
15296 {
15297 self._additional_params
15298 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15299 self
15300 }
15301
15302 /// Identifies the authorization scope for the method you are building.
15303 ///
15304 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15305 /// [`Scope::Full`].
15306 ///
15307 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15308 /// tokens for more than one scope.
15309 ///
15310 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15311 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15312 /// sufficient, a read-write scope will do as well.
15313 pub fn add_scope<St>(mut self, scope: St) -> FileGenerateIdCall<'a, C>
15314 where
15315 St: AsRef<str>,
15316 {
15317 self._scopes.insert(String::from(scope.as_ref()));
15318 self
15319 }
15320 /// Identifies the authorization scope(s) for the method you are building.
15321 ///
15322 /// See [`Self::add_scope()`] for details.
15323 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileGenerateIdCall<'a, C>
15324 where
15325 I: IntoIterator<Item = St>,
15326 St: AsRef<str>,
15327 {
15328 self._scopes
15329 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15330 self
15331 }
15332
15333 /// Removes all scopes, and no default scope will be used either.
15334 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15335 /// for details).
15336 pub fn clear_scopes(mut self) -> FileGenerateIdCall<'a, C> {
15337 self._scopes.clear();
15338 self
15339 }
15340}
15341
15342/// 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/workspace/drive/api/reference/rest/v2/files/export) instead. For more information, see [Download & export files](https://developers.google.com/workspace/drive/api/guides/manage-downloads).
15343///
15344/// This method supports **media download**. To enable it, adjust the builder like this:
15345/// `.param("alt", "media")`.
15346/// Please note that due to missing multi-part support on the server side, you will only receive the media,
15347/// but not the `File` structure that you would usually get. The latter will be a default value.
15348///
15349/// A builder for the *get* method supported by a *file* resource.
15350/// It is not used directly, but through a [`FileMethods`] instance.
15351///
15352/// # Example
15353///
15354/// Instantiate a resource method builder
15355///
15356/// ```test_harness,no_run
15357/// # extern crate hyper;
15358/// # extern crate hyper_rustls;
15359/// # extern crate google_drive2 as drive2;
15360/// # async fn dox() {
15361/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15362///
15363/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15364/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15365/// # .with_native_roots()
15366/// # .unwrap()
15367/// # .https_only()
15368/// # .enable_http2()
15369/// # .build();
15370///
15371/// # let executor = hyper_util::rt::TokioExecutor::new();
15372/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15373/// # secret,
15374/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15375/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15376/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15377/// # ),
15378/// # ).build().await.unwrap();
15379///
15380/// # let client = hyper_util::client::legacy::Client::builder(
15381/// # hyper_util::rt::TokioExecutor::new()
15382/// # )
15383/// # .build(
15384/// # hyper_rustls::HttpsConnectorBuilder::new()
15385/// # .with_native_roots()
15386/// # .unwrap()
15387/// # .https_or_http()
15388/// # .enable_http2()
15389/// # .build()
15390/// # );
15391/// # let mut hub = DriveHub::new(client, auth);
15392/// // You can configure optional parameters by calling the respective setters at will, and
15393/// // execute the final call using `doit()`.
15394/// // Values shown here are possibly random and not representative !
15395/// let result = hub.files().get("fileId")
15396/// .update_viewed_date(false)
15397/// .supports_team_drives(true)
15398/// .supports_all_drives(false)
15399/// .revision_id("duo")
15400/// .projection("sadipscing")
15401/// .include_permissions_for_view("ut")
15402/// .include_labels("rebum.")
15403/// .acknowledge_abuse(false)
15404/// .doit().await;
15405/// # }
15406/// ```
15407pub struct FileGetCall<'a, C>
15408where
15409 C: 'a,
15410{
15411 hub: &'a DriveHub<C>,
15412 _file_id: String,
15413 _update_viewed_date: Option<bool>,
15414 _supports_team_drives: Option<bool>,
15415 _supports_all_drives: Option<bool>,
15416 _revision_id: Option<String>,
15417 _projection: Option<String>,
15418 _include_permissions_for_view: Option<String>,
15419 _include_labels: Option<String>,
15420 _acknowledge_abuse: Option<bool>,
15421 _delegate: Option<&'a mut dyn common::Delegate>,
15422 _additional_params: HashMap<String, String>,
15423 _scopes: BTreeSet<String>,
15424}
15425
15426impl<'a, C> common::CallBuilder for FileGetCall<'a, C> {}
15427
15428impl<'a, C> FileGetCall<'a, C>
15429where
15430 C: common::Connector,
15431{
15432 /// Perform the operation you have build so far.
15433 pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
15434 use std::borrow::Cow;
15435 use std::io::{Read, Seek};
15436
15437 use common::{url::Params, ToParts};
15438 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15439
15440 let mut dd = common::DefaultDelegate;
15441 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15442 dlg.begin(common::MethodInfo {
15443 id: "drive.files.get",
15444 http_method: hyper::Method::GET,
15445 });
15446
15447 for &field in [
15448 "fileId",
15449 "updateViewedDate",
15450 "supportsTeamDrives",
15451 "supportsAllDrives",
15452 "revisionId",
15453 "projection",
15454 "includePermissionsForView",
15455 "includeLabels",
15456 "acknowledgeAbuse",
15457 ]
15458 .iter()
15459 {
15460 if self._additional_params.contains_key(field) {
15461 dlg.finished(false);
15462 return Err(common::Error::FieldClash(field));
15463 }
15464 }
15465
15466 let mut params = Params::with_capacity(10 + self._additional_params.len());
15467 params.push("fileId", self._file_id);
15468 if let Some(value) = self._update_viewed_date.as_ref() {
15469 params.push("updateViewedDate", value.to_string());
15470 }
15471 if let Some(value) = self._supports_team_drives.as_ref() {
15472 params.push("supportsTeamDrives", value.to_string());
15473 }
15474 if let Some(value) = self._supports_all_drives.as_ref() {
15475 params.push("supportsAllDrives", value.to_string());
15476 }
15477 if let Some(value) = self._revision_id.as_ref() {
15478 params.push("revisionId", value);
15479 }
15480 if let Some(value) = self._projection.as_ref() {
15481 params.push("projection", value);
15482 }
15483 if let Some(value) = self._include_permissions_for_view.as_ref() {
15484 params.push("includePermissionsForView", value);
15485 }
15486 if let Some(value) = self._include_labels.as_ref() {
15487 params.push("includeLabels", value);
15488 }
15489 if let Some(value) = self._acknowledge_abuse.as_ref() {
15490 params.push("acknowledgeAbuse", value.to_string());
15491 }
15492
15493 params.extend(self._additional_params.iter());
15494
15495 let (alt_field_missing, enable_resource_parsing) = {
15496 if let Some(value) = params.get("alt") {
15497 (false, value == "json")
15498 } else {
15499 (true, true)
15500 }
15501 };
15502 if alt_field_missing {
15503 params.push("alt", "json");
15504 }
15505 let mut url = self.hub._base_url.clone() + "files/{fileId}";
15506 if self._scopes.is_empty() {
15507 self._scopes
15508 .insert(Scope::MeetReadonly.as_ref().to_string());
15509 }
15510
15511 #[allow(clippy::single_element_loop)]
15512 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
15513 url = params.uri_replacement(url, param_name, find_this, false);
15514 }
15515 {
15516 let to_remove = ["fileId"];
15517 params.remove_params(&to_remove);
15518 }
15519
15520 let url = params.parse_with_url(&url);
15521
15522 loop {
15523 let token = match self
15524 .hub
15525 .auth
15526 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15527 .await
15528 {
15529 Ok(token) => token,
15530 Err(e) => match dlg.token(e) {
15531 Ok(token) => token,
15532 Err(e) => {
15533 dlg.finished(false);
15534 return Err(common::Error::MissingToken(e));
15535 }
15536 },
15537 };
15538 let mut req_result = {
15539 let client = &self.hub.client;
15540 dlg.pre_request();
15541 let mut req_builder = hyper::Request::builder()
15542 .method(hyper::Method::GET)
15543 .uri(url.as_str())
15544 .header(USER_AGENT, self.hub._user_agent.clone());
15545
15546 if let Some(token) = token.as_ref() {
15547 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15548 }
15549
15550 let request = req_builder
15551 .header(CONTENT_LENGTH, 0_u64)
15552 .body(common::to_body::<String>(None));
15553
15554 client.request(request.unwrap()).await
15555 };
15556
15557 match req_result {
15558 Err(err) => {
15559 if let common::Retry::After(d) = dlg.http_error(&err) {
15560 sleep(d).await;
15561 continue;
15562 }
15563 dlg.finished(false);
15564 return Err(common::Error::HttpError(err));
15565 }
15566 Ok(res) => {
15567 let (mut parts, body) = res.into_parts();
15568 let mut body = common::Body::new(body);
15569 if !parts.status.is_success() {
15570 let bytes = common::to_bytes(body).await.unwrap_or_default();
15571 let error = serde_json::from_str(&common::to_string(&bytes));
15572 let response = common::to_response(parts, bytes.into());
15573
15574 if let common::Retry::After(d) =
15575 dlg.http_failure(&response, error.as_ref().ok())
15576 {
15577 sleep(d).await;
15578 continue;
15579 }
15580
15581 dlg.finished(false);
15582
15583 return Err(match error {
15584 Ok(value) => common::Error::BadRequest(value),
15585 _ => common::Error::Failure(response),
15586 });
15587 }
15588 let response = if enable_resource_parsing {
15589 let bytes = common::to_bytes(body).await.unwrap_or_default();
15590 let encoded = common::to_string(&bytes);
15591 match serde_json::from_str(&encoded) {
15592 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15593 Err(error) => {
15594 dlg.response_json_decode_error(&encoded, &error);
15595 return Err(common::Error::JsonDecodeError(
15596 encoded.to_string(),
15597 error,
15598 ));
15599 }
15600 }
15601 } else {
15602 (
15603 common::Response::from_parts(parts, body),
15604 Default::default(),
15605 )
15606 };
15607
15608 dlg.finished(true);
15609 return Ok(response);
15610 }
15611 }
15612 }
15613 }
15614
15615 /// The ID for the file in question.
15616 ///
15617 /// Sets the *file id* path property to the given value.
15618 ///
15619 /// Even though the property as already been set when instantiating this call,
15620 /// we provide this method for API completeness.
15621 pub fn file_id(mut self, new_value: &str) -> FileGetCall<'a, C> {
15622 self._file_id = new_value.to_string();
15623 self
15624 }
15625 /// Deprecated: Use `files.update` with `modifiedDateBehavior=noChange, updateViewedDate=true` and an empty request body.
15626 ///
15627 /// Sets the *update viewed date* query property to the given value.
15628 pub fn update_viewed_date(mut self, new_value: bool) -> FileGetCall<'a, C> {
15629 self._update_viewed_date = Some(new_value);
15630 self
15631 }
15632 /// Deprecated: Use `supportsAllDrives` instead.
15633 ///
15634 /// Sets the *supports team drives* query property to the given value.
15635 pub fn supports_team_drives(mut self, new_value: bool) -> FileGetCall<'a, C> {
15636 self._supports_team_drives = Some(new_value);
15637 self
15638 }
15639 /// Whether the requesting application supports both My Drives and shared drives.
15640 ///
15641 /// Sets the *supports all drives* query property to the given value.
15642 pub fn supports_all_drives(mut self, new_value: bool) -> FileGetCall<'a, C> {
15643 self._supports_all_drives = Some(new_value);
15644 self
15645 }
15646 /// Specifies the Revision ID that should be downloaded. Ignored unless alt=media is specified.
15647 ///
15648 /// Sets the *revision id* query property to the given value.
15649 pub fn revision_id(mut self, new_value: &str) -> FileGetCall<'a, C> {
15650 self._revision_id = Some(new_value.to_string());
15651 self
15652 }
15653 /// Deprecated: This parameter has no function.
15654 ///
15655 /// Sets the *projection* query property to the given value.
15656 pub fn projection(mut self, new_value: &str) -> FileGetCall<'a, C> {
15657 self._projection = Some(new_value.to_string());
15658 self
15659 }
15660 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
15661 ///
15662 /// Sets the *include permissions for view* query property to the given value.
15663 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileGetCall<'a, C> {
15664 self._include_permissions_for_view = Some(new_value.to_string());
15665 self
15666 }
15667 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
15668 ///
15669 /// Sets the *include labels* query property to the given value.
15670 pub fn include_labels(mut self, new_value: &str) -> FileGetCall<'a, C> {
15671 self._include_labels = Some(new_value.to_string());
15672 self
15673 }
15674 /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when the `alt` parameter is set to `media` and the user is the owner of the file or an organizer of the shared drive in which the file resides.
15675 ///
15676 /// Sets the *acknowledge abuse* query property to the given value.
15677 pub fn acknowledge_abuse(mut self, new_value: bool) -> FileGetCall<'a, C> {
15678 self._acknowledge_abuse = Some(new_value);
15679 self
15680 }
15681 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15682 /// while executing the actual API request.
15683 ///
15684 /// ````text
15685 /// It should be used to handle progress information, and to implement a certain level of resilience.
15686 /// ````
15687 ///
15688 /// Sets the *delegate* property to the given value.
15689 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileGetCall<'a, C> {
15690 self._delegate = Some(new_value);
15691 self
15692 }
15693
15694 /// Set any additional parameter of the query string used in the request.
15695 /// It should be used to set parameters which are not yet available through their own
15696 /// setters.
15697 ///
15698 /// Please note that this method must not be used to set any of the known parameters
15699 /// which have their own setter method. If done anyway, the request will fail.
15700 ///
15701 /// # Additional Parameters
15702 ///
15703 /// * *$.xgafv* (query-string) - V1 error format.
15704 /// * *access_token* (query-string) - OAuth access token.
15705 /// * *alt* (query-string) - Data format for response.
15706 /// * *callback* (query-string) - JSONP
15707 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15708 /// * *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.
15709 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15710 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15711 /// * *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.
15712 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15713 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15714 pub fn param<T>(mut self, name: T, value: T) -> FileGetCall<'a, C>
15715 where
15716 T: AsRef<str>,
15717 {
15718 self._additional_params
15719 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15720 self
15721 }
15722
15723 /// Identifies the authorization scope for the method you are building.
15724 ///
15725 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15726 /// [`Scope::MeetReadonly`].
15727 ///
15728 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15729 /// tokens for more than one scope.
15730 ///
15731 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15732 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15733 /// sufficient, a read-write scope will do as well.
15734 pub fn add_scope<St>(mut self, scope: St) -> FileGetCall<'a, C>
15735 where
15736 St: AsRef<str>,
15737 {
15738 self._scopes.insert(String::from(scope.as_ref()));
15739 self
15740 }
15741 /// Identifies the authorization scope(s) for the method you are building.
15742 ///
15743 /// See [`Self::add_scope()`] for details.
15744 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileGetCall<'a, C>
15745 where
15746 I: IntoIterator<Item = St>,
15747 St: AsRef<str>,
15748 {
15749 self._scopes
15750 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15751 self
15752 }
15753
15754 /// Removes all scopes, and no default scope will be used either.
15755 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15756 /// for details).
15757 pub fn clear_scopes(mut self) -> FileGetCall<'a, C> {
15758 self._scopes.clear();
15759 self
15760 }
15761}
15762
15763/// 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/workspace/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.
15764///
15765/// A builder for the *insert* method supported by a *file* resource.
15766/// It is not used directly, but through a [`FileMethods`] instance.
15767///
15768/// # Example
15769///
15770/// Instantiate a resource method builder
15771///
15772/// ```test_harness,no_run
15773/// # extern crate hyper;
15774/// # extern crate hyper_rustls;
15775/// # extern crate google_drive2 as drive2;
15776/// use drive2::api::File;
15777/// use std::fs;
15778/// # async fn dox() {
15779/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15780///
15781/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15782/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15783/// # .with_native_roots()
15784/// # .unwrap()
15785/// # .https_only()
15786/// # .enable_http2()
15787/// # .build();
15788///
15789/// # let executor = hyper_util::rt::TokioExecutor::new();
15790/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15791/// # secret,
15792/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15793/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15794/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15795/// # ),
15796/// # ).build().await.unwrap();
15797///
15798/// # let client = hyper_util::client::legacy::Client::builder(
15799/// # hyper_util::rt::TokioExecutor::new()
15800/// # )
15801/// # .build(
15802/// # hyper_rustls::HttpsConnectorBuilder::new()
15803/// # .with_native_roots()
15804/// # .unwrap()
15805/// # .https_or_http()
15806/// # .enable_http2()
15807/// # .build()
15808/// # );
15809/// # let mut hub = DriveHub::new(client, auth);
15810/// // As the method needs a request, you would usually fill it with the desired information
15811/// // into the respective structure. Some of the parts shown here might not be applicable !
15812/// // Values shown here are possibly random and not representative !
15813/// let mut req = File::default();
15814///
15815/// // You can configure optional parameters by calling the respective setters at will, and
15816/// // execute the final call using `upload(...)`.
15817/// // Values shown here are possibly random and not representative !
15818/// let result = hub.files().insert(req)
15819/// .visibility("kasd")
15820/// .use_content_as_indexable_text(false)
15821/// .timed_text_track_name("tempor")
15822/// .timed_text_language("sea")
15823/// .supports_team_drives(false)
15824/// .supports_all_drives(true)
15825/// .pinned(true)
15826/// .ocr_language("rebum.")
15827/// .ocr(false)
15828/// .include_permissions_for_view("clita")
15829/// .include_labels("Stet")
15830/// .enforce_single_parent(false)
15831/// .convert(false)
15832/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
15833/// # }
15834/// ```
15835pub struct FileInsertCall<'a, C>
15836where
15837 C: 'a,
15838{
15839 hub: &'a DriveHub<C>,
15840 _request: File,
15841 _visibility: Option<String>,
15842 _use_content_as_indexable_text: Option<bool>,
15843 _timed_text_track_name: Option<String>,
15844 _timed_text_language: Option<String>,
15845 _supports_team_drives: Option<bool>,
15846 _supports_all_drives: Option<bool>,
15847 _pinned: Option<bool>,
15848 _ocr_language: Option<String>,
15849 _ocr: Option<bool>,
15850 _include_permissions_for_view: Option<String>,
15851 _include_labels: Option<String>,
15852 _enforce_single_parent: Option<bool>,
15853 _convert: Option<bool>,
15854 _delegate: Option<&'a mut dyn common::Delegate>,
15855 _additional_params: HashMap<String, String>,
15856 _scopes: BTreeSet<String>,
15857}
15858
15859impl<'a, C> common::CallBuilder for FileInsertCall<'a, C> {}
15860
15861impl<'a, C> FileInsertCall<'a, C>
15862where
15863 C: common::Connector,
15864{
15865 /// Perform the operation you have build so far.
15866 async fn doit<RS>(
15867 mut self,
15868 mut reader: RS,
15869 reader_mime_type: mime::Mime,
15870 protocol: common::UploadProtocol,
15871 ) -> common::Result<(common::Response, File)>
15872 where
15873 RS: common::ReadSeek,
15874 {
15875 use std::borrow::Cow;
15876 use std::io::{Read, Seek};
15877
15878 use common::{url::Params, ToParts};
15879 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15880
15881 let mut dd = common::DefaultDelegate;
15882 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15883 dlg.begin(common::MethodInfo {
15884 id: "drive.files.insert",
15885 http_method: hyper::Method::POST,
15886 });
15887
15888 for &field in [
15889 "alt",
15890 "visibility",
15891 "useContentAsIndexableText",
15892 "timedTextTrackName",
15893 "timedTextLanguage",
15894 "supportsTeamDrives",
15895 "supportsAllDrives",
15896 "pinned",
15897 "ocrLanguage",
15898 "ocr",
15899 "includePermissionsForView",
15900 "includeLabels",
15901 "enforceSingleParent",
15902 "convert",
15903 ]
15904 .iter()
15905 {
15906 if self._additional_params.contains_key(field) {
15907 dlg.finished(false);
15908 return Err(common::Error::FieldClash(field));
15909 }
15910 }
15911
15912 let mut params = Params::with_capacity(16 + self._additional_params.len());
15913 if let Some(value) = self._visibility.as_ref() {
15914 params.push("visibility", value);
15915 }
15916 if let Some(value) = self._use_content_as_indexable_text.as_ref() {
15917 params.push("useContentAsIndexableText", value.to_string());
15918 }
15919 if let Some(value) = self._timed_text_track_name.as_ref() {
15920 params.push("timedTextTrackName", value);
15921 }
15922 if let Some(value) = self._timed_text_language.as_ref() {
15923 params.push("timedTextLanguage", value);
15924 }
15925 if let Some(value) = self._supports_team_drives.as_ref() {
15926 params.push("supportsTeamDrives", value.to_string());
15927 }
15928 if let Some(value) = self._supports_all_drives.as_ref() {
15929 params.push("supportsAllDrives", value.to_string());
15930 }
15931 if let Some(value) = self._pinned.as_ref() {
15932 params.push("pinned", value.to_string());
15933 }
15934 if let Some(value) = self._ocr_language.as_ref() {
15935 params.push("ocrLanguage", value);
15936 }
15937 if let Some(value) = self._ocr.as_ref() {
15938 params.push("ocr", value.to_string());
15939 }
15940 if let Some(value) = self._include_permissions_for_view.as_ref() {
15941 params.push("includePermissionsForView", value);
15942 }
15943 if let Some(value) = self._include_labels.as_ref() {
15944 params.push("includeLabels", value);
15945 }
15946 if let Some(value) = self._enforce_single_parent.as_ref() {
15947 params.push("enforceSingleParent", value.to_string());
15948 }
15949 if let Some(value) = self._convert.as_ref() {
15950 params.push("convert", value.to_string());
15951 }
15952
15953 params.extend(self._additional_params.iter());
15954
15955 params.push("alt", "json");
15956 let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
15957 (
15958 self.hub._root_url.clone() + "resumable/upload/drive/v2/files",
15959 "resumable",
15960 )
15961 } else if protocol == common::UploadProtocol::Simple {
15962 (
15963 self.hub._root_url.clone() + "upload/drive/v2/files",
15964 "multipart",
15965 )
15966 } else {
15967 unreachable!()
15968 };
15969 params.push("uploadType", upload_type);
15970 if self._scopes.is_empty() {
15971 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
15972 }
15973
15974 let url = params.parse_with_url(&url);
15975
15976 let mut json_mime_type = mime::APPLICATION_JSON;
15977 let mut request_value_reader = {
15978 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15979 common::remove_json_null_values(&mut value);
15980 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15981 serde_json::to_writer(&mut dst, &value).unwrap();
15982 dst
15983 };
15984 let request_size = request_value_reader
15985 .seek(std::io::SeekFrom::End(0))
15986 .unwrap();
15987 request_value_reader
15988 .seek(std::io::SeekFrom::Start(0))
15989 .unwrap();
15990
15991 let mut upload_url_from_server;
15992
15993 loop {
15994 let token = match self
15995 .hub
15996 .auth
15997 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15998 .await
15999 {
16000 Ok(token) => token,
16001 Err(e) => match dlg.token(e) {
16002 Ok(token) => token,
16003 Err(e) => {
16004 dlg.finished(false);
16005 return Err(common::Error::MissingToken(e));
16006 }
16007 },
16008 };
16009 request_value_reader
16010 .seek(std::io::SeekFrom::Start(0))
16011 .unwrap();
16012 let mut req_result = {
16013 let mut mp_reader: common::MultiPartReader = Default::default();
16014 let (mut body_reader, content_type) = match protocol {
16015 common::UploadProtocol::Simple => {
16016 mp_reader.reserve_exact(2);
16017 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
16018 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
16019 if size > 5497558138880 {
16020 return Err(common::Error::UploadSizeLimitExceeded(size, 5497558138880));
16021 }
16022 mp_reader
16023 .add_part(
16024 &mut request_value_reader,
16025 request_size,
16026 json_mime_type.clone(),
16027 )
16028 .add_part(&mut reader, size, reader_mime_type.clone());
16029 (
16030 &mut mp_reader as &mut (dyn std::io::Read + Send),
16031 common::MultiPartReader::mime_type(),
16032 )
16033 }
16034 _ => (
16035 &mut request_value_reader as &mut (dyn std::io::Read + Send),
16036 json_mime_type.clone(),
16037 ),
16038 };
16039 let client = &self.hub.client;
16040 dlg.pre_request();
16041 let mut req_builder = hyper::Request::builder()
16042 .method(hyper::Method::POST)
16043 .uri(url.as_str())
16044 .header(USER_AGENT, self.hub._user_agent.clone());
16045
16046 if let Some(token) = token.as_ref() {
16047 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16048 }
16049
16050 upload_url_from_server = true;
16051 if protocol == common::UploadProtocol::Resumable {
16052 req_builder = req_builder
16053 .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
16054 }
16055
16056 let mut body_reader_bytes = vec![];
16057 body_reader.read_to_end(&mut body_reader_bytes).unwrap();
16058 let request = req_builder
16059 .header(CONTENT_TYPE, content_type.to_string())
16060 .body(common::to_body(body_reader_bytes.into()));
16061
16062 client.request(request.unwrap()).await
16063 };
16064
16065 match req_result {
16066 Err(err) => {
16067 if let common::Retry::After(d) = dlg.http_error(&err) {
16068 sleep(d).await;
16069 continue;
16070 }
16071 dlg.finished(false);
16072 return Err(common::Error::HttpError(err));
16073 }
16074 Ok(res) => {
16075 let (mut parts, body) = res.into_parts();
16076 let mut body = common::Body::new(body);
16077 if !parts.status.is_success() {
16078 let bytes = common::to_bytes(body).await.unwrap_or_default();
16079 let error = serde_json::from_str(&common::to_string(&bytes));
16080 let response = common::to_response(parts, bytes.into());
16081
16082 if let common::Retry::After(d) =
16083 dlg.http_failure(&response, error.as_ref().ok())
16084 {
16085 sleep(d).await;
16086 continue;
16087 }
16088
16089 dlg.finished(false);
16090
16091 return Err(match error {
16092 Ok(value) => common::Error::BadRequest(value),
16093 _ => common::Error::Failure(response),
16094 });
16095 }
16096 if protocol == common::UploadProtocol::Resumable {
16097 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
16098 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
16099 if size > 5497558138880 {
16100 return Err(common::Error::UploadSizeLimitExceeded(size, 5497558138880));
16101 }
16102 let upload_result = {
16103 let url_str = &parts
16104 .headers
16105 .get("Location")
16106 .expect("LOCATION header is part of protocol")
16107 .to_str()
16108 .unwrap();
16109 if upload_url_from_server {
16110 dlg.store_upload_url(Some(url_str));
16111 }
16112
16113 common::ResumableUploadHelper {
16114 client: &self.hub.client,
16115 delegate: dlg,
16116 start_at: if upload_url_from_server {
16117 Some(0)
16118 } else {
16119 None
16120 },
16121 auth: &self.hub.auth,
16122 user_agent: &self.hub._user_agent,
16123 // TODO: Check this assumption
16124 auth_header: format!(
16125 "Bearer {}",
16126 token
16127 .ok_or_else(|| common::Error::MissingToken(
16128 "resumable upload requires token".into()
16129 ))?
16130 .as_str()
16131 ),
16132 url: url_str,
16133 reader: &mut reader,
16134 media_type: reader_mime_type.clone(),
16135 content_length: size,
16136 }
16137 .upload()
16138 .await
16139 };
16140 match upload_result {
16141 None => {
16142 dlg.finished(false);
16143 return Err(common::Error::Cancelled);
16144 }
16145 Some(Err(err)) => {
16146 dlg.finished(false);
16147 return Err(common::Error::HttpError(err));
16148 }
16149 Some(Ok(response)) => {
16150 (parts, body) = response.into_parts();
16151 if !parts.status.is_success() {
16152 dlg.store_upload_url(None);
16153 dlg.finished(false);
16154 return Err(common::Error::Failure(
16155 common::Response::from_parts(parts, body),
16156 ));
16157 }
16158 }
16159 }
16160 }
16161 let response = {
16162 let bytes = common::to_bytes(body).await.unwrap_or_default();
16163 let encoded = common::to_string(&bytes);
16164 match serde_json::from_str(&encoded) {
16165 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16166 Err(error) => {
16167 dlg.response_json_decode_error(&encoded, &error);
16168 return Err(common::Error::JsonDecodeError(
16169 encoded.to_string(),
16170 error,
16171 ));
16172 }
16173 }
16174 };
16175
16176 dlg.finished(true);
16177 return Ok(response);
16178 }
16179 }
16180 }
16181 }
16182
16183 /// Upload media in a resumable fashion.
16184 /// Even if the upload fails or is interrupted, it can be resumed for a
16185 /// certain amount of time as the server maintains state temporarily.
16186 ///
16187 /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
16188 /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
16189 /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
16190 /// `cancel_chunk_upload(...)`.
16191 ///
16192 /// * *multipart*: yes
16193 /// * *max size*: 5497558138880
16194 /// * *valid mime types*: '*/*'
16195 pub async fn upload_resumable<RS>(
16196 self,
16197 resumeable_stream: RS,
16198 mime_type: mime::Mime,
16199 ) -> common::Result<(common::Response, File)>
16200 where
16201 RS: common::ReadSeek,
16202 {
16203 self.doit(
16204 resumeable_stream,
16205 mime_type,
16206 common::UploadProtocol::Resumable,
16207 )
16208 .await
16209 }
16210 /// Upload media all at once.
16211 /// If the upload fails for whichever reason, all progress is lost.
16212 ///
16213 /// * *multipart*: yes
16214 /// * *max size*: 5497558138880
16215 /// * *valid mime types*: '*/*'
16216 pub async fn upload<RS>(
16217 self,
16218 stream: RS,
16219 mime_type: mime::Mime,
16220 ) -> common::Result<(common::Response, File)>
16221 where
16222 RS: common::ReadSeek,
16223 {
16224 self.doit(stream, mime_type, common::UploadProtocol::Simple)
16225 .await
16226 }
16227
16228 ///
16229 /// Sets the *request* property to the given value.
16230 ///
16231 /// Even though the property as already been set when instantiating this call,
16232 /// we provide this method for API completeness.
16233 pub fn request(mut self, new_value: File) -> FileInsertCall<'a, C> {
16234 self._request = new_value;
16235 self
16236 }
16237 /// The visibility of the new file. This parameter is only relevant when convert=false.
16238 ///
16239 /// Sets the *visibility* query property to the given value.
16240 pub fn visibility(mut self, new_value: &str) -> FileInsertCall<'a, C> {
16241 self._visibility = Some(new_value.to_string());
16242 self
16243 }
16244 /// Whether to use the content as indexable text.
16245 ///
16246 /// Sets the *use content as indexable text* query property to the given value.
16247 pub fn use_content_as_indexable_text(mut self, new_value: bool) -> FileInsertCall<'a, C> {
16248 self._use_content_as_indexable_text = Some(new_value);
16249 self
16250 }
16251 /// The timed text track name.
16252 ///
16253 /// Sets the *timed text track name* query property to the given value.
16254 pub fn timed_text_track_name(mut self, new_value: &str) -> FileInsertCall<'a, C> {
16255 self._timed_text_track_name = Some(new_value.to_string());
16256 self
16257 }
16258 /// The language of the timed text.
16259 ///
16260 /// Sets the *timed text language* query property to the given value.
16261 pub fn timed_text_language(mut self, new_value: &str) -> FileInsertCall<'a, C> {
16262 self._timed_text_language = Some(new_value.to_string());
16263 self
16264 }
16265 /// Deprecated: Use `supportsAllDrives` instead.
16266 ///
16267 /// Sets the *supports team drives* query property to the given value.
16268 pub fn supports_team_drives(mut self, new_value: bool) -> FileInsertCall<'a, C> {
16269 self._supports_team_drives = Some(new_value);
16270 self
16271 }
16272 /// Whether the requesting application supports both My Drives and shared drives.
16273 ///
16274 /// Sets the *supports all drives* query property to the given value.
16275 pub fn supports_all_drives(mut self, new_value: bool) -> FileInsertCall<'a, C> {
16276 self._supports_all_drives = Some(new_value);
16277 self
16278 }
16279 /// Whether to pin the head revision of the uploaded file. A file can have a maximum of 200 pinned revisions.
16280 ///
16281 /// Sets the *pinned* query property to the given value.
16282 pub fn pinned(mut self, new_value: bool) -> FileInsertCall<'a, C> {
16283 self._pinned = Some(new_value);
16284 self
16285 }
16286 /// If ocr is true, hints at the language to use. Valid values are BCP 47 codes.
16287 ///
16288 /// Sets the *ocr language* query property to the given value.
16289 pub fn ocr_language(mut self, new_value: &str) -> FileInsertCall<'a, C> {
16290 self._ocr_language = Some(new_value.to_string());
16291 self
16292 }
16293 /// Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads.
16294 ///
16295 /// Sets the *ocr* query property to the given value.
16296 pub fn ocr(mut self, new_value: bool) -> FileInsertCall<'a, C> {
16297 self._ocr = Some(new_value);
16298 self
16299 }
16300 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
16301 ///
16302 /// Sets the *include permissions for view* query property to the given value.
16303 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileInsertCall<'a, C> {
16304 self._include_permissions_for_view = Some(new_value.to_string());
16305 self
16306 }
16307 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
16308 ///
16309 /// Sets the *include labels* query property to the given value.
16310 pub fn include_labels(mut self, new_value: &str) -> FileInsertCall<'a, C> {
16311 self._include_labels = Some(new_value.to_string());
16312 self
16313 }
16314 /// Deprecated: Creating files in multiple folders is no longer supported.
16315 ///
16316 /// Sets the *enforce single parent* query property to the given value.
16317 pub fn enforce_single_parent(mut self, new_value: bool) -> FileInsertCall<'a, C> {
16318 self._enforce_single_parent = Some(new_value);
16319 self
16320 }
16321 /// Whether to convert this file to the corresponding Docs Editors format.
16322 ///
16323 /// Sets the *convert* query property to the given value.
16324 pub fn convert(mut self, new_value: bool) -> FileInsertCall<'a, C> {
16325 self._convert = Some(new_value);
16326 self
16327 }
16328 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16329 /// while executing the actual API request.
16330 ///
16331 /// ````text
16332 /// It should be used to handle progress information, and to implement a certain level of resilience.
16333 /// ````
16334 ///
16335 /// Sets the *delegate* property to the given value.
16336 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileInsertCall<'a, C> {
16337 self._delegate = Some(new_value);
16338 self
16339 }
16340
16341 /// Set any additional parameter of the query string used in the request.
16342 /// It should be used to set parameters which are not yet available through their own
16343 /// setters.
16344 ///
16345 /// Please note that this method must not be used to set any of the known parameters
16346 /// which have their own setter method. If done anyway, the request will fail.
16347 ///
16348 /// # Additional Parameters
16349 ///
16350 /// * *$.xgafv* (query-string) - V1 error format.
16351 /// * *access_token* (query-string) - OAuth access token.
16352 /// * *alt* (query-string) - Data format for response.
16353 /// * *callback* (query-string) - JSONP
16354 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16355 /// * *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.
16356 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16357 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16358 /// * *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.
16359 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16360 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16361 pub fn param<T>(mut self, name: T, value: T) -> FileInsertCall<'a, C>
16362 where
16363 T: AsRef<str>,
16364 {
16365 self._additional_params
16366 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16367 self
16368 }
16369
16370 /// Identifies the authorization scope for the method you are building.
16371 ///
16372 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16373 /// [`Scope::AppReadonly`].
16374 ///
16375 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16376 /// tokens for more than one scope.
16377 ///
16378 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16379 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16380 /// sufficient, a read-write scope will do as well.
16381 pub fn add_scope<St>(mut self, scope: St) -> FileInsertCall<'a, C>
16382 where
16383 St: AsRef<str>,
16384 {
16385 self._scopes.insert(String::from(scope.as_ref()));
16386 self
16387 }
16388 /// Identifies the authorization scope(s) for the method you are building.
16389 ///
16390 /// See [`Self::add_scope()`] for details.
16391 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileInsertCall<'a, C>
16392 where
16393 I: IntoIterator<Item = St>,
16394 St: AsRef<str>,
16395 {
16396 self._scopes
16397 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16398 self
16399 }
16400
16401 /// Removes all scopes, and no default scope will be used either.
16402 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16403 /// for details).
16404 pub fn clear_scopes(mut self) -> FileInsertCall<'a, C> {
16405 self._scopes.clear();
16406 self
16407 }
16408}
16409
16410/// Lists the user’s files. For more information, see [Search for files and folders](https://developers.google.com/workspace/drive/api/guides/search-files). This method accepts the `q` parameter, which is a search query combining one or more search terms. 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.
16411///
16412/// A builder for the *list* method supported by a *file* resource.
16413/// It is not used directly, but through a [`FileMethods`] instance.
16414///
16415/// # Example
16416///
16417/// Instantiate a resource method builder
16418///
16419/// ```test_harness,no_run
16420/// # extern crate hyper;
16421/// # extern crate hyper_rustls;
16422/// # extern crate google_drive2 as drive2;
16423/// # async fn dox() {
16424/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16425///
16426/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16427/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16428/// # .with_native_roots()
16429/// # .unwrap()
16430/// # .https_only()
16431/// # .enable_http2()
16432/// # .build();
16433///
16434/// # let executor = hyper_util::rt::TokioExecutor::new();
16435/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16436/// # secret,
16437/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16438/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16439/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16440/// # ),
16441/// # ).build().await.unwrap();
16442///
16443/// # let client = hyper_util::client::legacy::Client::builder(
16444/// # hyper_util::rt::TokioExecutor::new()
16445/// # )
16446/// # .build(
16447/// # hyper_rustls::HttpsConnectorBuilder::new()
16448/// # .with_native_roots()
16449/// # .unwrap()
16450/// # .https_or_http()
16451/// # .enable_http2()
16452/// # .build()
16453/// # );
16454/// # let mut hub = DriveHub::new(client, auth);
16455/// // You can configure optional parameters by calling the respective setters at will, and
16456/// // execute the final call using `doit()`.
16457/// // Values shown here are possibly random and not representative !
16458/// let result = hub.files().list()
16459/// .team_drive_id("dolores")
16460/// .supports_team_drives(true)
16461/// .supports_all_drives(true)
16462/// .spaces("dolor")
16463/// .q("aliquyam")
16464/// .projection("magna")
16465/// .page_token("diam")
16466/// .order_by("nonumy")
16467/// .max_results(-18)
16468/// .include_team_drive_items(true)
16469/// .include_permissions_for_view("sed")
16470/// .include_labels("est")
16471/// .include_items_from_all_drives(false)
16472/// .drive_id("diam")
16473/// .corpus("At")
16474/// .corpora("erat")
16475/// .doit().await;
16476/// # }
16477/// ```
16478pub struct FileListCall<'a, C>
16479where
16480 C: 'a,
16481{
16482 hub: &'a DriveHub<C>,
16483 _team_drive_id: Option<String>,
16484 _supports_team_drives: Option<bool>,
16485 _supports_all_drives: Option<bool>,
16486 _spaces: Option<String>,
16487 _q: Option<String>,
16488 _projection: Option<String>,
16489 _page_token: Option<String>,
16490 _order_by: Option<String>,
16491 _max_results: Option<i32>,
16492 _include_team_drive_items: Option<bool>,
16493 _include_permissions_for_view: Option<String>,
16494 _include_labels: Option<String>,
16495 _include_items_from_all_drives: Option<bool>,
16496 _drive_id: Option<String>,
16497 _corpus: Option<String>,
16498 _corpora: Option<String>,
16499 _delegate: Option<&'a mut dyn common::Delegate>,
16500 _additional_params: HashMap<String, String>,
16501 _scopes: BTreeSet<String>,
16502}
16503
16504impl<'a, C> common::CallBuilder for FileListCall<'a, C> {}
16505
16506impl<'a, C> FileListCall<'a, C>
16507where
16508 C: common::Connector,
16509{
16510 /// Perform the operation you have build so far.
16511 pub async fn doit(mut self) -> common::Result<(common::Response, FileList)> {
16512 use std::borrow::Cow;
16513 use std::io::{Read, Seek};
16514
16515 use common::{url::Params, ToParts};
16516 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16517
16518 let mut dd = common::DefaultDelegate;
16519 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16520 dlg.begin(common::MethodInfo {
16521 id: "drive.files.list",
16522 http_method: hyper::Method::GET,
16523 });
16524
16525 for &field in [
16526 "alt",
16527 "teamDriveId",
16528 "supportsTeamDrives",
16529 "supportsAllDrives",
16530 "spaces",
16531 "q",
16532 "projection",
16533 "pageToken",
16534 "orderBy",
16535 "maxResults",
16536 "includeTeamDriveItems",
16537 "includePermissionsForView",
16538 "includeLabels",
16539 "includeItemsFromAllDrives",
16540 "driveId",
16541 "corpus",
16542 "corpora",
16543 ]
16544 .iter()
16545 {
16546 if self._additional_params.contains_key(field) {
16547 dlg.finished(false);
16548 return Err(common::Error::FieldClash(field));
16549 }
16550 }
16551
16552 let mut params = Params::with_capacity(18 + self._additional_params.len());
16553 if let Some(value) = self._team_drive_id.as_ref() {
16554 params.push("teamDriveId", value);
16555 }
16556 if let Some(value) = self._supports_team_drives.as_ref() {
16557 params.push("supportsTeamDrives", value.to_string());
16558 }
16559 if let Some(value) = self._supports_all_drives.as_ref() {
16560 params.push("supportsAllDrives", value.to_string());
16561 }
16562 if let Some(value) = self._spaces.as_ref() {
16563 params.push("spaces", value);
16564 }
16565 if let Some(value) = self._q.as_ref() {
16566 params.push("q", value);
16567 }
16568 if let Some(value) = self._projection.as_ref() {
16569 params.push("projection", value);
16570 }
16571 if let Some(value) = self._page_token.as_ref() {
16572 params.push("pageToken", value);
16573 }
16574 if let Some(value) = self._order_by.as_ref() {
16575 params.push("orderBy", value);
16576 }
16577 if let Some(value) = self._max_results.as_ref() {
16578 params.push("maxResults", value.to_string());
16579 }
16580 if let Some(value) = self._include_team_drive_items.as_ref() {
16581 params.push("includeTeamDriveItems", value.to_string());
16582 }
16583 if let Some(value) = self._include_permissions_for_view.as_ref() {
16584 params.push("includePermissionsForView", value);
16585 }
16586 if let Some(value) = self._include_labels.as_ref() {
16587 params.push("includeLabels", value);
16588 }
16589 if let Some(value) = self._include_items_from_all_drives.as_ref() {
16590 params.push("includeItemsFromAllDrives", value.to_string());
16591 }
16592 if let Some(value) = self._drive_id.as_ref() {
16593 params.push("driveId", value);
16594 }
16595 if let Some(value) = self._corpus.as_ref() {
16596 params.push("corpus", value);
16597 }
16598 if let Some(value) = self._corpora.as_ref() {
16599 params.push("corpora", value);
16600 }
16601
16602 params.extend(self._additional_params.iter());
16603
16604 params.push("alt", "json");
16605 let mut url = self.hub._base_url.clone() + "files";
16606 if self._scopes.is_empty() {
16607 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
16608 }
16609
16610 let url = params.parse_with_url(&url);
16611
16612 loop {
16613 let token = match self
16614 .hub
16615 .auth
16616 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16617 .await
16618 {
16619 Ok(token) => token,
16620 Err(e) => match dlg.token(e) {
16621 Ok(token) => token,
16622 Err(e) => {
16623 dlg.finished(false);
16624 return Err(common::Error::MissingToken(e));
16625 }
16626 },
16627 };
16628 let mut req_result = {
16629 let client = &self.hub.client;
16630 dlg.pre_request();
16631 let mut req_builder = hyper::Request::builder()
16632 .method(hyper::Method::GET)
16633 .uri(url.as_str())
16634 .header(USER_AGENT, self.hub._user_agent.clone());
16635
16636 if let Some(token) = token.as_ref() {
16637 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16638 }
16639
16640 let request = req_builder
16641 .header(CONTENT_LENGTH, 0_u64)
16642 .body(common::to_body::<String>(None));
16643
16644 client.request(request.unwrap()).await
16645 };
16646
16647 match req_result {
16648 Err(err) => {
16649 if let common::Retry::After(d) = dlg.http_error(&err) {
16650 sleep(d).await;
16651 continue;
16652 }
16653 dlg.finished(false);
16654 return Err(common::Error::HttpError(err));
16655 }
16656 Ok(res) => {
16657 let (mut parts, body) = res.into_parts();
16658 let mut body = common::Body::new(body);
16659 if !parts.status.is_success() {
16660 let bytes = common::to_bytes(body).await.unwrap_or_default();
16661 let error = serde_json::from_str(&common::to_string(&bytes));
16662 let response = common::to_response(parts, bytes.into());
16663
16664 if let common::Retry::After(d) =
16665 dlg.http_failure(&response, error.as_ref().ok())
16666 {
16667 sleep(d).await;
16668 continue;
16669 }
16670
16671 dlg.finished(false);
16672
16673 return Err(match error {
16674 Ok(value) => common::Error::BadRequest(value),
16675 _ => common::Error::Failure(response),
16676 });
16677 }
16678 let response = {
16679 let bytes = common::to_bytes(body).await.unwrap_or_default();
16680 let encoded = common::to_string(&bytes);
16681 match serde_json::from_str(&encoded) {
16682 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16683 Err(error) => {
16684 dlg.response_json_decode_error(&encoded, &error);
16685 return Err(common::Error::JsonDecodeError(
16686 encoded.to_string(),
16687 error,
16688 ));
16689 }
16690 }
16691 };
16692
16693 dlg.finished(true);
16694 return Ok(response);
16695 }
16696 }
16697 }
16698 }
16699
16700 /// Deprecated: Use `driveId` instead.
16701 ///
16702 /// Sets the *team drive id* query property to the given value.
16703 pub fn team_drive_id(mut self, new_value: &str) -> FileListCall<'a, C> {
16704 self._team_drive_id = Some(new_value.to_string());
16705 self
16706 }
16707 /// Deprecated: Use `supportsAllDrives` instead.
16708 ///
16709 /// Sets the *supports team drives* query property to the given value.
16710 pub fn supports_team_drives(mut self, new_value: bool) -> FileListCall<'a, C> {
16711 self._supports_team_drives = Some(new_value);
16712 self
16713 }
16714 /// Whether the requesting application supports both My Drives and shared drives.
16715 ///
16716 /// Sets the *supports all drives* query property to the given value.
16717 pub fn supports_all_drives(mut self, new_value: bool) -> FileListCall<'a, C> {
16718 self._supports_all_drives = Some(new_value);
16719 self
16720 }
16721 /// A comma-separated list of spaces to query. Supported values are `drive`, and `appDataFolder`.
16722 ///
16723 /// Sets the *spaces* query property to the given value.
16724 pub fn spaces(mut self, new_value: &str) -> FileListCall<'a, C> {
16725 self._spaces = Some(new_value.to_string());
16726 self
16727 }
16728 /// Query string for searching files.
16729 ///
16730 /// Sets the *q* query property to the given value.
16731 pub fn q(mut self, new_value: &str) -> FileListCall<'a, C> {
16732 self._q = Some(new_value.to_string());
16733 self
16734 }
16735 /// Deprecated: This parameter has no function.
16736 ///
16737 /// Sets the *projection* query property to the given value.
16738 pub fn projection(mut self, new_value: &str) -> FileListCall<'a, C> {
16739 self._projection = Some(new_value.to_string());
16740 self
16741 }
16742 /// Page token for files.
16743 ///
16744 /// Sets the *page token* query property to the given value.
16745 pub fn page_token(mut self, new_value: &str) -> FileListCall<'a, C> {
16746 self._page_token = Some(new_value.to_string());
16747 self
16748 }
16749 /// A comma-separated list of sort keys. Valid keys are: * `createdDate`: When the file was created. * `folder`: The folder ID. This field is sorted using alphabetical ordering. * `lastViewedByMeDate`: The last time the file was viewed by the user. * `modifiedByMeDate`: The last time the file was modified by the user. * `modifiedDate`: The last time the file was modified by anyone. * `quotaBytesUsed`: The number of storage quota bytes used by the file. * `recency`: The most recent timestamp from the file's date-time fields. * `sharedWithMeDate`: When the file was shared with the user, if applicable. * `starred`: Whether the user has starred the file. * `title`: The title of the file. This field is sorted using alphabetical ordering, so 1, 12, 2, 22. * `title_natural`: The title of the file. This field is sorted using natural sort ordering, so 1, 2, 12, 22. Each key sorts ascending by default, but can be reversed with the 'desc' modifier. Example usage: `?orderBy=folder,modifiedDate desc,title`. Note that there's a current limitation for users with approximately one million files in which the requested sort order is ignored.
16750 ///
16751 /// Sets the *order by* query property to the given value.
16752 pub fn order_by(mut self, new_value: &str) -> FileListCall<'a, C> {
16753 self._order_by = Some(new_value.to_string());
16754 self
16755 }
16756 /// 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.
16757 ///
16758 /// Sets the *max results* query property to the given value.
16759 pub fn max_results(mut self, new_value: i32) -> FileListCall<'a, C> {
16760 self._max_results = Some(new_value);
16761 self
16762 }
16763 /// Deprecated: Use `includeItemsFromAllDrives` instead.
16764 ///
16765 /// Sets the *include team drive items* query property to the given value.
16766 pub fn include_team_drive_items(mut self, new_value: bool) -> FileListCall<'a, C> {
16767 self._include_team_drive_items = Some(new_value);
16768 self
16769 }
16770 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
16771 ///
16772 /// Sets the *include permissions for view* query property to the given value.
16773 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileListCall<'a, C> {
16774 self._include_permissions_for_view = Some(new_value.to_string());
16775 self
16776 }
16777 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
16778 ///
16779 /// Sets the *include labels* query property to the given value.
16780 pub fn include_labels(mut self, new_value: &str) -> FileListCall<'a, C> {
16781 self._include_labels = Some(new_value.to_string());
16782 self
16783 }
16784 /// Whether both My Drive and shared drive items should be included in results.
16785 ///
16786 /// Sets the *include items from all drives* query property to the given value.
16787 pub fn include_items_from_all_drives(mut self, new_value: bool) -> FileListCall<'a, C> {
16788 self._include_items_from_all_drives = Some(new_value);
16789 self
16790 }
16791 /// ID of the shared drive to search.
16792 ///
16793 /// Sets the *drive id* query property to the given value.
16794 pub fn drive_id(mut self, new_value: &str) -> FileListCall<'a, C> {
16795 self._drive_id = Some(new_value.to_string());
16796 self
16797 }
16798 /// Deprecated: The body of items (files/documents) to which the query applies. Use `corpora` instead.
16799 ///
16800 /// Sets the *corpus* query property to the given value.
16801 pub fn corpus(mut self, new_value: &str) -> FileListCall<'a, C> {
16802 self._corpus = Some(new_value.to_string());
16803 self
16804 }
16805 /// 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.
16806 ///
16807 /// Sets the *corpora* query property to the given value.
16808 pub fn corpora(mut self, new_value: &str) -> FileListCall<'a, C> {
16809 self._corpora = Some(new_value.to_string());
16810 self
16811 }
16812 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16813 /// while executing the actual API request.
16814 ///
16815 /// ````text
16816 /// It should be used to handle progress information, and to implement a certain level of resilience.
16817 /// ````
16818 ///
16819 /// Sets the *delegate* property to the given value.
16820 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileListCall<'a, C> {
16821 self._delegate = Some(new_value);
16822 self
16823 }
16824
16825 /// Set any additional parameter of the query string used in the request.
16826 /// It should be used to set parameters which are not yet available through their own
16827 /// setters.
16828 ///
16829 /// Please note that this method must not be used to set any of the known parameters
16830 /// which have their own setter method. If done anyway, the request will fail.
16831 ///
16832 /// # Additional Parameters
16833 ///
16834 /// * *$.xgafv* (query-string) - V1 error format.
16835 /// * *access_token* (query-string) - OAuth access token.
16836 /// * *alt* (query-string) - Data format for response.
16837 /// * *callback* (query-string) - JSONP
16838 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16839 /// * *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.
16840 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16841 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16842 /// * *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.
16843 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16844 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16845 pub fn param<T>(mut self, name: T, value: T) -> FileListCall<'a, C>
16846 where
16847 T: AsRef<str>,
16848 {
16849 self._additional_params
16850 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16851 self
16852 }
16853
16854 /// Identifies the authorization scope for the method you are building.
16855 ///
16856 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16857 /// [`Scope::AppReadonly`].
16858 ///
16859 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16860 /// tokens for more than one scope.
16861 ///
16862 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16863 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16864 /// sufficient, a read-write scope will do as well.
16865 pub fn add_scope<St>(mut self, scope: St) -> FileListCall<'a, C>
16866 where
16867 St: AsRef<str>,
16868 {
16869 self._scopes.insert(String::from(scope.as_ref()));
16870 self
16871 }
16872 /// Identifies the authorization scope(s) for the method you are building.
16873 ///
16874 /// See [`Self::add_scope()`] for details.
16875 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileListCall<'a, C>
16876 where
16877 I: IntoIterator<Item = St>,
16878 St: AsRef<str>,
16879 {
16880 self._scopes
16881 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16882 self
16883 }
16884
16885 /// Removes all scopes, and no default scope will be used either.
16886 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16887 /// for details).
16888 pub fn clear_scopes(mut self) -> FileListCall<'a, C> {
16889 self._scopes.clear();
16890 self
16891 }
16892}
16893
16894/// Lists the labels on a file.
16895///
16896/// A builder for the *listLabels* method supported by a *file* resource.
16897/// It is not used directly, but through a [`FileMethods`] instance.
16898///
16899/// # Example
16900///
16901/// Instantiate a resource method builder
16902///
16903/// ```test_harness,no_run
16904/// # extern crate hyper;
16905/// # extern crate hyper_rustls;
16906/// # extern crate google_drive2 as drive2;
16907/// # async fn dox() {
16908/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16909///
16910/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16911/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16912/// # .with_native_roots()
16913/// # .unwrap()
16914/// # .https_only()
16915/// # .enable_http2()
16916/// # .build();
16917///
16918/// # let executor = hyper_util::rt::TokioExecutor::new();
16919/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16920/// # secret,
16921/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16922/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16923/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16924/// # ),
16925/// # ).build().await.unwrap();
16926///
16927/// # let client = hyper_util::client::legacy::Client::builder(
16928/// # hyper_util::rt::TokioExecutor::new()
16929/// # )
16930/// # .build(
16931/// # hyper_rustls::HttpsConnectorBuilder::new()
16932/// # .with_native_roots()
16933/// # .unwrap()
16934/// # .https_or_http()
16935/// # .enable_http2()
16936/// # .build()
16937/// # );
16938/// # let mut hub = DriveHub::new(client, auth);
16939/// // You can configure optional parameters by calling the respective setters at will, and
16940/// // execute the final call using `doit()`.
16941/// // Values shown here are possibly random and not representative !
16942/// let result = hub.files().list_labels("fileId")
16943/// .page_token("ipsum")
16944/// .max_results(-73)
16945/// .doit().await;
16946/// # }
16947/// ```
16948pub struct FileListLabelCall<'a, C>
16949where
16950 C: 'a,
16951{
16952 hub: &'a DriveHub<C>,
16953 _file_id: String,
16954 _page_token: Option<String>,
16955 _max_results: Option<i32>,
16956 _delegate: Option<&'a mut dyn common::Delegate>,
16957 _additional_params: HashMap<String, String>,
16958 _scopes: BTreeSet<String>,
16959}
16960
16961impl<'a, C> common::CallBuilder for FileListLabelCall<'a, C> {}
16962
16963impl<'a, C> FileListLabelCall<'a, C>
16964where
16965 C: common::Connector,
16966{
16967 /// Perform the operation you have build so far.
16968 pub async fn doit(mut self) -> common::Result<(common::Response, LabelList)> {
16969 use std::borrow::Cow;
16970 use std::io::{Read, Seek};
16971
16972 use common::{url::Params, ToParts};
16973 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16974
16975 let mut dd = common::DefaultDelegate;
16976 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16977 dlg.begin(common::MethodInfo {
16978 id: "drive.files.listLabels",
16979 http_method: hyper::Method::GET,
16980 });
16981
16982 for &field in ["alt", "fileId", "pageToken", "maxResults"].iter() {
16983 if self._additional_params.contains_key(field) {
16984 dlg.finished(false);
16985 return Err(common::Error::FieldClash(field));
16986 }
16987 }
16988
16989 let mut params = Params::with_capacity(5 + self._additional_params.len());
16990 params.push("fileId", self._file_id);
16991 if let Some(value) = self._page_token.as_ref() {
16992 params.push("pageToken", value);
16993 }
16994 if let Some(value) = self._max_results.as_ref() {
16995 params.push("maxResults", value.to_string());
16996 }
16997
16998 params.extend(self._additional_params.iter());
16999
17000 params.push("alt", "json");
17001 let mut url = self.hub._base_url.clone() + "files/{fileId}/listLabels";
17002 if self._scopes.is_empty() {
17003 self._scopes
17004 .insert(Scope::MeetReadonly.as_ref().to_string());
17005 }
17006
17007 #[allow(clippy::single_element_loop)]
17008 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
17009 url = params.uri_replacement(url, param_name, find_this, false);
17010 }
17011 {
17012 let to_remove = ["fileId"];
17013 params.remove_params(&to_remove);
17014 }
17015
17016 let url = params.parse_with_url(&url);
17017
17018 loop {
17019 let token = match self
17020 .hub
17021 .auth
17022 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17023 .await
17024 {
17025 Ok(token) => token,
17026 Err(e) => match dlg.token(e) {
17027 Ok(token) => token,
17028 Err(e) => {
17029 dlg.finished(false);
17030 return Err(common::Error::MissingToken(e));
17031 }
17032 },
17033 };
17034 let mut req_result = {
17035 let client = &self.hub.client;
17036 dlg.pre_request();
17037 let mut req_builder = hyper::Request::builder()
17038 .method(hyper::Method::GET)
17039 .uri(url.as_str())
17040 .header(USER_AGENT, self.hub._user_agent.clone());
17041
17042 if let Some(token) = token.as_ref() {
17043 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17044 }
17045
17046 let request = req_builder
17047 .header(CONTENT_LENGTH, 0_u64)
17048 .body(common::to_body::<String>(None));
17049
17050 client.request(request.unwrap()).await
17051 };
17052
17053 match req_result {
17054 Err(err) => {
17055 if let common::Retry::After(d) = dlg.http_error(&err) {
17056 sleep(d).await;
17057 continue;
17058 }
17059 dlg.finished(false);
17060 return Err(common::Error::HttpError(err));
17061 }
17062 Ok(res) => {
17063 let (mut parts, body) = res.into_parts();
17064 let mut body = common::Body::new(body);
17065 if !parts.status.is_success() {
17066 let bytes = common::to_bytes(body).await.unwrap_or_default();
17067 let error = serde_json::from_str(&common::to_string(&bytes));
17068 let response = common::to_response(parts, bytes.into());
17069
17070 if let common::Retry::After(d) =
17071 dlg.http_failure(&response, error.as_ref().ok())
17072 {
17073 sleep(d).await;
17074 continue;
17075 }
17076
17077 dlg.finished(false);
17078
17079 return Err(match error {
17080 Ok(value) => common::Error::BadRequest(value),
17081 _ => common::Error::Failure(response),
17082 });
17083 }
17084 let response = {
17085 let bytes = common::to_bytes(body).await.unwrap_or_default();
17086 let encoded = common::to_string(&bytes);
17087 match serde_json::from_str(&encoded) {
17088 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17089 Err(error) => {
17090 dlg.response_json_decode_error(&encoded, &error);
17091 return Err(common::Error::JsonDecodeError(
17092 encoded.to_string(),
17093 error,
17094 ));
17095 }
17096 }
17097 };
17098
17099 dlg.finished(true);
17100 return Ok(response);
17101 }
17102 }
17103 }
17104 }
17105
17106 /// The ID for the file.
17107 ///
17108 /// Sets the *file id* path property to the given value.
17109 ///
17110 /// Even though the property as already been set when instantiating this call,
17111 /// we provide this method for API completeness.
17112 pub fn file_id(mut self, new_value: &str) -> FileListLabelCall<'a, C> {
17113 self._file_id = new_value.to_string();
17114 self
17115 }
17116 /// 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.
17117 ///
17118 /// Sets the *page token* query property to the given value.
17119 pub fn page_token(mut self, new_value: &str) -> FileListLabelCall<'a, C> {
17120 self._page_token = Some(new_value.to_string());
17121 self
17122 }
17123 /// The maximum number of labels to return per page. When not set, defaults to 100.
17124 ///
17125 /// Sets the *max results* query property to the given value.
17126 pub fn max_results(mut self, new_value: i32) -> FileListLabelCall<'a, C> {
17127 self._max_results = Some(new_value);
17128 self
17129 }
17130 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17131 /// while executing the actual API request.
17132 ///
17133 /// ````text
17134 /// It should be used to handle progress information, and to implement a certain level of resilience.
17135 /// ````
17136 ///
17137 /// Sets the *delegate* property to the given value.
17138 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileListLabelCall<'a, C> {
17139 self._delegate = Some(new_value);
17140 self
17141 }
17142
17143 /// Set any additional parameter of the query string used in the request.
17144 /// It should be used to set parameters which are not yet available through their own
17145 /// setters.
17146 ///
17147 /// Please note that this method must not be used to set any of the known parameters
17148 /// which have their own setter method. If done anyway, the request will fail.
17149 ///
17150 /// # Additional Parameters
17151 ///
17152 /// * *$.xgafv* (query-string) - V1 error format.
17153 /// * *access_token* (query-string) - OAuth access token.
17154 /// * *alt* (query-string) - Data format for response.
17155 /// * *callback* (query-string) - JSONP
17156 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17157 /// * *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.
17158 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17159 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17160 /// * *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.
17161 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17162 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17163 pub fn param<T>(mut self, name: T, value: T) -> FileListLabelCall<'a, C>
17164 where
17165 T: AsRef<str>,
17166 {
17167 self._additional_params
17168 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17169 self
17170 }
17171
17172 /// Identifies the authorization scope for the method you are building.
17173 ///
17174 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17175 /// [`Scope::MeetReadonly`].
17176 ///
17177 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17178 /// tokens for more than one scope.
17179 ///
17180 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17181 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17182 /// sufficient, a read-write scope will do as well.
17183 pub fn add_scope<St>(mut self, scope: St) -> FileListLabelCall<'a, C>
17184 where
17185 St: AsRef<str>,
17186 {
17187 self._scopes.insert(String::from(scope.as_ref()));
17188 self
17189 }
17190 /// Identifies the authorization scope(s) for the method you are building.
17191 ///
17192 /// See [`Self::add_scope()`] for details.
17193 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileListLabelCall<'a, C>
17194 where
17195 I: IntoIterator<Item = St>,
17196 St: AsRef<str>,
17197 {
17198 self._scopes
17199 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17200 self
17201 }
17202
17203 /// Removes all scopes, and no default scope will be used either.
17204 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17205 /// for details).
17206 pub fn clear_scopes(mut self) -> FileListLabelCall<'a, C> {
17207 self._scopes.clear();
17208 self
17209 }
17210}
17211
17212/// Modifies the set of labels applied to a file. Returns a list of the labels that were added or modified.
17213///
17214/// A builder for the *modifyLabels* method supported by a *file* resource.
17215/// It is not used directly, but through a [`FileMethods`] instance.
17216///
17217/// # Example
17218///
17219/// Instantiate a resource method builder
17220///
17221/// ```test_harness,no_run
17222/// # extern crate hyper;
17223/// # extern crate hyper_rustls;
17224/// # extern crate google_drive2 as drive2;
17225/// use drive2::api::ModifyLabelsRequest;
17226/// # async fn dox() {
17227/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17228///
17229/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17230/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17231/// # .with_native_roots()
17232/// # .unwrap()
17233/// # .https_only()
17234/// # .enable_http2()
17235/// # .build();
17236///
17237/// # let executor = hyper_util::rt::TokioExecutor::new();
17238/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17239/// # secret,
17240/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17241/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17242/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17243/// # ),
17244/// # ).build().await.unwrap();
17245///
17246/// # let client = hyper_util::client::legacy::Client::builder(
17247/// # hyper_util::rt::TokioExecutor::new()
17248/// # )
17249/// # .build(
17250/// # hyper_rustls::HttpsConnectorBuilder::new()
17251/// # .with_native_roots()
17252/// # .unwrap()
17253/// # .https_or_http()
17254/// # .enable_http2()
17255/// # .build()
17256/// # );
17257/// # let mut hub = DriveHub::new(client, auth);
17258/// // As the method needs a request, you would usually fill it with the desired information
17259/// // into the respective structure. Some of the parts shown here might not be applicable !
17260/// // Values shown here are possibly random and not representative !
17261/// let mut req = ModifyLabelsRequest::default();
17262///
17263/// // You can configure optional parameters by calling the respective setters at will, and
17264/// // execute the final call using `doit()`.
17265/// // Values shown here are possibly random and not representative !
17266/// let result = hub.files().modify_labels(req, "fileId")
17267/// .doit().await;
17268/// # }
17269/// ```
17270pub struct FileModifyLabelCall<'a, C>
17271where
17272 C: 'a,
17273{
17274 hub: &'a DriveHub<C>,
17275 _request: ModifyLabelsRequest,
17276 _file_id: String,
17277 _delegate: Option<&'a mut dyn common::Delegate>,
17278 _additional_params: HashMap<String, String>,
17279 _scopes: BTreeSet<String>,
17280}
17281
17282impl<'a, C> common::CallBuilder for FileModifyLabelCall<'a, C> {}
17283
17284impl<'a, C> FileModifyLabelCall<'a, C>
17285where
17286 C: common::Connector,
17287{
17288 /// Perform the operation you have build so far.
17289 pub async fn doit(mut self) -> common::Result<(common::Response, ModifyLabelsResponse)> {
17290 use std::borrow::Cow;
17291 use std::io::{Read, Seek};
17292
17293 use common::{url::Params, ToParts};
17294 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17295
17296 let mut dd = common::DefaultDelegate;
17297 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17298 dlg.begin(common::MethodInfo {
17299 id: "drive.files.modifyLabels",
17300 http_method: hyper::Method::POST,
17301 });
17302
17303 for &field in ["alt", "fileId"].iter() {
17304 if self._additional_params.contains_key(field) {
17305 dlg.finished(false);
17306 return Err(common::Error::FieldClash(field));
17307 }
17308 }
17309
17310 let mut params = Params::with_capacity(4 + self._additional_params.len());
17311 params.push("fileId", self._file_id);
17312
17313 params.extend(self._additional_params.iter());
17314
17315 params.push("alt", "json");
17316 let mut url = self.hub._base_url.clone() + "files/{fileId}/modifyLabels";
17317 if self._scopes.is_empty() {
17318 self._scopes.insert(Scope::Full.as_ref().to_string());
17319 }
17320
17321 #[allow(clippy::single_element_loop)]
17322 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
17323 url = params.uri_replacement(url, param_name, find_this, false);
17324 }
17325 {
17326 let to_remove = ["fileId"];
17327 params.remove_params(&to_remove);
17328 }
17329
17330 let url = params.parse_with_url(&url);
17331
17332 let mut json_mime_type = mime::APPLICATION_JSON;
17333 let mut request_value_reader = {
17334 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17335 common::remove_json_null_values(&mut value);
17336 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17337 serde_json::to_writer(&mut dst, &value).unwrap();
17338 dst
17339 };
17340 let request_size = request_value_reader
17341 .seek(std::io::SeekFrom::End(0))
17342 .unwrap();
17343 request_value_reader
17344 .seek(std::io::SeekFrom::Start(0))
17345 .unwrap();
17346
17347 loop {
17348 let token = match self
17349 .hub
17350 .auth
17351 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17352 .await
17353 {
17354 Ok(token) => token,
17355 Err(e) => match dlg.token(e) {
17356 Ok(token) => token,
17357 Err(e) => {
17358 dlg.finished(false);
17359 return Err(common::Error::MissingToken(e));
17360 }
17361 },
17362 };
17363 request_value_reader
17364 .seek(std::io::SeekFrom::Start(0))
17365 .unwrap();
17366 let mut req_result = {
17367 let client = &self.hub.client;
17368 dlg.pre_request();
17369 let mut req_builder = hyper::Request::builder()
17370 .method(hyper::Method::POST)
17371 .uri(url.as_str())
17372 .header(USER_AGENT, self.hub._user_agent.clone());
17373
17374 if let Some(token) = token.as_ref() {
17375 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17376 }
17377
17378 let request = req_builder
17379 .header(CONTENT_TYPE, json_mime_type.to_string())
17380 .header(CONTENT_LENGTH, request_size as u64)
17381 .body(common::to_body(
17382 request_value_reader.get_ref().clone().into(),
17383 ));
17384
17385 client.request(request.unwrap()).await
17386 };
17387
17388 match req_result {
17389 Err(err) => {
17390 if let common::Retry::After(d) = dlg.http_error(&err) {
17391 sleep(d).await;
17392 continue;
17393 }
17394 dlg.finished(false);
17395 return Err(common::Error::HttpError(err));
17396 }
17397 Ok(res) => {
17398 let (mut parts, body) = res.into_parts();
17399 let mut body = common::Body::new(body);
17400 if !parts.status.is_success() {
17401 let bytes = common::to_bytes(body).await.unwrap_or_default();
17402 let error = serde_json::from_str(&common::to_string(&bytes));
17403 let response = common::to_response(parts, bytes.into());
17404
17405 if let common::Retry::After(d) =
17406 dlg.http_failure(&response, error.as_ref().ok())
17407 {
17408 sleep(d).await;
17409 continue;
17410 }
17411
17412 dlg.finished(false);
17413
17414 return Err(match error {
17415 Ok(value) => common::Error::BadRequest(value),
17416 _ => common::Error::Failure(response),
17417 });
17418 }
17419 let response = {
17420 let bytes = common::to_bytes(body).await.unwrap_or_default();
17421 let encoded = common::to_string(&bytes);
17422 match serde_json::from_str(&encoded) {
17423 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17424 Err(error) => {
17425 dlg.response_json_decode_error(&encoded, &error);
17426 return Err(common::Error::JsonDecodeError(
17427 encoded.to_string(),
17428 error,
17429 ));
17430 }
17431 }
17432 };
17433
17434 dlg.finished(true);
17435 return Ok(response);
17436 }
17437 }
17438 }
17439 }
17440
17441 ///
17442 /// Sets the *request* property to the given value.
17443 ///
17444 /// Even though the property as already been set when instantiating this call,
17445 /// we provide this method for API completeness.
17446 pub fn request(mut self, new_value: ModifyLabelsRequest) -> FileModifyLabelCall<'a, C> {
17447 self._request = new_value;
17448 self
17449 }
17450 /// The ID of the file to which the labels belong.
17451 ///
17452 /// Sets the *file id* path property to the given value.
17453 ///
17454 /// Even though the property as already been set when instantiating this call,
17455 /// we provide this method for API completeness.
17456 pub fn file_id(mut self, new_value: &str) -> FileModifyLabelCall<'a, C> {
17457 self._file_id = new_value.to_string();
17458 self
17459 }
17460 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17461 /// while executing the actual API request.
17462 ///
17463 /// ````text
17464 /// It should be used to handle progress information, and to implement a certain level of resilience.
17465 /// ````
17466 ///
17467 /// Sets the *delegate* property to the given value.
17468 pub fn delegate(
17469 mut self,
17470 new_value: &'a mut dyn common::Delegate,
17471 ) -> FileModifyLabelCall<'a, C> {
17472 self._delegate = Some(new_value);
17473 self
17474 }
17475
17476 /// Set any additional parameter of the query string used in the request.
17477 /// It should be used to set parameters which are not yet available through their own
17478 /// setters.
17479 ///
17480 /// Please note that this method must not be used to set any of the known parameters
17481 /// which have their own setter method. If done anyway, the request will fail.
17482 ///
17483 /// # Additional Parameters
17484 ///
17485 /// * *$.xgafv* (query-string) - V1 error format.
17486 /// * *access_token* (query-string) - OAuth access token.
17487 /// * *alt* (query-string) - Data format for response.
17488 /// * *callback* (query-string) - JSONP
17489 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17490 /// * *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.
17491 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17492 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17493 /// * *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.
17494 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17495 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17496 pub fn param<T>(mut self, name: T, value: T) -> FileModifyLabelCall<'a, C>
17497 where
17498 T: AsRef<str>,
17499 {
17500 self._additional_params
17501 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17502 self
17503 }
17504
17505 /// Identifies the authorization scope for the method you are building.
17506 ///
17507 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17508 /// [`Scope::Full`].
17509 ///
17510 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17511 /// tokens for more than one scope.
17512 ///
17513 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17514 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17515 /// sufficient, a read-write scope will do as well.
17516 pub fn add_scope<St>(mut self, scope: St) -> FileModifyLabelCall<'a, C>
17517 where
17518 St: AsRef<str>,
17519 {
17520 self._scopes.insert(String::from(scope.as_ref()));
17521 self
17522 }
17523 /// Identifies the authorization scope(s) for the method you are building.
17524 ///
17525 /// See [`Self::add_scope()`] for details.
17526 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileModifyLabelCall<'a, C>
17527 where
17528 I: IntoIterator<Item = St>,
17529 St: AsRef<str>,
17530 {
17531 self._scopes
17532 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17533 self
17534 }
17535
17536 /// Removes all scopes, and no default scope will be used either.
17537 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17538 /// for details).
17539 pub fn clear_scopes(mut self) -> FileModifyLabelCall<'a, C> {
17540 self._scopes.clear();
17541 self
17542 }
17543}
17544
17545/// 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.
17546///
17547/// A builder for the *patch* method supported by a *file* resource.
17548/// It is not used directly, but through a [`FileMethods`] instance.
17549///
17550/// # Example
17551///
17552/// Instantiate a resource method builder
17553///
17554/// ```test_harness,no_run
17555/// # extern crate hyper;
17556/// # extern crate hyper_rustls;
17557/// # extern crate google_drive2 as drive2;
17558/// use drive2::api::File;
17559/// # async fn dox() {
17560/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17561///
17562/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17563/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17564/// # .with_native_roots()
17565/// # .unwrap()
17566/// # .https_only()
17567/// # .enable_http2()
17568/// # .build();
17569///
17570/// # let executor = hyper_util::rt::TokioExecutor::new();
17571/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17572/// # secret,
17573/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17574/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17575/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17576/// # ),
17577/// # ).build().await.unwrap();
17578///
17579/// # let client = hyper_util::client::legacy::Client::builder(
17580/// # hyper_util::rt::TokioExecutor::new()
17581/// # )
17582/// # .build(
17583/// # hyper_rustls::HttpsConnectorBuilder::new()
17584/// # .with_native_roots()
17585/// # .unwrap()
17586/// # .https_or_http()
17587/// # .enable_http2()
17588/// # .build()
17589/// # );
17590/// # let mut hub = DriveHub::new(client, auth);
17591/// // As the method needs a request, you would usually fill it with the desired information
17592/// // into the respective structure. Some of the parts shown here might not be applicable !
17593/// // Values shown here are possibly random and not representative !
17594/// let mut req = File::default();
17595///
17596/// // You can configure optional parameters by calling the respective setters at will, and
17597/// // execute the final call using `doit()`.
17598/// // Values shown here are possibly random and not representative !
17599/// let result = hub.files().patch(req, "fileId")
17600/// .use_content_as_indexable_text(true)
17601/// .update_viewed_date(true)
17602/// .timed_text_track_name("sea")
17603/// .timed_text_language("ipsum")
17604/// .supports_team_drives(true)
17605/// .supports_all_drives(true)
17606/// .set_modified_date(false)
17607/// .remove_parents("kasd")
17608/// .pinned(true)
17609/// .ocr_language("Lorem")
17610/// .ocr(false)
17611/// .new_revision(false)
17612/// .modified_date_behavior("nonumy")
17613/// .include_permissions_for_view("sea")
17614/// .include_labels("ipsum")
17615/// .enforce_single_parent(true)
17616/// .convert(false)
17617/// .add_parents("erat")
17618/// .doit().await;
17619/// # }
17620/// ```
17621pub struct FilePatchCall<'a, C>
17622where
17623 C: 'a,
17624{
17625 hub: &'a DriveHub<C>,
17626 _request: File,
17627 _file_id: String,
17628 _use_content_as_indexable_text: Option<bool>,
17629 _update_viewed_date: Option<bool>,
17630 _timed_text_track_name: Option<String>,
17631 _timed_text_language: Option<String>,
17632 _supports_team_drives: Option<bool>,
17633 _supports_all_drives: Option<bool>,
17634 _set_modified_date: Option<bool>,
17635 _remove_parents: Option<String>,
17636 _pinned: Option<bool>,
17637 _ocr_language: Option<String>,
17638 _ocr: Option<bool>,
17639 _new_revision: Option<bool>,
17640 _modified_date_behavior: Option<String>,
17641 _include_permissions_for_view: Option<String>,
17642 _include_labels: Option<String>,
17643 _enforce_single_parent: Option<bool>,
17644 _convert: Option<bool>,
17645 _add_parents: Option<String>,
17646 _delegate: Option<&'a mut dyn common::Delegate>,
17647 _additional_params: HashMap<String, String>,
17648 _scopes: BTreeSet<String>,
17649}
17650
17651impl<'a, C> common::CallBuilder for FilePatchCall<'a, C> {}
17652
17653impl<'a, C> FilePatchCall<'a, C>
17654where
17655 C: common::Connector,
17656{
17657 /// Perform the operation you have build so far.
17658 pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
17659 use std::borrow::Cow;
17660 use std::io::{Read, Seek};
17661
17662 use common::{url::Params, ToParts};
17663 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17664
17665 let mut dd = common::DefaultDelegate;
17666 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17667 dlg.begin(common::MethodInfo {
17668 id: "drive.files.patch",
17669 http_method: hyper::Method::PATCH,
17670 });
17671
17672 for &field in [
17673 "alt",
17674 "fileId",
17675 "useContentAsIndexableText",
17676 "updateViewedDate",
17677 "timedTextTrackName",
17678 "timedTextLanguage",
17679 "supportsTeamDrives",
17680 "supportsAllDrives",
17681 "setModifiedDate",
17682 "removeParents",
17683 "pinned",
17684 "ocrLanguage",
17685 "ocr",
17686 "newRevision",
17687 "modifiedDateBehavior",
17688 "includePermissionsForView",
17689 "includeLabels",
17690 "enforceSingleParent",
17691 "convert",
17692 "addParents",
17693 ]
17694 .iter()
17695 {
17696 if self._additional_params.contains_key(field) {
17697 dlg.finished(false);
17698 return Err(common::Error::FieldClash(field));
17699 }
17700 }
17701
17702 let mut params = Params::with_capacity(22 + self._additional_params.len());
17703 params.push("fileId", self._file_id);
17704 if let Some(value) = self._use_content_as_indexable_text.as_ref() {
17705 params.push("useContentAsIndexableText", value.to_string());
17706 }
17707 if let Some(value) = self._update_viewed_date.as_ref() {
17708 params.push("updateViewedDate", value.to_string());
17709 }
17710 if let Some(value) = self._timed_text_track_name.as_ref() {
17711 params.push("timedTextTrackName", value);
17712 }
17713 if let Some(value) = self._timed_text_language.as_ref() {
17714 params.push("timedTextLanguage", value);
17715 }
17716 if let Some(value) = self._supports_team_drives.as_ref() {
17717 params.push("supportsTeamDrives", value.to_string());
17718 }
17719 if let Some(value) = self._supports_all_drives.as_ref() {
17720 params.push("supportsAllDrives", value.to_string());
17721 }
17722 if let Some(value) = self._set_modified_date.as_ref() {
17723 params.push("setModifiedDate", value.to_string());
17724 }
17725 if let Some(value) = self._remove_parents.as_ref() {
17726 params.push("removeParents", value);
17727 }
17728 if let Some(value) = self._pinned.as_ref() {
17729 params.push("pinned", value.to_string());
17730 }
17731 if let Some(value) = self._ocr_language.as_ref() {
17732 params.push("ocrLanguage", value);
17733 }
17734 if let Some(value) = self._ocr.as_ref() {
17735 params.push("ocr", value.to_string());
17736 }
17737 if let Some(value) = self._new_revision.as_ref() {
17738 params.push("newRevision", value.to_string());
17739 }
17740 if let Some(value) = self._modified_date_behavior.as_ref() {
17741 params.push("modifiedDateBehavior", value);
17742 }
17743 if let Some(value) = self._include_permissions_for_view.as_ref() {
17744 params.push("includePermissionsForView", value);
17745 }
17746 if let Some(value) = self._include_labels.as_ref() {
17747 params.push("includeLabels", value);
17748 }
17749 if let Some(value) = self._enforce_single_parent.as_ref() {
17750 params.push("enforceSingleParent", value.to_string());
17751 }
17752 if let Some(value) = self._convert.as_ref() {
17753 params.push("convert", value.to_string());
17754 }
17755 if let Some(value) = self._add_parents.as_ref() {
17756 params.push("addParents", value);
17757 }
17758
17759 params.extend(self._additional_params.iter());
17760
17761 params.push("alt", "json");
17762 let mut url = self.hub._base_url.clone() + "files/{fileId}";
17763 if self._scopes.is_empty() {
17764 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
17765 }
17766
17767 #[allow(clippy::single_element_loop)]
17768 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
17769 url = params.uri_replacement(url, param_name, find_this, false);
17770 }
17771 {
17772 let to_remove = ["fileId"];
17773 params.remove_params(&to_remove);
17774 }
17775
17776 let url = params.parse_with_url(&url);
17777
17778 let mut json_mime_type = mime::APPLICATION_JSON;
17779 let mut request_value_reader = {
17780 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17781 common::remove_json_null_values(&mut value);
17782 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17783 serde_json::to_writer(&mut dst, &value).unwrap();
17784 dst
17785 };
17786 let request_size = request_value_reader
17787 .seek(std::io::SeekFrom::End(0))
17788 .unwrap();
17789 request_value_reader
17790 .seek(std::io::SeekFrom::Start(0))
17791 .unwrap();
17792
17793 loop {
17794 let token = match self
17795 .hub
17796 .auth
17797 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17798 .await
17799 {
17800 Ok(token) => token,
17801 Err(e) => match dlg.token(e) {
17802 Ok(token) => token,
17803 Err(e) => {
17804 dlg.finished(false);
17805 return Err(common::Error::MissingToken(e));
17806 }
17807 },
17808 };
17809 request_value_reader
17810 .seek(std::io::SeekFrom::Start(0))
17811 .unwrap();
17812 let mut req_result = {
17813 let client = &self.hub.client;
17814 dlg.pre_request();
17815 let mut req_builder = hyper::Request::builder()
17816 .method(hyper::Method::PATCH)
17817 .uri(url.as_str())
17818 .header(USER_AGENT, self.hub._user_agent.clone());
17819
17820 if let Some(token) = token.as_ref() {
17821 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17822 }
17823
17824 let request = req_builder
17825 .header(CONTENT_TYPE, json_mime_type.to_string())
17826 .header(CONTENT_LENGTH, request_size as u64)
17827 .body(common::to_body(
17828 request_value_reader.get_ref().clone().into(),
17829 ));
17830
17831 client.request(request.unwrap()).await
17832 };
17833
17834 match req_result {
17835 Err(err) => {
17836 if let common::Retry::After(d) = dlg.http_error(&err) {
17837 sleep(d).await;
17838 continue;
17839 }
17840 dlg.finished(false);
17841 return Err(common::Error::HttpError(err));
17842 }
17843 Ok(res) => {
17844 let (mut parts, body) = res.into_parts();
17845 let mut body = common::Body::new(body);
17846 if !parts.status.is_success() {
17847 let bytes = common::to_bytes(body).await.unwrap_or_default();
17848 let error = serde_json::from_str(&common::to_string(&bytes));
17849 let response = common::to_response(parts, bytes.into());
17850
17851 if let common::Retry::After(d) =
17852 dlg.http_failure(&response, error.as_ref().ok())
17853 {
17854 sleep(d).await;
17855 continue;
17856 }
17857
17858 dlg.finished(false);
17859
17860 return Err(match error {
17861 Ok(value) => common::Error::BadRequest(value),
17862 _ => common::Error::Failure(response),
17863 });
17864 }
17865 let response = {
17866 let bytes = common::to_bytes(body).await.unwrap_or_default();
17867 let encoded = common::to_string(&bytes);
17868 match serde_json::from_str(&encoded) {
17869 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17870 Err(error) => {
17871 dlg.response_json_decode_error(&encoded, &error);
17872 return Err(common::Error::JsonDecodeError(
17873 encoded.to_string(),
17874 error,
17875 ));
17876 }
17877 }
17878 };
17879
17880 dlg.finished(true);
17881 return Ok(response);
17882 }
17883 }
17884 }
17885 }
17886
17887 ///
17888 /// Sets the *request* property to the given value.
17889 ///
17890 /// Even though the property as already been set when instantiating this call,
17891 /// we provide this method for API completeness.
17892 pub fn request(mut self, new_value: File) -> FilePatchCall<'a, C> {
17893 self._request = new_value;
17894 self
17895 }
17896 /// The ID of the file to update.
17897 ///
17898 /// Sets the *file id* path property to the given value.
17899 ///
17900 /// Even though the property as already been set when instantiating this call,
17901 /// we provide this method for API completeness.
17902 pub fn file_id(mut self, new_value: &str) -> FilePatchCall<'a, C> {
17903 self._file_id = new_value.to_string();
17904 self
17905 }
17906 /// Whether to use the content as indexable text.
17907 ///
17908 /// Sets the *use content as indexable text* query property to the given value.
17909 pub fn use_content_as_indexable_text(mut self, new_value: bool) -> FilePatchCall<'a, C> {
17910 self._use_content_as_indexable_text = Some(new_value);
17911 self
17912 }
17913 /// Whether to update the view date after successfully updating the file.
17914 ///
17915 /// Sets the *update viewed date* query property to the given value.
17916 pub fn update_viewed_date(mut self, new_value: bool) -> FilePatchCall<'a, C> {
17917 self._update_viewed_date = Some(new_value);
17918 self
17919 }
17920 /// The timed text track name.
17921 ///
17922 /// Sets the *timed text track name* query property to the given value.
17923 pub fn timed_text_track_name(mut self, new_value: &str) -> FilePatchCall<'a, C> {
17924 self._timed_text_track_name = Some(new_value.to_string());
17925 self
17926 }
17927 /// The language of the timed text.
17928 ///
17929 /// Sets the *timed text language* query property to the given value.
17930 pub fn timed_text_language(mut self, new_value: &str) -> FilePatchCall<'a, C> {
17931 self._timed_text_language = Some(new_value.to_string());
17932 self
17933 }
17934 /// Deprecated: Use `supportsAllDrives` instead.
17935 ///
17936 /// Sets the *supports team drives* query property to the given value.
17937 pub fn supports_team_drives(mut self, new_value: bool) -> FilePatchCall<'a, C> {
17938 self._supports_team_drives = Some(new_value);
17939 self
17940 }
17941 /// Whether the requesting application supports both My Drives and shared drives.
17942 ///
17943 /// Sets the *supports all drives* query property to the given value.
17944 pub fn supports_all_drives(mut self, new_value: bool) -> FilePatchCall<'a, C> {
17945 self._supports_all_drives = Some(new_value);
17946 self
17947 }
17948 /// 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`.
17949 ///
17950 /// Sets the *set modified date* query property to the given value.
17951 pub fn set_modified_date(mut self, new_value: bool) -> FilePatchCall<'a, C> {
17952 self._set_modified_date = Some(new_value);
17953 self
17954 }
17955 /// Comma-separated list of parent IDs to remove.
17956 ///
17957 /// Sets the *remove parents* query property to the given value.
17958 pub fn remove_parents(mut self, new_value: &str) -> FilePatchCall<'a, C> {
17959 self._remove_parents = Some(new_value.to_string());
17960 self
17961 }
17962 /// 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.
17963 ///
17964 /// Sets the *pinned* query property to the given value.
17965 pub fn pinned(mut self, new_value: bool) -> FilePatchCall<'a, C> {
17966 self._pinned = Some(new_value);
17967 self
17968 }
17969 /// If ocr is true, hints at the language to use. Valid values are BCP 47 codes.
17970 ///
17971 /// Sets the *ocr language* query property to the given value.
17972 pub fn ocr_language(mut self, new_value: &str) -> FilePatchCall<'a, C> {
17973 self._ocr_language = Some(new_value.to_string());
17974 self
17975 }
17976 /// Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads.
17977 ///
17978 /// Sets the *ocr* query property to the given value.
17979 pub fn ocr(mut self, new_value: bool) -> FilePatchCall<'a, C> {
17980 self._ocr = Some(new_value);
17981 self
17982 }
17983 /// 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.
17984 ///
17985 /// Sets the *new revision* query property to the given value.
17986 pub fn new_revision(mut self, new_value: bool) -> FilePatchCall<'a, C> {
17987 self._new_revision = Some(new_value);
17988 self
17989 }
17990 /// Determines the behavior in which `modifiedDate` is updated. This overrides `setModifiedDate`.
17991 ///
17992 /// Sets the *modified date behavior* query property to the given value.
17993 pub fn modified_date_behavior(mut self, new_value: &str) -> FilePatchCall<'a, C> {
17994 self._modified_date_behavior = Some(new_value.to_string());
17995 self
17996 }
17997 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
17998 ///
17999 /// Sets the *include permissions for view* query property to the given value.
18000 pub fn include_permissions_for_view(mut self, new_value: &str) -> FilePatchCall<'a, C> {
18001 self._include_permissions_for_view = Some(new_value.to_string());
18002 self
18003 }
18004 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
18005 ///
18006 /// Sets the *include labels* query property to the given value.
18007 pub fn include_labels(mut self, new_value: &str) -> FilePatchCall<'a, C> {
18008 self._include_labels = Some(new_value.to_string());
18009 self
18010 }
18011 /// Deprecated: Adding files to multiple folders is no longer supported. Use `shortcuts` instead.
18012 ///
18013 /// Sets the *enforce single parent* query property to the given value.
18014 pub fn enforce_single_parent(mut self, new_value: bool) -> FilePatchCall<'a, C> {
18015 self._enforce_single_parent = Some(new_value);
18016 self
18017 }
18018 /// Deprecated: This parameter has no function.
18019 ///
18020 /// Sets the *convert* query property to the given value.
18021 pub fn convert(mut self, new_value: bool) -> FilePatchCall<'a, C> {
18022 self._convert = Some(new_value);
18023 self
18024 }
18025 /// Comma-separated list of parent IDs to add.
18026 ///
18027 /// Sets the *add parents* query property to the given value.
18028 pub fn add_parents(mut self, new_value: &str) -> FilePatchCall<'a, C> {
18029 self._add_parents = Some(new_value.to_string());
18030 self
18031 }
18032 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18033 /// while executing the actual API request.
18034 ///
18035 /// ````text
18036 /// It should be used to handle progress information, and to implement a certain level of resilience.
18037 /// ````
18038 ///
18039 /// Sets the *delegate* property to the given value.
18040 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FilePatchCall<'a, C> {
18041 self._delegate = Some(new_value);
18042 self
18043 }
18044
18045 /// Set any additional parameter of the query string used in the request.
18046 /// It should be used to set parameters which are not yet available through their own
18047 /// setters.
18048 ///
18049 /// Please note that this method must not be used to set any of the known parameters
18050 /// which have their own setter method. If done anyway, the request will fail.
18051 ///
18052 /// # Additional Parameters
18053 ///
18054 /// * *$.xgafv* (query-string) - V1 error format.
18055 /// * *access_token* (query-string) - OAuth access token.
18056 /// * *alt* (query-string) - Data format for response.
18057 /// * *callback* (query-string) - JSONP
18058 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18059 /// * *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.
18060 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18061 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18062 /// * *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.
18063 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18064 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18065 pub fn param<T>(mut self, name: T, value: T) -> FilePatchCall<'a, C>
18066 where
18067 T: AsRef<str>,
18068 {
18069 self._additional_params
18070 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18071 self
18072 }
18073
18074 /// Identifies the authorization scope for the method you are building.
18075 ///
18076 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18077 /// [`Scope::AppReadonly`].
18078 ///
18079 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18080 /// tokens for more than one scope.
18081 ///
18082 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18083 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18084 /// sufficient, a read-write scope will do as well.
18085 pub fn add_scope<St>(mut self, scope: St) -> FilePatchCall<'a, C>
18086 where
18087 St: AsRef<str>,
18088 {
18089 self._scopes.insert(String::from(scope.as_ref()));
18090 self
18091 }
18092 /// Identifies the authorization scope(s) for the method you are building.
18093 ///
18094 /// See [`Self::add_scope()`] for details.
18095 pub fn add_scopes<I, St>(mut self, scopes: I) -> FilePatchCall<'a, C>
18096 where
18097 I: IntoIterator<Item = St>,
18098 St: AsRef<str>,
18099 {
18100 self._scopes
18101 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18102 self
18103 }
18104
18105 /// Removes all scopes, and no default scope will be used either.
18106 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18107 /// for details).
18108 pub fn clear_scopes(mut self) -> FilePatchCall<'a, C> {
18109 self._scopes.clear();
18110 self
18111 }
18112}
18113
18114/// Set the file's updated time to the current server time.
18115///
18116/// A builder for the *touch* method supported by a *file* resource.
18117/// It is not used directly, but through a [`FileMethods`] instance.
18118///
18119/// # Example
18120///
18121/// Instantiate a resource method builder
18122///
18123/// ```test_harness,no_run
18124/// # extern crate hyper;
18125/// # extern crate hyper_rustls;
18126/// # extern crate google_drive2 as drive2;
18127/// # async fn dox() {
18128/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18129///
18130/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18131/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18132/// # .with_native_roots()
18133/// # .unwrap()
18134/// # .https_only()
18135/// # .enable_http2()
18136/// # .build();
18137///
18138/// # let executor = hyper_util::rt::TokioExecutor::new();
18139/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18140/// # secret,
18141/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18142/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18143/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18144/// # ),
18145/// # ).build().await.unwrap();
18146///
18147/// # let client = hyper_util::client::legacy::Client::builder(
18148/// # hyper_util::rt::TokioExecutor::new()
18149/// # )
18150/// # .build(
18151/// # hyper_rustls::HttpsConnectorBuilder::new()
18152/// # .with_native_roots()
18153/// # .unwrap()
18154/// # .https_or_http()
18155/// # .enable_http2()
18156/// # .build()
18157/// # );
18158/// # let mut hub = DriveHub::new(client, auth);
18159/// // You can configure optional parameters by calling the respective setters at will, and
18160/// // execute the final call using `doit()`.
18161/// // Values shown here are possibly random and not representative !
18162/// let result = hub.files().touch("fileId")
18163/// .supports_team_drives(false)
18164/// .supports_all_drives(false)
18165/// .include_permissions_for_view("nonumy")
18166/// .include_labels("erat")
18167/// .doit().await;
18168/// # }
18169/// ```
18170pub struct FileTouchCall<'a, C>
18171where
18172 C: 'a,
18173{
18174 hub: &'a DriveHub<C>,
18175 _file_id: String,
18176 _supports_team_drives: Option<bool>,
18177 _supports_all_drives: Option<bool>,
18178 _include_permissions_for_view: Option<String>,
18179 _include_labels: Option<String>,
18180 _delegate: Option<&'a mut dyn common::Delegate>,
18181 _additional_params: HashMap<String, String>,
18182 _scopes: BTreeSet<String>,
18183}
18184
18185impl<'a, C> common::CallBuilder for FileTouchCall<'a, C> {}
18186
18187impl<'a, C> FileTouchCall<'a, C>
18188where
18189 C: common::Connector,
18190{
18191 /// Perform the operation you have build so far.
18192 pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
18193 use std::borrow::Cow;
18194 use std::io::{Read, Seek};
18195
18196 use common::{url::Params, ToParts};
18197 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18198
18199 let mut dd = common::DefaultDelegate;
18200 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18201 dlg.begin(common::MethodInfo {
18202 id: "drive.files.touch",
18203 http_method: hyper::Method::POST,
18204 });
18205
18206 for &field in [
18207 "alt",
18208 "fileId",
18209 "supportsTeamDrives",
18210 "supportsAllDrives",
18211 "includePermissionsForView",
18212 "includeLabels",
18213 ]
18214 .iter()
18215 {
18216 if self._additional_params.contains_key(field) {
18217 dlg.finished(false);
18218 return Err(common::Error::FieldClash(field));
18219 }
18220 }
18221
18222 let mut params = Params::with_capacity(7 + self._additional_params.len());
18223 params.push("fileId", self._file_id);
18224 if let Some(value) = self._supports_team_drives.as_ref() {
18225 params.push("supportsTeamDrives", value.to_string());
18226 }
18227 if let Some(value) = self._supports_all_drives.as_ref() {
18228 params.push("supportsAllDrives", value.to_string());
18229 }
18230 if let Some(value) = self._include_permissions_for_view.as_ref() {
18231 params.push("includePermissionsForView", value);
18232 }
18233 if let Some(value) = self._include_labels.as_ref() {
18234 params.push("includeLabels", value);
18235 }
18236
18237 params.extend(self._additional_params.iter());
18238
18239 params.push("alt", "json");
18240 let mut url = self.hub._base_url.clone() + "files/{fileId}/touch";
18241 if self._scopes.is_empty() {
18242 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
18243 }
18244
18245 #[allow(clippy::single_element_loop)]
18246 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
18247 url = params.uri_replacement(url, param_name, find_this, false);
18248 }
18249 {
18250 let to_remove = ["fileId"];
18251 params.remove_params(&to_remove);
18252 }
18253
18254 let url = params.parse_with_url(&url);
18255
18256 loop {
18257 let token = match self
18258 .hub
18259 .auth
18260 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18261 .await
18262 {
18263 Ok(token) => token,
18264 Err(e) => match dlg.token(e) {
18265 Ok(token) => token,
18266 Err(e) => {
18267 dlg.finished(false);
18268 return Err(common::Error::MissingToken(e));
18269 }
18270 },
18271 };
18272 let mut req_result = {
18273 let client = &self.hub.client;
18274 dlg.pre_request();
18275 let mut req_builder = hyper::Request::builder()
18276 .method(hyper::Method::POST)
18277 .uri(url.as_str())
18278 .header(USER_AGENT, self.hub._user_agent.clone());
18279
18280 if let Some(token) = token.as_ref() {
18281 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18282 }
18283
18284 let request = req_builder
18285 .header(CONTENT_LENGTH, 0_u64)
18286 .body(common::to_body::<String>(None));
18287
18288 client.request(request.unwrap()).await
18289 };
18290
18291 match req_result {
18292 Err(err) => {
18293 if let common::Retry::After(d) = dlg.http_error(&err) {
18294 sleep(d).await;
18295 continue;
18296 }
18297 dlg.finished(false);
18298 return Err(common::Error::HttpError(err));
18299 }
18300 Ok(res) => {
18301 let (mut parts, body) = res.into_parts();
18302 let mut body = common::Body::new(body);
18303 if !parts.status.is_success() {
18304 let bytes = common::to_bytes(body).await.unwrap_or_default();
18305 let error = serde_json::from_str(&common::to_string(&bytes));
18306 let response = common::to_response(parts, bytes.into());
18307
18308 if let common::Retry::After(d) =
18309 dlg.http_failure(&response, error.as_ref().ok())
18310 {
18311 sleep(d).await;
18312 continue;
18313 }
18314
18315 dlg.finished(false);
18316
18317 return Err(match error {
18318 Ok(value) => common::Error::BadRequest(value),
18319 _ => common::Error::Failure(response),
18320 });
18321 }
18322 let response = {
18323 let bytes = common::to_bytes(body).await.unwrap_or_default();
18324 let encoded = common::to_string(&bytes);
18325 match serde_json::from_str(&encoded) {
18326 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18327 Err(error) => {
18328 dlg.response_json_decode_error(&encoded, &error);
18329 return Err(common::Error::JsonDecodeError(
18330 encoded.to_string(),
18331 error,
18332 ));
18333 }
18334 }
18335 };
18336
18337 dlg.finished(true);
18338 return Ok(response);
18339 }
18340 }
18341 }
18342 }
18343
18344 /// The ID of the file to update.
18345 ///
18346 /// Sets the *file id* path property to the given value.
18347 ///
18348 /// Even though the property as already been set when instantiating this call,
18349 /// we provide this method for API completeness.
18350 pub fn file_id(mut self, new_value: &str) -> FileTouchCall<'a, C> {
18351 self._file_id = new_value.to_string();
18352 self
18353 }
18354 /// Deprecated: Use `supportsAllDrives` instead.
18355 ///
18356 /// Sets the *supports team drives* query property to the given value.
18357 pub fn supports_team_drives(mut self, new_value: bool) -> FileTouchCall<'a, C> {
18358 self._supports_team_drives = Some(new_value);
18359 self
18360 }
18361 /// Whether the requesting application supports both My Drives and shared drives.
18362 ///
18363 /// Sets the *supports all drives* query property to the given value.
18364 pub fn supports_all_drives(mut self, new_value: bool) -> FileTouchCall<'a, C> {
18365 self._supports_all_drives = Some(new_value);
18366 self
18367 }
18368 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
18369 ///
18370 /// Sets the *include permissions for view* query property to the given value.
18371 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileTouchCall<'a, C> {
18372 self._include_permissions_for_view = Some(new_value.to_string());
18373 self
18374 }
18375 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
18376 ///
18377 /// Sets the *include labels* query property to the given value.
18378 pub fn include_labels(mut self, new_value: &str) -> FileTouchCall<'a, C> {
18379 self._include_labels = Some(new_value.to_string());
18380 self
18381 }
18382 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18383 /// while executing the actual API request.
18384 ///
18385 /// ````text
18386 /// It should be used to handle progress information, and to implement a certain level of resilience.
18387 /// ````
18388 ///
18389 /// Sets the *delegate* property to the given value.
18390 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileTouchCall<'a, C> {
18391 self._delegate = Some(new_value);
18392 self
18393 }
18394
18395 /// Set any additional parameter of the query string used in the request.
18396 /// It should be used to set parameters which are not yet available through their own
18397 /// setters.
18398 ///
18399 /// Please note that this method must not be used to set any of the known parameters
18400 /// which have their own setter method. If done anyway, the request will fail.
18401 ///
18402 /// # Additional Parameters
18403 ///
18404 /// * *$.xgafv* (query-string) - V1 error format.
18405 /// * *access_token* (query-string) - OAuth access token.
18406 /// * *alt* (query-string) - Data format for response.
18407 /// * *callback* (query-string) - JSONP
18408 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18409 /// * *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.
18410 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18411 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18412 /// * *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.
18413 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18414 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18415 pub fn param<T>(mut self, name: T, value: T) -> FileTouchCall<'a, C>
18416 where
18417 T: AsRef<str>,
18418 {
18419 self._additional_params
18420 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18421 self
18422 }
18423
18424 /// Identifies the authorization scope for the method you are building.
18425 ///
18426 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18427 /// [`Scope::AppReadonly`].
18428 ///
18429 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18430 /// tokens for more than one scope.
18431 ///
18432 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18433 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18434 /// sufficient, a read-write scope will do as well.
18435 pub fn add_scope<St>(mut self, scope: St) -> FileTouchCall<'a, C>
18436 where
18437 St: AsRef<str>,
18438 {
18439 self._scopes.insert(String::from(scope.as_ref()));
18440 self
18441 }
18442 /// Identifies the authorization scope(s) for the method you are building.
18443 ///
18444 /// See [`Self::add_scope()`] for details.
18445 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileTouchCall<'a, C>
18446 where
18447 I: IntoIterator<Item = St>,
18448 St: AsRef<str>,
18449 {
18450 self._scopes
18451 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18452 self
18453 }
18454
18455 /// Removes all scopes, and no default scope will be used either.
18456 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18457 /// for details).
18458 pub fn clear_scopes(mut self) -> FileTouchCall<'a, C> {
18459 self._scopes.clear();
18460 self
18461 }
18462}
18463
18464/// 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.
18465///
18466/// A builder for the *trash* method supported by a *file* resource.
18467/// It is not used directly, but through a [`FileMethods`] instance.
18468///
18469/// # Example
18470///
18471/// Instantiate a resource method builder
18472///
18473/// ```test_harness,no_run
18474/// # extern crate hyper;
18475/// # extern crate hyper_rustls;
18476/// # extern crate google_drive2 as drive2;
18477/// # async fn dox() {
18478/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18479///
18480/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18481/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18482/// # .with_native_roots()
18483/// # .unwrap()
18484/// # .https_only()
18485/// # .enable_http2()
18486/// # .build();
18487///
18488/// # let executor = hyper_util::rt::TokioExecutor::new();
18489/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18490/// # secret,
18491/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18492/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18493/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18494/// # ),
18495/// # ).build().await.unwrap();
18496///
18497/// # let client = hyper_util::client::legacy::Client::builder(
18498/// # hyper_util::rt::TokioExecutor::new()
18499/// # )
18500/// # .build(
18501/// # hyper_rustls::HttpsConnectorBuilder::new()
18502/// # .with_native_roots()
18503/// # .unwrap()
18504/// # .https_or_http()
18505/// # .enable_http2()
18506/// # .build()
18507/// # );
18508/// # let mut hub = DriveHub::new(client, auth);
18509/// // You can configure optional parameters by calling the respective setters at will, and
18510/// // execute the final call using `doit()`.
18511/// // Values shown here are possibly random and not representative !
18512/// let result = hub.files().trash("fileId")
18513/// .supports_team_drives(true)
18514/// .supports_all_drives(false)
18515/// .include_permissions_for_view("elitr")
18516/// .include_labels("consetetur")
18517/// .doit().await;
18518/// # }
18519/// ```
18520pub struct FileTrashCall<'a, C>
18521where
18522 C: 'a,
18523{
18524 hub: &'a DriveHub<C>,
18525 _file_id: String,
18526 _supports_team_drives: Option<bool>,
18527 _supports_all_drives: Option<bool>,
18528 _include_permissions_for_view: Option<String>,
18529 _include_labels: Option<String>,
18530 _delegate: Option<&'a mut dyn common::Delegate>,
18531 _additional_params: HashMap<String, String>,
18532 _scopes: BTreeSet<String>,
18533}
18534
18535impl<'a, C> common::CallBuilder for FileTrashCall<'a, C> {}
18536
18537impl<'a, C> FileTrashCall<'a, C>
18538where
18539 C: common::Connector,
18540{
18541 /// Perform the operation you have build so far.
18542 pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
18543 use std::borrow::Cow;
18544 use std::io::{Read, Seek};
18545
18546 use common::{url::Params, ToParts};
18547 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18548
18549 let mut dd = common::DefaultDelegate;
18550 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18551 dlg.begin(common::MethodInfo {
18552 id: "drive.files.trash",
18553 http_method: hyper::Method::POST,
18554 });
18555
18556 for &field in [
18557 "alt",
18558 "fileId",
18559 "supportsTeamDrives",
18560 "supportsAllDrives",
18561 "includePermissionsForView",
18562 "includeLabels",
18563 ]
18564 .iter()
18565 {
18566 if self._additional_params.contains_key(field) {
18567 dlg.finished(false);
18568 return Err(common::Error::FieldClash(field));
18569 }
18570 }
18571
18572 let mut params = Params::with_capacity(7 + self._additional_params.len());
18573 params.push("fileId", self._file_id);
18574 if let Some(value) = self._supports_team_drives.as_ref() {
18575 params.push("supportsTeamDrives", value.to_string());
18576 }
18577 if let Some(value) = self._supports_all_drives.as_ref() {
18578 params.push("supportsAllDrives", value.to_string());
18579 }
18580 if let Some(value) = self._include_permissions_for_view.as_ref() {
18581 params.push("includePermissionsForView", value);
18582 }
18583 if let Some(value) = self._include_labels.as_ref() {
18584 params.push("includeLabels", value);
18585 }
18586
18587 params.extend(self._additional_params.iter());
18588
18589 params.push("alt", "json");
18590 let mut url = self.hub._base_url.clone() + "files/{fileId}/trash";
18591 if self._scopes.is_empty() {
18592 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
18593 }
18594
18595 #[allow(clippy::single_element_loop)]
18596 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
18597 url = params.uri_replacement(url, param_name, find_this, false);
18598 }
18599 {
18600 let to_remove = ["fileId"];
18601 params.remove_params(&to_remove);
18602 }
18603
18604 let url = params.parse_with_url(&url);
18605
18606 loop {
18607 let token = match self
18608 .hub
18609 .auth
18610 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18611 .await
18612 {
18613 Ok(token) => token,
18614 Err(e) => match dlg.token(e) {
18615 Ok(token) => token,
18616 Err(e) => {
18617 dlg.finished(false);
18618 return Err(common::Error::MissingToken(e));
18619 }
18620 },
18621 };
18622 let mut req_result = {
18623 let client = &self.hub.client;
18624 dlg.pre_request();
18625 let mut req_builder = hyper::Request::builder()
18626 .method(hyper::Method::POST)
18627 .uri(url.as_str())
18628 .header(USER_AGENT, self.hub._user_agent.clone());
18629
18630 if let Some(token) = token.as_ref() {
18631 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18632 }
18633
18634 let request = req_builder
18635 .header(CONTENT_LENGTH, 0_u64)
18636 .body(common::to_body::<String>(None));
18637
18638 client.request(request.unwrap()).await
18639 };
18640
18641 match req_result {
18642 Err(err) => {
18643 if let common::Retry::After(d) = dlg.http_error(&err) {
18644 sleep(d).await;
18645 continue;
18646 }
18647 dlg.finished(false);
18648 return Err(common::Error::HttpError(err));
18649 }
18650 Ok(res) => {
18651 let (mut parts, body) = res.into_parts();
18652 let mut body = common::Body::new(body);
18653 if !parts.status.is_success() {
18654 let bytes = common::to_bytes(body).await.unwrap_or_default();
18655 let error = serde_json::from_str(&common::to_string(&bytes));
18656 let response = common::to_response(parts, bytes.into());
18657
18658 if let common::Retry::After(d) =
18659 dlg.http_failure(&response, error.as_ref().ok())
18660 {
18661 sleep(d).await;
18662 continue;
18663 }
18664
18665 dlg.finished(false);
18666
18667 return Err(match error {
18668 Ok(value) => common::Error::BadRequest(value),
18669 _ => common::Error::Failure(response),
18670 });
18671 }
18672 let response = {
18673 let bytes = common::to_bytes(body).await.unwrap_or_default();
18674 let encoded = common::to_string(&bytes);
18675 match serde_json::from_str(&encoded) {
18676 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18677 Err(error) => {
18678 dlg.response_json_decode_error(&encoded, &error);
18679 return Err(common::Error::JsonDecodeError(
18680 encoded.to_string(),
18681 error,
18682 ));
18683 }
18684 }
18685 };
18686
18687 dlg.finished(true);
18688 return Ok(response);
18689 }
18690 }
18691 }
18692 }
18693
18694 /// The ID of the file to trash.
18695 ///
18696 /// Sets the *file id* path property to the given value.
18697 ///
18698 /// Even though the property as already been set when instantiating this call,
18699 /// we provide this method for API completeness.
18700 pub fn file_id(mut self, new_value: &str) -> FileTrashCall<'a, C> {
18701 self._file_id = new_value.to_string();
18702 self
18703 }
18704 /// Deprecated: Use `supportsAllDrives` instead.
18705 ///
18706 /// Sets the *supports team drives* query property to the given value.
18707 pub fn supports_team_drives(mut self, new_value: bool) -> FileTrashCall<'a, C> {
18708 self._supports_team_drives = Some(new_value);
18709 self
18710 }
18711 /// Whether the requesting application supports both My Drives and shared drives.
18712 ///
18713 /// Sets the *supports all drives* query property to the given value.
18714 pub fn supports_all_drives(mut self, new_value: bool) -> FileTrashCall<'a, C> {
18715 self._supports_all_drives = Some(new_value);
18716 self
18717 }
18718 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
18719 ///
18720 /// Sets the *include permissions for view* query property to the given value.
18721 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileTrashCall<'a, C> {
18722 self._include_permissions_for_view = Some(new_value.to_string());
18723 self
18724 }
18725 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
18726 ///
18727 /// Sets the *include labels* query property to the given value.
18728 pub fn include_labels(mut self, new_value: &str) -> FileTrashCall<'a, C> {
18729 self._include_labels = Some(new_value.to_string());
18730 self
18731 }
18732 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18733 /// while executing the actual API request.
18734 ///
18735 /// ````text
18736 /// It should be used to handle progress information, and to implement a certain level of resilience.
18737 /// ````
18738 ///
18739 /// Sets the *delegate* property to the given value.
18740 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileTrashCall<'a, C> {
18741 self._delegate = Some(new_value);
18742 self
18743 }
18744
18745 /// Set any additional parameter of the query string used in the request.
18746 /// It should be used to set parameters which are not yet available through their own
18747 /// setters.
18748 ///
18749 /// Please note that this method must not be used to set any of the known parameters
18750 /// which have their own setter method. If done anyway, the request will fail.
18751 ///
18752 /// # Additional Parameters
18753 ///
18754 /// * *$.xgafv* (query-string) - V1 error format.
18755 /// * *access_token* (query-string) - OAuth access token.
18756 /// * *alt* (query-string) - Data format for response.
18757 /// * *callback* (query-string) - JSONP
18758 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18759 /// * *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.
18760 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18761 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18762 /// * *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.
18763 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18764 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18765 pub fn param<T>(mut self, name: T, value: T) -> FileTrashCall<'a, C>
18766 where
18767 T: AsRef<str>,
18768 {
18769 self._additional_params
18770 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18771 self
18772 }
18773
18774 /// Identifies the authorization scope for the method you are building.
18775 ///
18776 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18777 /// [`Scope::AppReadonly`].
18778 ///
18779 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18780 /// tokens for more than one scope.
18781 ///
18782 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18783 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18784 /// sufficient, a read-write scope will do as well.
18785 pub fn add_scope<St>(mut self, scope: St) -> FileTrashCall<'a, C>
18786 where
18787 St: AsRef<str>,
18788 {
18789 self._scopes.insert(String::from(scope.as_ref()));
18790 self
18791 }
18792 /// Identifies the authorization scope(s) for the method you are building.
18793 ///
18794 /// See [`Self::add_scope()`] for details.
18795 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileTrashCall<'a, C>
18796 where
18797 I: IntoIterator<Item = St>,
18798 St: AsRef<str>,
18799 {
18800 self._scopes
18801 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18802 self
18803 }
18804
18805 /// Removes all scopes, and no default scope will be used either.
18806 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18807 /// for details).
18808 pub fn clear_scopes(mut self) -> FileTrashCall<'a, C> {
18809 self._scopes.clear();
18810 self
18811 }
18812}
18813
18814/// 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.
18815///
18816/// A builder for the *untrash* method supported by a *file* resource.
18817/// It is not used directly, but through a [`FileMethods`] instance.
18818///
18819/// # Example
18820///
18821/// Instantiate a resource method builder
18822///
18823/// ```test_harness,no_run
18824/// # extern crate hyper;
18825/// # extern crate hyper_rustls;
18826/// # extern crate google_drive2 as drive2;
18827/// # async fn dox() {
18828/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18829///
18830/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18831/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18832/// # .with_native_roots()
18833/// # .unwrap()
18834/// # .https_only()
18835/// # .enable_http2()
18836/// # .build();
18837///
18838/// # let executor = hyper_util::rt::TokioExecutor::new();
18839/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18840/// # secret,
18841/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18842/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18843/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18844/// # ),
18845/// # ).build().await.unwrap();
18846///
18847/// # let client = hyper_util::client::legacy::Client::builder(
18848/// # hyper_util::rt::TokioExecutor::new()
18849/// # )
18850/// # .build(
18851/// # hyper_rustls::HttpsConnectorBuilder::new()
18852/// # .with_native_roots()
18853/// # .unwrap()
18854/// # .https_or_http()
18855/// # .enable_http2()
18856/// # .build()
18857/// # );
18858/// # let mut hub = DriveHub::new(client, auth);
18859/// // You can configure optional parameters by calling the respective setters at will, and
18860/// // execute the final call using `doit()`.
18861/// // Values shown here are possibly random and not representative !
18862/// let result = hub.files().untrash("fileId")
18863/// .supports_team_drives(true)
18864/// .supports_all_drives(true)
18865/// .include_permissions_for_view("erat")
18866/// .include_labels("diam")
18867/// .doit().await;
18868/// # }
18869/// ```
18870pub struct FileUntrashCall<'a, C>
18871where
18872 C: 'a,
18873{
18874 hub: &'a DriveHub<C>,
18875 _file_id: String,
18876 _supports_team_drives: Option<bool>,
18877 _supports_all_drives: Option<bool>,
18878 _include_permissions_for_view: Option<String>,
18879 _include_labels: Option<String>,
18880 _delegate: Option<&'a mut dyn common::Delegate>,
18881 _additional_params: HashMap<String, String>,
18882 _scopes: BTreeSet<String>,
18883}
18884
18885impl<'a, C> common::CallBuilder for FileUntrashCall<'a, C> {}
18886
18887impl<'a, C> FileUntrashCall<'a, C>
18888where
18889 C: common::Connector,
18890{
18891 /// Perform the operation you have build so far.
18892 pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
18893 use std::borrow::Cow;
18894 use std::io::{Read, Seek};
18895
18896 use common::{url::Params, ToParts};
18897 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18898
18899 let mut dd = common::DefaultDelegate;
18900 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18901 dlg.begin(common::MethodInfo {
18902 id: "drive.files.untrash",
18903 http_method: hyper::Method::POST,
18904 });
18905
18906 for &field in [
18907 "alt",
18908 "fileId",
18909 "supportsTeamDrives",
18910 "supportsAllDrives",
18911 "includePermissionsForView",
18912 "includeLabels",
18913 ]
18914 .iter()
18915 {
18916 if self._additional_params.contains_key(field) {
18917 dlg.finished(false);
18918 return Err(common::Error::FieldClash(field));
18919 }
18920 }
18921
18922 let mut params = Params::with_capacity(7 + self._additional_params.len());
18923 params.push("fileId", self._file_id);
18924 if let Some(value) = self._supports_team_drives.as_ref() {
18925 params.push("supportsTeamDrives", value.to_string());
18926 }
18927 if let Some(value) = self._supports_all_drives.as_ref() {
18928 params.push("supportsAllDrives", value.to_string());
18929 }
18930 if let Some(value) = self._include_permissions_for_view.as_ref() {
18931 params.push("includePermissionsForView", value);
18932 }
18933 if let Some(value) = self._include_labels.as_ref() {
18934 params.push("includeLabels", value);
18935 }
18936
18937 params.extend(self._additional_params.iter());
18938
18939 params.push("alt", "json");
18940 let mut url = self.hub._base_url.clone() + "files/{fileId}/untrash";
18941 if self._scopes.is_empty() {
18942 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
18943 }
18944
18945 #[allow(clippy::single_element_loop)]
18946 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
18947 url = params.uri_replacement(url, param_name, find_this, false);
18948 }
18949 {
18950 let to_remove = ["fileId"];
18951 params.remove_params(&to_remove);
18952 }
18953
18954 let url = params.parse_with_url(&url);
18955
18956 loop {
18957 let token = match self
18958 .hub
18959 .auth
18960 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18961 .await
18962 {
18963 Ok(token) => token,
18964 Err(e) => match dlg.token(e) {
18965 Ok(token) => token,
18966 Err(e) => {
18967 dlg.finished(false);
18968 return Err(common::Error::MissingToken(e));
18969 }
18970 },
18971 };
18972 let mut req_result = {
18973 let client = &self.hub.client;
18974 dlg.pre_request();
18975 let mut req_builder = hyper::Request::builder()
18976 .method(hyper::Method::POST)
18977 .uri(url.as_str())
18978 .header(USER_AGENT, self.hub._user_agent.clone());
18979
18980 if let Some(token) = token.as_ref() {
18981 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18982 }
18983
18984 let request = req_builder
18985 .header(CONTENT_LENGTH, 0_u64)
18986 .body(common::to_body::<String>(None));
18987
18988 client.request(request.unwrap()).await
18989 };
18990
18991 match req_result {
18992 Err(err) => {
18993 if let common::Retry::After(d) = dlg.http_error(&err) {
18994 sleep(d).await;
18995 continue;
18996 }
18997 dlg.finished(false);
18998 return Err(common::Error::HttpError(err));
18999 }
19000 Ok(res) => {
19001 let (mut parts, body) = res.into_parts();
19002 let mut body = common::Body::new(body);
19003 if !parts.status.is_success() {
19004 let bytes = common::to_bytes(body).await.unwrap_or_default();
19005 let error = serde_json::from_str(&common::to_string(&bytes));
19006 let response = common::to_response(parts, bytes.into());
19007
19008 if let common::Retry::After(d) =
19009 dlg.http_failure(&response, error.as_ref().ok())
19010 {
19011 sleep(d).await;
19012 continue;
19013 }
19014
19015 dlg.finished(false);
19016
19017 return Err(match error {
19018 Ok(value) => common::Error::BadRequest(value),
19019 _ => common::Error::Failure(response),
19020 });
19021 }
19022 let response = {
19023 let bytes = common::to_bytes(body).await.unwrap_or_default();
19024 let encoded = common::to_string(&bytes);
19025 match serde_json::from_str(&encoded) {
19026 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19027 Err(error) => {
19028 dlg.response_json_decode_error(&encoded, &error);
19029 return Err(common::Error::JsonDecodeError(
19030 encoded.to_string(),
19031 error,
19032 ));
19033 }
19034 }
19035 };
19036
19037 dlg.finished(true);
19038 return Ok(response);
19039 }
19040 }
19041 }
19042 }
19043
19044 /// The ID of the file to untrash.
19045 ///
19046 /// Sets the *file id* path property to the given value.
19047 ///
19048 /// Even though the property as already been set when instantiating this call,
19049 /// we provide this method for API completeness.
19050 pub fn file_id(mut self, new_value: &str) -> FileUntrashCall<'a, C> {
19051 self._file_id = new_value.to_string();
19052 self
19053 }
19054 /// Deprecated: Use `supportsAllDrives` instead.
19055 ///
19056 /// Sets the *supports team drives* query property to the given value.
19057 pub fn supports_team_drives(mut self, new_value: bool) -> FileUntrashCall<'a, C> {
19058 self._supports_team_drives = Some(new_value);
19059 self
19060 }
19061 /// Whether the requesting application supports both My Drives and shared drives.
19062 ///
19063 /// Sets the *supports all drives* query property to the given value.
19064 pub fn supports_all_drives(mut self, new_value: bool) -> FileUntrashCall<'a, C> {
19065 self._supports_all_drives = Some(new_value);
19066 self
19067 }
19068 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
19069 ///
19070 /// Sets the *include permissions for view* query property to the given value.
19071 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileUntrashCall<'a, C> {
19072 self._include_permissions_for_view = Some(new_value.to_string());
19073 self
19074 }
19075 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
19076 ///
19077 /// Sets the *include labels* query property to the given value.
19078 pub fn include_labels(mut self, new_value: &str) -> FileUntrashCall<'a, C> {
19079 self._include_labels = Some(new_value.to_string());
19080 self
19081 }
19082 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19083 /// while executing the actual API request.
19084 ///
19085 /// ````text
19086 /// It should be used to handle progress information, and to implement a certain level of resilience.
19087 /// ````
19088 ///
19089 /// Sets the *delegate* property to the given value.
19090 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileUntrashCall<'a, C> {
19091 self._delegate = Some(new_value);
19092 self
19093 }
19094
19095 /// Set any additional parameter of the query string used in the request.
19096 /// It should be used to set parameters which are not yet available through their own
19097 /// setters.
19098 ///
19099 /// Please note that this method must not be used to set any of the known parameters
19100 /// which have their own setter method. If done anyway, the request will fail.
19101 ///
19102 /// # Additional Parameters
19103 ///
19104 /// * *$.xgafv* (query-string) - V1 error format.
19105 /// * *access_token* (query-string) - OAuth access token.
19106 /// * *alt* (query-string) - Data format for response.
19107 /// * *callback* (query-string) - JSONP
19108 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19109 /// * *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.
19110 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19111 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19112 /// * *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.
19113 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19114 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19115 pub fn param<T>(mut self, name: T, value: T) -> FileUntrashCall<'a, C>
19116 where
19117 T: AsRef<str>,
19118 {
19119 self._additional_params
19120 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19121 self
19122 }
19123
19124 /// Identifies the authorization scope for the method you are building.
19125 ///
19126 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19127 /// [`Scope::AppReadonly`].
19128 ///
19129 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19130 /// tokens for more than one scope.
19131 ///
19132 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19133 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19134 /// sufficient, a read-write scope will do as well.
19135 pub fn add_scope<St>(mut self, scope: St) -> FileUntrashCall<'a, C>
19136 where
19137 St: AsRef<str>,
19138 {
19139 self._scopes.insert(String::from(scope.as_ref()));
19140 self
19141 }
19142 /// Identifies the authorization scope(s) for the method you are building.
19143 ///
19144 /// See [`Self::add_scope()`] for details.
19145 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileUntrashCall<'a, C>
19146 where
19147 I: IntoIterator<Item = St>,
19148 St: AsRef<str>,
19149 {
19150 self._scopes
19151 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19152 self
19153 }
19154
19155 /// Removes all scopes, and no default scope will be used either.
19156 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19157 /// for details).
19158 pub fn clear_scopes(mut self) -> FileUntrashCall<'a, C> {
19159 self._scopes.clear();
19160 self
19161 }
19162}
19163
19164/// Updates a file’s metadata, content, or both. 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:* `*/*` (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, see [Google Workspace and Google Drive supported MIME types](https://developers.google.com/workspace/drive/api/guides/mime-types).) For more information on uploading files, see [Upload file data](https://developers.google.com/workspace/drive/api/guides/manage-uploads).
19165///
19166/// A builder for the *update* method supported by a *file* resource.
19167/// It is not used directly, but through a [`FileMethods`] instance.
19168///
19169/// # Example
19170///
19171/// Instantiate a resource method builder
19172///
19173/// ```test_harness,no_run
19174/// # extern crate hyper;
19175/// # extern crate hyper_rustls;
19176/// # extern crate google_drive2 as drive2;
19177/// use drive2::api::File;
19178/// use std::fs;
19179/// # async fn dox() {
19180/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19181///
19182/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19183/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19184/// # .with_native_roots()
19185/// # .unwrap()
19186/// # .https_only()
19187/// # .enable_http2()
19188/// # .build();
19189///
19190/// # let executor = hyper_util::rt::TokioExecutor::new();
19191/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19192/// # secret,
19193/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19194/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19195/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19196/// # ),
19197/// # ).build().await.unwrap();
19198///
19199/// # let client = hyper_util::client::legacy::Client::builder(
19200/// # hyper_util::rt::TokioExecutor::new()
19201/// # )
19202/// # .build(
19203/// # hyper_rustls::HttpsConnectorBuilder::new()
19204/// # .with_native_roots()
19205/// # .unwrap()
19206/// # .https_or_http()
19207/// # .enable_http2()
19208/// # .build()
19209/// # );
19210/// # let mut hub = DriveHub::new(client, auth);
19211/// // As the method needs a request, you would usually fill it with the desired information
19212/// // into the respective structure. Some of the parts shown here might not be applicable !
19213/// // Values shown here are possibly random and not representative !
19214/// let mut req = File::default();
19215///
19216/// // You can configure optional parameters by calling the respective setters at will, and
19217/// // execute the final call using `upload(...)`.
19218/// // Values shown here are possibly random and not representative !
19219/// let result = hub.files().update(req, "fileId")
19220/// .use_content_as_indexable_text(false)
19221/// .update_viewed_date(false)
19222/// .timed_text_track_name("diam")
19223/// .timed_text_language("sed")
19224/// .supports_team_drives(false)
19225/// .supports_all_drives(true)
19226/// .set_modified_date(true)
19227/// .remove_parents("At")
19228/// .pinned(true)
19229/// .ocr_language("sit")
19230/// .ocr(false)
19231/// .new_revision(false)
19232/// .modified_date_behavior("elitr")
19233/// .include_permissions_for_view("aliquyam")
19234/// .include_labels("erat")
19235/// .enforce_single_parent(false)
19236/// .convert(true)
19237/// .add_parents("rebum.")
19238/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
19239/// # }
19240/// ```
19241pub struct FileUpdateCall<'a, C>
19242where
19243 C: 'a,
19244{
19245 hub: &'a DriveHub<C>,
19246 _request: File,
19247 _file_id: String,
19248 _use_content_as_indexable_text: Option<bool>,
19249 _update_viewed_date: Option<bool>,
19250 _timed_text_track_name: Option<String>,
19251 _timed_text_language: Option<String>,
19252 _supports_team_drives: Option<bool>,
19253 _supports_all_drives: Option<bool>,
19254 _set_modified_date: Option<bool>,
19255 _remove_parents: Option<String>,
19256 _pinned: Option<bool>,
19257 _ocr_language: Option<String>,
19258 _ocr: Option<bool>,
19259 _new_revision: Option<bool>,
19260 _modified_date_behavior: Option<String>,
19261 _include_permissions_for_view: Option<String>,
19262 _include_labels: Option<String>,
19263 _enforce_single_parent: Option<bool>,
19264 _convert: Option<bool>,
19265 _add_parents: Option<String>,
19266 _delegate: Option<&'a mut dyn common::Delegate>,
19267 _additional_params: HashMap<String, String>,
19268 _scopes: BTreeSet<String>,
19269}
19270
19271impl<'a, C> common::CallBuilder for FileUpdateCall<'a, C> {}
19272
19273impl<'a, C> FileUpdateCall<'a, C>
19274where
19275 C: common::Connector,
19276{
19277 /// 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
19278 pub async fn doit_without_upload(mut self) -> common::Result<(common::Response, File)> {
19279 use std::borrow::Cow;
19280 use std::io::{Read, Seek};
19281
19282 use common::{url::Params, ToParts};
19283 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19284
19285 let mut dd = common::DefaultDelegate;
19286 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19287 dlg.begin(common::MethodInfo {
19288 id: "drive.files.update",
19289 http_method: hyper::Method::PUT,
19290 });
19291
19292 for &field in [
19293 "alt",
19294 "fileId",
19295 "useContentAsIndexableText",
19296 "updateViewedDate",
19297 "timedTextTrackName",
19298 "timedTextLanguage",
19299 "supportsTeamDrives",
19300 "supportsAllDrives",
19301 "setModifiedDate",
19302 "removeParents",
19303 "pinned",
19304 "ocrLanguage",
19305 "ocr",
19306 "newRevision",
19307 "modifiedDateBehavior",
19308 "includePermissionsForView",
19309 "includeLabels",
19310 "enforceSingleParent",
19311 "convert",
19312 "addParents",
19313 ]
19314 .iter()
19315 {
19316 if self._additional_params.contains_key(field) {
19317 dlg.finished(false);
19318 return Err(common::Error::FieldClash(field));
19319 }
19320 }
19321
19322 let mut params = Params::with_capacity(22 + self._additional_params.len());
19323 params.push("fileId", self._file_id);
19324 if let Some(value) = self._use_content_as_indexable_text.as_ref() {
19325 params.push("useContentAsIndexableText", value.to_string());
19326 }
19327 if let Some(value) = self._update_viewed_date.as_ref() {
19328 params.push("updateViewedDate", value.to_string());
19329 }
19330 if let Some(value) = self._timed_text_track_name.as_ref() {
19331 params.push("timedTextTrackName", value);
19332 }
19333 if let Some(value) = self._timed_text_language.as_ref() {
19334 params.push("timedTextLanguage", value);
19335 }
19336 if let Some(value) = self._supports_team_drives.as_ref() {
19337 params.push("supportsTeamDrives", value.to_string());
19338 }
19339 if let Some(value) = self._supports_all_drives.as_ref() {
19340 params.push("supportsAllDrives", value.to_string());
19341 }
19342 if let Some(value) = self._set_modified_date.as_ref() {
19343 params.push("setModifiedDate", value.to_string());
19344 }
19345 if let Some(value) = self._remove_parents.as_ref() {
19346 params.push("removeParents", value);
19347 }
19348 if let Some(value) = self._pinned.as_ref() {
19349 params.push("pinned", value.to_string());
19350 }
19351 if let Some(value) = self._ocr_language.as_ref() {
19352 params.push("ocrLanguage", value);
19353 }
19354 if let Some(value) = self._ocr.as_ref() {
19355 params.push("ocr", value.to_string());
19356 }
19357 if let Some(value) = self._new_revision.as_ref() {
19358 params.push("newRevision", value.to_string());
19359 }
19360 if let Some(value) = self._modified_date_behavior.as_ref() {
19361 params.push("modifiedDateBehavior", value);
19362 }
19363 if let Some(value) = self._include_permissions_for_view.as_ref() {
19364 params.push("includePermissionsForView", value);
19365 }
19366 if let Some(value) = self._include_labels.as_ref() {
19367 params.push("includeLabels", value);
19368 }
19369 if let Some(value) = self._enforce_single_parent.as_ref() {
19370 params.push("enforceSingleParent", value.to_string());
19371 }
19372 if let Some(value) = self._convert.as_ref() {
19373 params.push("convert", value.to_string());
19374 }
19375 if let Some(value) = self._add_parents.as_ref() {
19376 params.push("addParents", value);
19377 }
19378
19379 params.extend(self._additional_params.iter());
19380
19381 params.push("alt", "json");
19382 let mut url = self.hub._base_url.clone() + "files/{fileId}";
19383 if self._scopes.is_empty() {
19384 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
19385 }
19386
19387 #[allow(clippy::single_element_loop)]
19388 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
19389 url = params.uri_replacement(url, param_name, find_this, false);
19390 }
19391 {
19392 let to_remove = ["fileId"];
19393 params.remove_params(&to_remove);
19394 }
19395
19396 let url = params.parse_with_url(&url);
19397
19398 let mut json_mime_type = mime::APPLICATION_JSON;
19399 let mut request_value_reader = {
19400 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19401 common::remove_json_null_values(&mut value);
19402 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19403 serde_json::to_writer(&mut dst, &value).unwrap();
19404 dst
19405 };
19406 let request_size = request_value_reader
19407 .seek(std::io::SeekFrom::End(0))
19408 .unwrap();
19409 request_value_reader
19410 .seek(std::io::SeekFrom::Start(0))
19411 .unwrap();
19412
19413 loop {
19414 let token = match self
19415 .hub
19416 .auth
19417 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19418 .await
19419 {
19420 Ok(token) => token,
19421 Err(e) => match dlg.token(e) {
19422 Ok(token) => token,
19423 Err(e) => {
19424 dlg.finished(false);
19425 return Err(common::Error::MissingToken(e));
19426 }
19427 },
19428 };
19429 request_value_reader
19430 .seek(std::io::SeekFrom::Start(0))
19431 .unwrap();
19432 let mut req_result = {
19433 let client = &self.hub.client;
19434 dlg.pre_request();
19435 let mut req_builder = hyper::Request::builder()
19436 .method(hyper::Method::PUT)
19437 .uri(url.as_str())
19438 .header(USER_AGENT, self.hub._user_agent.clone());
19439
19440 if let Some(token) = token.as_ref() {
19441 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19442 }
19443
19444 let request = req_builder
19445 .header(CONTENT_TYPE, json_mime_type.to_string())
19446 .header(CONTENT_LENGTH, request_size as u64)
19447 .body(common::to_body(
19448 request_value_reader.get_ref().clone().into(),
19449 ));
19450
19451 client.request(request.unwrap()).await
19452 };
19453
19454 match req_result {
19455 Err(err) => {
19456 if let common::Retry::After(d) = dlg.http_error(&err) {
19457 sleep(d).await;
19458 continue;
19459 }
19460 dlg.finished(false);
19461 return Err(common::Error::HttpError(err));
19462 }
19463 Ok(res) => {
19464 let (mut parts, body) = res.into_parts();
19465 let mut body = common::Body::new(body);
19466 if !parts.status.is_success() {
19467 let bytes = common::to_bytes(body).await.unwrap_or_default();
19468 let error = serde_json::from_str(&common::to_string(&bytes));
19469 let response = common::to_response(parts, bytes.into());
19470
19471 if let common::Retry::After(d) =
19472 dlg.http_failure(&response, error.as_ref().ok())
19473 {
19474 sleep(d).await;
19475 continue;
19476 }
19477
19478 dlg.finished(false);
19479
19480 return Err(match error {
19481 Ok(value) => common::Error::BadRequest(value),
19482 _ => common::Error::Failure(response),
19483 });
19484 }
19485 let response = {
19486 let bytes = common::to_bytes(body).await.unwrap_or_default();
19487 let encoded = common::to_string(&bytes);
19488 match serde_json::from_str(&encoded) {
19489 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19490 Err(error) => {
19491 dlg.response_json_decode_error(&encoded, &error);
19492 return Err(common::Error::JsonDecodeError(
19493 encoded.to_string(),
19494 error,
19495 ));
19496 }
19497 }
19498 };
19499
19500 dlg.finished(true);
19501 return Ok(response);
19502 }
19503 }
19504 }
19505 }
19506
19507 /// Perform the operation you have build so far.
19508 async fn doit<RS>(
19509 mut self,
19510 mut reader: RS,
19511 reader_mime_type: mime::Mime,
19512 protocol: common::UploadProtocol,
19513 ) -> common::Result<(common::Response, File)>
19514 where
19515 RS: common::ReadSeek,
19516 {
19517 use std::borrow::Cow;
19518 use std::io::{Read, Seek};
19519
19520 use common::{url::Params, ToParts};
19521 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19522
19523 let mut dd = common::DefaultDelegate;
19524 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19525 dlg.begin(common::MethodInfo {
19526 id: "drive.files.update",
19527 http_method: hyper::Method::PUT,
19528 });
19529
19530 for &field in [
19531 "alt",
19532 "fileId",
19533 "useContentAsIndexableText",
19534 "updateViewedDate",
19535 "timedTextTrackName",
19536 "timedTextLanguage",
19537 "supportsTeamDrives",
19538 "supportsAllDrives",
19539 "setModifiedDate",
19540 "removeParents",
19541 "pinned",
19542 "ocrLanguage",
19543 "ocr",
19544 "newRevision",
19545 "modifiedDateBehavior",
19546 "includePermissionsForView",
19547 "includeLabels",
19548 "enforceSingleParent",
19549 "convert",
19550 "addParents",
19551 ]
19552 .iter()
19553 {
19554 if self._additional_params.contains_key(field) {
19555 dlg.finished(false);
19556 return Err(common::Error::FieldClash(field));
19557 }
19558 }
19559
19560 let mut params = Params::with_capacity(22 + self._additional_params.len());
19561 params.push("fileId", self._file_id);
19562 if let Some(value) = self._use_content_as_indexable_text.as_ref() {
19563 params.push("useContentAsIndexableText", value.to_string());
19564 }
19565 if let Some(value) = self._update_viewed_date.as_ref() {
19566 params.push("updateViewedDate", value.to_string());
19567 }
19568 if let Some(value) = self._timed_text_track_name.as_ref() {
19569 params.push("timedTextTrackName", value);
19570 }
19571 if let Some(value) = self._timed_text_language.as_ref() {
19572 params.push("timedTextLanguage", value);
19573 }
19574 if let Some(value) = self._supports_team_drives.as_ref() {
19575 params.push("supportsTeamDrives", value.to_string());
19576 }
19577 if let Some(value) = self._supports_all_drives.as_ref() {
19578 params.push("supportsAllDrives", value.to_string());
19579 }
19580 if let Some(value) = self._set_modified_date.as_ref() {
19581 params.push("setModifiedDate", value.to_string());
19582 }
19583 if let Some(value) = self._remove_parents.as_ref() {
19584 params.push("removeParents", value);
19585 }
19586 if let Some(value) = self._pinned.as_ref() {
19587 params.push("pinned", value.to_string());
19588 }
19589 if let Some(value) = self._ocr_language.as_ref() {
19590 params.push("ocrLanguage", value);
19591 }
19592 if let Some(value) = self._ocr.as_ref() {
19593 params.push("ocr", value.to_string());
19594 }
19595 if let Some(value) = self._new_revision.as_ref() {
19596 params.push("newRevision", value.to_string());
19597 }
19598 if let Some(value) = self._modified_date_behavior.as_ref() {
19599 params.push("modifiedDateBehavior", value);
19600 }
19601 if let Some(value) = self._include_permissions_for_view.as_ref() {
19602 params.push("includePermissionsForView", value);
19603 }
19604 if let Some(value) = self._include_labels.as_ref() {
19605 params.push("includeLabels", value);
19606 }
19607 if let Some(value) = self._enforce_single_parent.as_ref() {
19608 params.push("enforceSingleParent", value.to_string());
19609 }
19610 if let Some(value) = self._convert.as_ref() {
19611 params.push("convert", value.to_string());
19612 }
19613 if let Some(value) = self._add_parents.as_ref() {
19614 params.push("addParents", value);
19615 }
19616
19617 params.extend(self._additional_params.iter());
19618
19619 params.push("alt", "json");
19620 let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
19621 (
19622 self.hub._root_url.clone() + "resumable/upload/drive/v2/files/{fileId}",
19623 "resumable",
19624 )
19625 } else if protocol == common::UploadProtocol::Simple {
19626 (
19627 self.hub._root_url.clone() + "upload/drive/v2/files/{fileId}",
19628 "multipart",
19629 )
19630 } else {
19631 unreachable!()
19632 };
19633 params.push("uploadType", upload_type);
19634 if self._scopes.is_empty() {
19635 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
19636 }
19637
19638 #[allow(clippy::single_element_loop)]
19639 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
19640 url = params.uri_replacement(url, param_name, find_this, false);
19641 }
19642 {
19643 let to_remove = ["fileId"];
19644 params.remove_params(&to_remove);
19645 }
19646
19647 let url = params.parse_with_url(&url);
19648
19649 let mut json_mime_type = mime::APPLICATION_JSON;
19650 let mut request_value_reader = {
19651 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19652 common::remove_json_null_values(&mut value);
19653 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19654 serde_json::to_writer(&mut dst, &value).unwrap();
19655 dst
19656 };
19657 let request_size = request_value_reader
19658 .seek(std::io::SeekFrom::End(0))
19659 .unwrap();
19660 request_value_reader
19661 .seek(std::io::SeekFrom::Start(0))
19662 .unwrap();
19663
19664 let mut upload_url_from_server;
19665
19666 loop {
19667 let token = match self
19668 .hub
19669 .auth
19670 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19671 .await
19672 {
19673 Ok(token) => token,
19674 Err(e) => match dlg.token(e) {
19675 Ok(token) => token,
19676 Err(e) => {
19677 dlg.finished(false);
19678 return Err(common::Error::MissingToken(e));
19679 }
19680 },
19681 };
19682 request_value_reader
19683 .seek(std::io::SeekFrom::Start(0))
19684 .unwrap();
19685 let mut req_result = {
19686 let mut mp_reader: common::MultiPartReader = Default::default();
19687 let (mut body_reader, content_type) = match protocol {
19688 common::UploadProtocol::Simple => {
19689 mp_reader.reserve_exact(2);
19690 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
19691 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
19692 if size > 5497558138880 {
19693 return Err(common::Error::UploadSizeLimitExceeded(size, 5497558138880));
19694 }
19695 mp_reader
19696 .add_part(
19697 &mut request_value_reader,
19698 request_size,
19699 json_mime_type.clone(),
19700 )
19701 .add_part(&mut reader, size, reader_mime_type.clone());
19702 (
19703 &mut mp_reader as &mut (dyn std::io::Read + Send),
19704 common::MultiPartReader::mime_type(),
19705 )
19706 }
19707 _ => (
19708 &mut request_value_reader as &mut (dyn std::io::Read + Send),
19709 json_mime_type.clone(),
19710 ),
19711 };
19712 let client = &self.hub.client;
19713 dlg.pre_request();
19714 let mut req_builder = hyper::Request::builder()
19715 .method(hyper::Method::PUT)
19716 .uri(url.as_str())
19717 .header(USER_AGENT, self.hub._user_agent.clone());
19718
19719 if let Some(token) = token.as_ref() {
19720 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19721 }
19722
19723 upload_url_from_server = true;
19724 if protocol == common::UploadProtocol::Resumable {
19725 req_builder = req_builder
19726 .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
19727 }
19728
19729 let mut body_reader_bytes = vec![];
19730 body_reader.read_to_end(&mut body_reader_bytes).unwrap();
19731 let request = req_builder
19732 .header(CONTENT_TYPE, content_type.to_string())
19733 .body(common::to_body(body_reader_bytes.into()));
19734
19735 client.request(request.unwrap()).await
19736 };
19737
19738 match req_result {
19739 Err(err) => {
19740 if let common::Retry::After(d) = dlg.http_error(&err) {
19741 sleep(d).await;
19742 continue;
19743 }
19744 dlg.finished(false);
19745 return Err(common::Error::HttpError(err));
19746 }
19747 Ok(res) => {
19748 let (mut parts, body) = res.into_parts();
19749 let mut body = common::Body::new(body);
19750 if !parts.status.is_success() {
19751 let bytes = common::to_bytes(body).await.unwrap_or_default();
19752 let error = serde_json::from_str(&common::to_string(&bytes));
19753 let response = common::to_response(parts, bytes.into());
19754
19755 if let common::Retry::After(d) =
19756 dlg.http_failure(&response, error.as_ref().ok())
19757 {
19758 sleep(d).await;
19759 continue;
19760 }
19761
19762 dlg.finished(false);
19763
19764 return Err(match error {
19765 Ok(value) => common::Error::BadRequest(value),
19766 _ => common::Error::Failure(response),
19767 });
19768 }
19769 if protocol == common::UploadProtocol::Resumable {
19770 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
19771 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
19772 if size > 5497558138880 {
19773 return Err(common::Error::UploadSizeLimitExceeded(size, 5497558138880));
19774 }
19775 let upload_result = {
19776 let url_str = &parts
19777 .headers
19778 .get("Location")
19779 .expect("LOCATION header is part of protocol")
19780 .to_str()
19781 .unwrap();
19782 if upload_url_from_server {
19783 dlg.store_upload_url(Some(url_str));
19784 }
19785
19786 common::ResumableUploadHelper {
19787 client: &self.hub.client,
19788 delegate: dlg,
19789 start_at: if upload_url_from_server {
19790 Some(0)
19791 } else {
19792 None
19793 },
19794 auth: &self.hub.auth,
19795 user_agent: &self.hub._user_agent,
19796 // TODO: Check this assumption
19797 auth_header: format!(
19798 "Bearer {}",
19799 token
19800 .ok_or_else(|| common::Error::MissingToken(
19801 "resumable upload requires token".into()
19802 ))?
19803 .as_str()
19804 ),
19805 url: url_str,
19806 reader: &mut reader,
19807 media_type: reader_mime_type.clone(),
19808 content_length: size,
19809 }
19810 .upload()
19811 .await
19812 };
19813 match upload_result {
19814 None => {
19815 dlg.finished(false);
19816 return Err(common::Error::Cancelled);
19817 }
19818 Some(Err(err)) => {
19819 dlg.finished(false);
19820 return Err(common::Error::HttpError(err));
19821 }
19822 Some(Ok(response)) => {
19823 (parts, body) = response.into_parts();
19824 if !parts.status.is_success() {
19825 dlg.store_upload_url(None);
19826 dlg.finished(false);
19827 return Err(common::Error::Failure(
19828 common::Response::from_parts(parts, body),
19829 ));
19830 }
19831 }
19832 }
19833 }
19834 let response = {
19835 let bytes = common::to_bytes(body).await.unwrap_or_default();
19836 let encoded = common::to_string(&bytes);
19837 match serde_json::from_str(&encoded) {
19838 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19839 Err(error) => {
19840 dlg.response_json_decode_error(&encoded, &error);
19841 return Err(common::Error::JsonDecodeError(
19842 encoded.to_string(),
19843 error,
19844 ));
19845 }
19846 }
19847 };
19848
19849 dlg.finished(true);
19850 return Ok(response);
19851 }
19852 }
19853 }
19854 }
19855
19856 /// Upload media in a resumable fashion.
19857 /// Even if the upload fails or is interrupted, it can be resumed for a
19858 /// certain amount of time as the server maintains state temporarily.
19859 ///
19860 /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
19861 /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
19862 /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
19863 /// `cancel_chunk_upload(...)`.
19864 ///
19865 /// * *multipart*: yes
19866 /// * *max size*: 5497558138880
19867 /// * *valid mime types*: '*/*'
19868 pub async fn upload_resumable<RS>(
19869 self,
19870 resumeable_stream: RS,
19871 mime_type: mime::Mime,
19872 ) -> common::Result<(common::Response, File)>
19873 where
19874 RS: common::ReadSeek,
19875 {
19876 self.doit(
19877 resumeable_stream,
19878 mime_type,
19879 common::UploadProtocol::Resumable,
19880 )
19881 .await
19882 }
19883 /// Upload media all at once.
19884 /// If the upload fails for whichever reason, all progress is lost.
19885 ///
19886 /// * *multipart*: yes
19887 /// * *max size*: 5497558138880
19888 /// * *valid mime types*: '*/*'
19889 pub async fn upload<RS>(
19890 self,
19891 stream: RS,
19892 mime_type: mime::Mime,
19893 ) -> common::Result<(common::Response, File)>
19894 where
19895 RS: common::ReadSeek,
19896 {
19897 self.doit(stream, mime_type, common::UploadProtocol::Simple)
19898 .await
19899 }
19900
19901 ///
19902 /// Sets the *request* property to the given value.
19903 ///
19904 /// Even though the property as already been set when instantiating this call,
19905 /// we provide this method for API completeness.
19906 pub fn request(mut self, new_value: File) -> FileUpdateCall<'a, C> {
19907 self._request = new_value;
19908 self
19909 }
19910 /// The ID of the file to update.
19911 ///
19912 /// Sets the *file id* path property to the given value.
19913 ///
19914 /// Even though the property as already been set when instantiating this call,
19915 /// we provide this method for API completeness.
19916 pub fn file_id(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
19917 self._file_id = new_value.to_string();
19918 self
19919 }
19920 /// Whether to use the content as indexable text.
19921 ///
19922 /// Sets the *use content as indexable text* query property to the given value.
19923 pub fn use_content_as_indexable_text(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
19924 self._use_content_as_indexable_text = Some(new_value);
19925 self
19926 }
19927 /// Whether to update the view date after successfully updating the file.
19928 ///
19929 /// Sets the *update viewed date* query property to the given value.
19930 pub fn update_viewed_date(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
19931 self._update_viewed_date = Some(new_value);
19932 self
19933 }
19934 /// The timed text track name.
19935 ///
19936 /// Sets the *timed text track name* query property to the given value.
19937 pub fn timed_text_track_name(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
19938 self._timed_text_track_name = Some(new_value.to_string());
19939 self
19940 }
19941 /// The language of the timed text.
19942 ///
19943 /// Sets the *timed text language* query property to the given value.
19944 pub fn timed_text_language(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
19945 self._timed_text_language = Some(new_value.to_string());
19946 self
19947 }
19948 /// Deprecated: Use `supportsAllDrives` instead.
19949 ///
19950 /// Sets the *supports team drives* query property to the given value.
19951 pub fn supports_team_drives(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
19952 self._supports_team_drives = Some(new_value);
19953 self
19954 }
19955 /// Whether the requesting application supports both My Drives and shared drives.
19956 ///
19957 /// Sets the *supports all drives* query property to the given value.
19958 pub fn supports_all_drives(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
19959 self._supports_all_drives = Some(new_value);
19960 self
19961 }
19962 /// 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`.
19963 ///
19964 /// Sets the *set modified date* query property to the given value.
19965 pub fn set_modified_date(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
19966 self._set_modified_date = Some(new_value);
19967 self
19968 }
19969 /// Comma-separated list of parent IDs to remove.
19970 ///
19971 /// Sets the *remove parents* query property to the given value.
19972 pub fn remove_parents(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
19973 self._remove_parents = Some(new_value.to_string());
19974 self
19975 }
19976 /// Whether to pin the new revision. A file can have a maximum of 200 pinned revisions.
19977 ///
19978 /// Sets the *pinned* query property to the given value.
19979 pub fn pinned(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
19980 self._pinned = Some(new_value);
19981 self
19982 }
19983 /// If ocr is true, hints at the language to use. Valid values are BCP 47 codes.
19984 ///
19985 /// Sets the *ocr language* query property to the given value.
19986 pub fn ocr_language(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
19987 self._ocr_language = Some(new_value.to_string());
19988 self
19989 }
19990 /// Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads.
19991 ///
19992 /// Sets the *ocr* query property to the given value.
19993 pub fn ocr(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
19994 self._ocr = Some(new_value);
19995 self
19996 }
19997 /// 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).
19998 ///
19999 /// Sets the *new revision* query property to the given value.
20000 pub fn new_revision(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
20001 self._new_revision = Some(new_value);
20002 self
20003 }
20004 /// Determines the behavior in which `modifiedDate` is updated. This overrides `setModifiedDate`.
20005 ///
20006 /// Sets the *modified date behavior* query property to the given value.
20007 pub fn modified_date_behavior(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
20008 self._modified_date_behavior = Some(new_value.to_string());
20009 self
20010 }
20011 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
20012 ///
20013 /// Sets the *include permissions for view* query property to the given value.
20014 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
20015 self._include_permissions_for_view = Some(new_value.to_string());
20016 self
20017 }
20018 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
20019 ///
20020 /// Sets the *include labels* query property to the given value.
20021 pub fn include_labels(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
20022 self._include_labels = Some(new_value.to_string());
20023 self
20024 }
20025 /// Deprecated: Adding files to multiple folders is no longer supported. Use `shortcuts` instead.
20026 ///
20027 /// Sets the *enforce single parent* query property to the given value.
20028 pub fn enforce_single_parent(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
20029 self._enforce_single_parent = Some(new_value);
20030 self
20031 }
20032 /// Deprecated: This parameter has no function.
20033 ///
20034 /// Sets the *convert* query property to the given value.
20035 pub fn convert(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
20036 self._convert = Some(new_value);
20037 self
20038 }
20039 /// Comma-separated list of parent IDs to add.
20040 ///
20041 /// Sets the *add parents* query property to the given value.
20042 pub fn add_parents(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
20043 self._add_parents = Some(new_value.to_string());
20044 self
20045 }
20046 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20047 /// while executing the actual API request.
20048 ///
20049 /// ````text
20050 /// It should be used to handle progress information, and to implement a certain level of resilience.
20051 /// ````
20052 ///
20053 /// Sets the *delegate* property to the given value.
20054 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileUpdateCall<'a, C> {
20055 self._delegate = Some(new_value);
20056 self
20057 }
20058
20059 /// Set any additional parameter of the query string used in the request.
20060 /// It should be used to set parameters which are not yet available through their own
20061 /// setters.
20062 ///
20063 /// Please note that this method must not be used to set any of the known parameters
20064 /// which have their own setter method. If done anyway, the request will fail.
20065 ///
20066 /// # Additional Parameters
20067 ///
20068 /// * *$.xgafv* (query-string) - V1 error format.
20069 /// * *access_token* (query-string) - OAuth access token.
20070 /// * *alt* (query-string) - Data format for response.
20071 /// * *callback* (query-string) - JSONP
20072 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20073 /// * *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.
20074 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20075 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20076 /// * *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.
20077 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20078 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20079 pub fn param<T>(mut self, name: T, value: T) -> FileUpdateCall<'a, C>
20080 where
20081 T: AsRef<str>,
20082 {
20083 self._additional_params
20084 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20085 self
20086 }
20087
20088 /// Identifies the authorization scope for the method you are building.
20089 ///
20090 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20091 /// [`Scope::AppReadonly`].
20092 ///
20093 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20094 /// tokens for more than one scope.
20095 ///
20096 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20097 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20098 /// sufficient, a read-write scope will do as well.
20099 pub fn add_scope<St>(mut self, scope: St) -> FileUpdateCall<'a, C>
20100 where
20101 St: AsRef<str>,
20102 {
20103 self._scopes.insert(String::from(scope.as_ref()));
20104 self
20105 }
20106 /// Identifies the authorization scope(s) for the method you are building.
20107 ///
20108 /// See [`Self::add_scope()`] for details.
20109 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileUpdateCall<'a, C>
20110 where
20111 I: IntoIterator<Item = St>,
20112 St: AsRef<str>,
20113 {
20114 self._scopes
20115 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20116 self
20117 }
20118
20119 /// Removes all scopes, and no default scope will be used either.
20120 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20121 /// for details).
20122 pub fn clear_scopes(mut self) -> FileUpdateCall<'a, C> {
20123 self._scopes.clear();
20124 self
20125 }
20126}
20127
20128/// Subscribes to changes to a file.
20129///
20130/// A builder for the *watch* method supported by a *file* resource.
20131/// It is not used directly, but through a [`FileMethods`] instance.
20132///
20133/// # Example
20134///
20135/// Instantiate a resource method builder
20136///
20137/// ```test_harness,no_run
20138/// # extern crate hyper;
20139/// # extern crate hyper_rustls;
20140/// # extern crate google_drive2 as drive2;
20141/// use drive2::api::Channel;
20142/// # async fn dox() {
20143/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20144///
20145/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20146/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20147/// # .with_native_roots()
20148/// # .unwrap()
20149/// # .https_only()
20150/// # .enable_http2()
20151/// # .build();
20152///
20153/// # let executor = hyper_util::rt::TokioExecutor::new();
20154/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20155/// # secret,
20156/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20157/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20158/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20159/// # ),
20160/// # ).build().await.unwrap();
20161///
20162/// # let client = hyper_util::client::legacy::Client::builder(
20163/// # hyper_util::rt::TokioExecutor::new()
20164/// # )
20165/// # .build(
20166/// # hyper_rustls::HttpsConnectorBuilder::new()
20167/// # .with_native_roots()
20168/// # .unwrap()
20169/// # .https_or_http()
20170/// # .enable_http2()
20171/// # .build()
20172/// # );
20173/// # let mut hub = DriveHub::new(client, auth);
20174/// // As the method needs a request, you would usually fill it with the desired information
20175/// // into the respective structure. Some of the parts shown here might not be applicable !
20176/// // Values shown here are possibly random and not representative !
20177/// let mut req = Channel::default();
20178///
20179/// // You can configure optional parameters by calling the respective setters at will, and
20180/// // execute the final call using `doit()`.
20181/// // Values shown here are possibly random and not representative !
20182/// let result = hub.files().watch(req, "fileId")
20183/// .update_viewed_date(true)
20184/// .supports_team_drives(false)
20185/// .supports_all_drives(false)
20186/// .revision_id("sit")
20187/// .projection("kasd")
20188/// .include_permissions_for_view("tempor")
20189/// .include_labels("dolor")
20190/// .acknowledge_abuse(false)
20191/// .doit().await;
20192/// # }
20193/// ```
20194pub struct FileWatchCall<'a, C>
20195where
20196 C: 'a,
20197{
20198 hub: &'a DriveHub<C>,
20199 _request: Channel,
20200 _file_id: String,
20201 _update_viewed_date: Option<bool>,
20202 _supports_team_drives: Option<bool>,
20203 _supports_all_drives: Option<bool>,
20204 _revision_id: Option<String>,
20205 _projection: Option<String>,
20206 _include_permissions_for_view: Option<String>,
20207 _include_labels: Option<String>,
20208 _acknowledge_abuse: Option<bool>,
20209 _delegate: Option<&'a mut dyn common::Delegate>,
20210 _additional_params: HashMap<String, String>,
20211 _scopes: BTreeSet<String>,
20212}
20213
20214impl<'a, C> common::CallBuilder for FileWatchCall<'a, C> {}
20215
20216impl<'a, C> FileWatchCall<'a, C>
20217where
20218 C: common::Connector,
20219{
20220 /// Perform the operation you have build so far.
20221 pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
20222 use std::borrow::Cow;
20223 use std::io::{Read, Seek};
20224
20225 use common::{url::Params, ToParts};
20226 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20227
20228 let mut dd = common::DefaultDelegate;
20229 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20230 dlg.begin(common::MethodInfo {
20231 id: "drive.files.watch",
20232 http_method: hyper::Method::POST,
20233 });
20234
20235 for &field in [
20236 "alt",
20237 "fileId",
20238 "updateViewedDate",
20239 "supportsTeamDrives",
20240 "supportsAllDrives",
20241 "revisionId",
20242 "projection",
20243 "includePermissionsForView",
20244 "includeLabels",
20245 "acknowledgeAbuse",
20246 ]
20247 .iter()
20248 {
20249 if self._additional_params.contains_key(field) {
20250 dlg.finished(false);
20251 return Err(common::Error::FieldClash(field));
20252 }
20253 }
20254
20255 let mut params = Params::with_capacity(12 + self._additional_params.len());
20256 params.push("fileId", self._file_id);
20257 if let Some(value) = self._update_viewed_date.as_ref() {
20258 params.push("updateViewedDate", value.to_string());
20259 }
20260 if let Some(value) = self._supports_team_drives.as_ref() {
20261 params.push("supportsTeamDrives", value.to_string());
20262 }
20263 if let Some(value) = self._supports_all_drives.as_ref() {
20264 params.push("supportsAllDrives", value.to_string());
20265 }
20266 if let Some(value) = self._revision_id.as_ref() {
20267 params.push("revisionId", value);
20268 }
20269 if let Some(value) = self._projection.as_ref() {
20270 params.push("projection", value);
20271 }
20272 if let Some(value) = self._include_permissions_for_view.as_ref() {
20273 params.push("includePermissionsForView", value);
20274 }
20275 if let Some(value) = self._include_labels.as_ref() {
20276 params.push("includeLabels", value);
20277 }
20278 if let Some(value) = self._acknowledge_abuse.as_ref() {
20279 params.push("acknowledgeAbuse", value.to_string());
20280 }
20281
20282 params.extend(self._additional_params.iter());
20283
20284 params.push("alt", "json");
20285 let mut url = self.hub._base_url.clone() + "files/{fileId}/watch";
20286 if self._scopes.is_empty() {
20287 self._scopes
20288 .insert(Scope::MeetReadonly.as_ref().to_string());
20289 }
20290
20291 #[allow(clippy::single_element_loop)]
20292 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
20293 url = params.uri_replacement(url, param_name, find_this, false);
20294 }
20295 {
20296 let to_remove = ["fileId"];
20297 params.remove_params(&to_remove);
20298 }
20299
20300 let url = params.parse_with_url(&url);
20301
20302 let mut json_mime_type = mime::APPLICATION_JSON;
20303 let mut request_value_reader = {
20304 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20305 common::remove_json_null_values(&mut value);
20306 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20307 serde_json::to_writer(&mut dst, &value).unwrap();
20308 dst
20309 };
20310 let request_size = request_value_reader
20311 .seek(std::io::SeekFrom::End(0))
20312 .unwrap();
20313 request_value_reader
20314 .seek(std::io::SeekFrom::Start(0))
20315 .unwrap();
20316
20317 loop {
20318 let token = match self
20319 .hub
20320 .auth
20321 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20322 .await
20323 {
20324 Ok(token) => token,
20325 Err(e) => match dlg.token(e) {
20326 Ok(token) => token,
20327 Err(e) => {
20328 dlg.finished(false);
20329 return Err(common::Error::MissingToken(e));
20330 }
20331 },
20332 };
20333 request_value_reader
20334 .seek(std::io::SeekFrom::Start(0))
20335 .unwrap();
20336 let mut req_result = {
20337 let client = &self.hub.client;
20338 dlg.pre_request();
20339 let mut req_builder = hyper::Request::builder()
20340 .method(hyper::Method::POST)
20341 .uri(url.as_str())
20342 .header(USER_AGENT, self.hub._user_agent.clone());
20343
20344 if let Some(token) = token.as_ref() {
20345 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20346 }
20347
20348 let request = req_builder
20349 .header(CONTENT_TYPE, json_mime_type.to_string())
20350 .header(CONTENT_LENGTH, request_size as u64)
20351 .body(common::to_body(
20352 request_value_reader.get_ref().clone().into(),
20353 ));
20354
20355 client.request(request.unwrap()).await
20356 };
20357
20358 match req_result {
20359 Err(err) => {
20360 if let common::Retry::After(d) = dlg.http_error(&err) {
20361 sleep(d).await;
20362 continue;
20363 }
20364 dlg.finished(false);
20365 return Err(common::Error::HttpError(err));
20366 }
20367 Ok(res) => {
20368 let (mut parts, body) = res.into_parts();
20369 let mut body = common::Body::new(body);
20370 if !parts.status.is_success() {
20371 let bytes = common::to_bytes(body).await.unwrap_or_default();
20372 let error = serde_json::from_str(&common::to_string(&bytes));
20373 let response = common::to_response(parts, bytes.into());
20374
20375 if let common::Retry::After(d) =
20376 dlg.http_failure(&response, error.as_ref().ok())
20377 {
20378 sleep(d).await;
20379 continue;
20380 }
20381
20382 dlg.finished(false);
20383
20384 return Err(match error {
20385 Ok(value) => common::Error::BadRequest(value),
20386 _ => common::Error::Failure(response),
20387 });
20388 }
20389 let response = {
20390 let bytes = common::to_bytes(body).await.unwrap_or_default();
20391 let encoded = common::to_string(&bytes);
20392 match serde_json::from_str(&encoded) {
20393 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20394 Err(error) => {
20395 dlg.response_json_decode_error(&encoded, &error);
20396 return Err(common::Error::JsonDecodeError(
20397 encoded.to_string(),
20398 error,
20399 ));
20400 }
20401 }
20402 };
20403
20404 dlg.finished(true);
20405 return Ok(response);
20406 }
20407 }
20408 }
20409 }
20410
20411 ///
20412 /// Sets the *request* property to the given value.
20413 ///
20414 /// Even though the property as already been set when instantiating this call,
20415 /// we provide this method for API completeness.
20416 pub fn request(mut self, new_value: Channel) -> FileWatchCall<'a, C> {
20417 self._request = new_value;
20418 self
20419 }
20420 /// The ID for the file in question.
20421 ///
20422 /// Sets the *file id* path property to the given value.
20423 ///
20424 /// Even though the property as already been set when instantiating this call,
20425 /// we provide this method for API completeness.
20426 pub fn file_id(mut self, new_value: &str) -> FileWatchCall<'a, C> {
20427 self._file_id = new_value.to_string();
20428 self
20429 }
20430 /// Deprecated: Use files.update with modifiedDateBehavior=noChange, updateViewedDate=true and an empty request body.
20431 ///
20432 /// Sets the *update viewed date* query property to the given value.
20433 pub fn update_viewed_date(mut self, new_value: bool) -> FileWatchCall<'a, C> {
20434 self._update_viewed_date = Some(new_value);
20435 self
20436 }
20437 /// Deprecated: Use `supportsAllDrives` instead.
20438 ///
20439 /// Sets the *supports team drives* query property to the given value.
20440 pub fn supports_team_drives(mut self, new_value: bool) -> FileWatchCall<'a, C> {
20441 self._supports_team_drives = Some(new_value);
20442 self
20443 }
20444 /// Whether the requesting application supports both My Drives and shared drives.
20445 ///
20446 /// Sets the *supports all drives* query property to the given value.
20447 pub fn supports_all_drives(mut self, new_value: bool) -> FileWatchCall<'a, C> {
20448 self._supports_all_drives = Some(new_value);
20449 self
20450 }
20451 /// Specifies the Revision ID that should be downloaded. Ignored unless alt=media is specified.
20452 ///
20453 /// Sets the *revision id* query property to the given value.
20454 pub fn revision_id(mut self, new_value: &str) -> FileWatchCall<'a, C> {
20455 self._revision_id = Some(new_value.to_string());
20456 self
20457 }
20458 /// Deprecated: This parameter has no function.
20459 ///
20460 /// Sets the *projection* query property to the given value.
20461 pub fn projection(mut self, new_value: &str) -> FileWatchCall<'a, C> {
20462 self._projection = Some(new_value.to_string());
20463 self
20464 }
20465 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
20466 ///
20467 /// Sets the *include permissions for view* query property to the given value.
20468 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileWatchCall<'a, C> {
20469 self._include_permissions_for_view = Some(new_value.to_string());
20470 self
20471 }
20472 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
20473 ///
20474 /// Sets the *include labels* query property to the given value.
20475 pub fn include_labels(mut self, new_value: &str) -> FileWatchCall<'a, C> {
20476 self._include_labels = Some(new_value.to_string());
20477 self
20478 }
20479 /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when the `alt` parameter is set to `media` and the user is the owner of the file or an organizer of the shared drive in which the file resides.
20480 ///
20481 /// Sets the *acknowledge abuse* query property to the given value.
20482 pub fn acknowledge_abuse(mut self, new_value: bool) -> FileWatchCall<'a, C> {
20483 self._acknowledge_abuse = Some(new_value);
20484 self
20485 }
20486 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20487 /// while executing the actual API request.
20488 ///
20489 /// ````text
20490 /// It should be used to handle progress information, and to implement a certain level of resilience.
20491 /// ````
20492 ///
20493 /// Sets the *delegate* property to the given value.
20494 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileWatchCall<'a, C> {
20495 self._delegate = Some(new_value);
20496 self
20497 }
20498
20499 /// Set any additional parameter of the query string used in the request.
20500 /// It should be used to set parameters which are not yet available through their own
20501 /// setters.
20502 ///
20503 /// Please note that this method must not be used to set any of the known parameters
20504 /// which have their own setter method. If done anyway, the request will fail.
20505 ///
20506 /// # Additional Parameters
20507 ///
20508 /// * *$.xgafv* (query-string) - V1 error format.
20509 /// * *access_token* (query-string) - OAuth access token.
20510 /// * *alt* (query-string) - Data format for response.
20511 /// * *callback* (query-string) - JSONP
20512 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20513 /// * *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.
20514 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20515 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20516 /// * *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.
20517 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20518 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20519 pub fn param<T>(mut self, name: T, value: T) -> FileWatchCall<'a, C>
20520 where
20521 T: AsRef<str>,
20522 {
20523 self._additional_params
20524 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20525 self
20526 }
20527
20528 /// Identifies the authorization scope for the method you are building.
20529 ///
20530 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20531 /// [`Scope::MeetReadonly`].
20532 ///
20533 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20534 /// tokens for more than one scope.
20535 ///
20536 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20537 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20538 /// sufficient, a read-write scope will do as well.
20539 pub fn add_scope<St>(mut self, scope: St) -> FileWatchCall<'a, C>
20540 where
20541 St: AsRef<str>,
20542 {
20543 self._scopes.insert(String::from(scope.as_ref()));
20544 self
20545 }
20546 /// Identifies the authorization scope(s) for the method you are building.
20547 ///
20548 /// See [`Self::add_scope()`] for details.
20549 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileWatchCall<'a, C>
20550 where
20551 I: IntoIterator<Item = St>,
20552 St: AsRef<str>,
20553 {
20554 self._scopes
20555 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20556 self
20557 }
20558
20559 /// Removes all scopes, and no default scope will be used either.
20560 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20561 /// for details).
20562 pub fn clear_scopes(mut self) -> FileWatchCall<'a, C> {
20563 self._scopes.clear();
20564 self
20565 }
20566}
20567
20568/// Removes a parent from a file.
20569///
20570/// A builder for the *delete* method supported by a *parent* resource.
20571/// It is not used directly, but through a [`ParentMethods`] instance.
20572///
20573/// # Example
20574///
20575/// Instantiate a resource method builder
20576///
20577/// ```test_harness,no_run
20578/// # extern crate hyper;
20579/// # extern crate hyper_rustls;
20580/// # extern crate google_drive2 as drive2;
20581/// # async fn dox() {
20582/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20583///
20584/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20585/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20586/// # .with_native_roots()
20587/// # .unwrap()
20588/// # .https_only()
20589/// # .enable_http2()
20590/// # .build();
20591///
20592/// # let executor = hyper_util::rt::TokioExecutor::new();
20593/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20594/// # secret,
20595/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20596/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20597/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20598/// # ),
20599/// # ).build().await.unwrap();
20600///
20601/// # let client = hyper_util::client::legacy::Client::builder(
20602/// # hyper_util::rt::TokioExecutor::new()
20603/// # )
20604/// # .build(
20605/// # hyper_rustls::HttpsConnectorBuilder::new()
20606/// # .with_native_roots()
20607/// # .unwrap()
20608/// # .https_or_http()
20609/// # .enable_http2()
20610/// # .build()
20611/// # );
20612/// # let mut hub = DriveHub::new(client, auth);
20613/// // You can configure optional parameters by calling the respective setters at will, and
20614/// // execute the final call using `doit()`.
20615/// // Values shown here are possibly random and not representative !
20616/// let result = hub.parents().delete("fileId", "parentId")
20617/// .enforce_single_parent(true)
20618/// .doit().await;
20619/// # }
20620/// ```
20621pub struct ParentDeleteCall<'a, C>
20622where
20623 C: 'a,
20624{
20625 hub: &'a DriveHub<C>,
20626 _file_id: String,
20627 _parent_id: String,
20628 _enforce_single_parent: Option<bool>,
20629 _delegate: Option<&'a mut dyn common::Delegate>,
20630 _additional_params: HashMap<String, String>,
20631 _scopes: BTreeSet<String>,
20632}
20633
20634impl<'a, C> common::CallBuilder for ParentDeleteCall<'a, C> {}
20635
20636impl<'a, C> ParentDeleteCall<'a, C>
20637where
20638 C: common::Connector,
20639{
20640 /// Perform the operation you have build so far.
20641 pub async fn doit(mut self) -> common::Result<common::Response> {
20642 use std::borrow::Cow;
20643 use std::io::{Read, Seek};
20644
20645 use common::{url::Params, ToParts};
20646 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20647
20648 let mut dd = common::DefaultDelegate;
20649 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20650 dlg.begin(common::MethodInfo {
20651 id: "drive.parents.delete",
20652 http_method: hyper::Method::DELETE,
20653 });
20654
20655 for &field in ["fileId", "parentId", "enforceSingleParent"].iter() {
20656 if self._additional_params.contains_key(field) {
20657 dlg.finished(false);
20658 return Err(common::Error::FieldClash(field));
20659 }
20660 }
20661
20662 let mut params = Params::with_capacity(4 + self._additional_params.len());
20663 params.push("fileId", self._file_id);
20664 params.push("parentId", self._parent_id);
20665 if let Some(value) = self._enforce_single_parent.as_ref() {
20666 params.push("enforceSingleParent", value.to_string());
20667 }
20668
20669 params.extend(self._additional_params.iter());
20670
20671 let mut url = self.hub._base_url.clone() + "files/{fileId}/parents/{parentId}";
20672 if self._scopes.is_empty() {
20673 self._scopes.insert(Scope::Full.as_ref().to_string());
20674 }
20675
20676 #[allow(clippy::single_element_loop)]
20677 for &(find_this, param_name) in [("{fileId}", "fileId"), ("{parentId}", "parentId")].iter()
20678 {
20679 url = params.uri_replacement(url, param_name, find_this, false);
20680 }
20681 {
20682 let to_remove = ["parentId", "fileId"];
20683 params.remove_params(&to_remove);
20684 }
20685
20686 let url = params.parse_with_url(&url);
20687
20688 loop {
20689 let token = match self
20690 .hub
20691 .auth
20692 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20693 .await
20694 {
20695 Ok(token) => token,
20696 Err(e) => match dlg.token(e) {
20697 Ok(token) => token,
20698 Err(e) => {
20699 dlg.finished(false);
20700 return Err(common::Error::MissingToken(e));
20701 }
20702 },
20703 };
20704 let mut req_result = {
20705 let client = &self.hub.client;
20706 dlg.pre_request();
20707 let mut req_builder = hyper::Request::builder()
20708 .method(hyper::Method::DELETE)
20709 .uri(url.as_str())
20710 .header(USER_AGENT, self.hub._user_agent.clone());
20711
20712 if let Some(token) = token.as_ref() {
20713 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20714 }
20715
20716 let request = req_builder
20717 .header(CONTENT_LENGTH, 0_u64)
20718 .body(common::to_body::<String>(None));
20719
20720 client.request(request.unwrap()).await
20721 };
20722
20723 match req_result {
20724 Err(err) => {
20725 if let common::Retry::After(d) = dlg.http_error(&err) {
20726 sleep(d).await;
20727 continue;
20728 }
20729 dlg.finished(false);
20730 return Err(common::Error::HttpError(err));
20731 }
20732 Ok(res) => {
20733 let (mut parts, body) = res.into_parts();
20734 let mut body = common::Body::new(body);
20735 if !parts.status.is_success() {
20736 let bytes = common::to_bytes(body).await.unwrap_or_default();
20737 let error = serde_json::from_str(&common::to_string(&bytes));
20738 let response = common::to_response(parts, bytes.into());
20739
20740 if let common::Retry::After(d) =
20741 dlg.http_failure(&response, error.as_ref().ok())
20742 {
20743 sleep(d).await;
20744 continue;
20745 }
20746
20747 dlg.finished(false);
20748
20749 return Err(match error {
20750 Ok(value) => common::Error::BadRequest(value),
20751 _ => common::Error::Failure(response),
20752 });
20753 }
20754 let response = common::Response::from_parts(parts, body);
20755
20756 dlg.finished(true);
20757 return Ok(response);
20758 }
20759 }
20760 }
20761 }
20762
20763 /// The ID of the file.
20764 ///
20765 /// Sets the *file id* path property to the given value.
20766 ///
20767 /// Even though the property as already been set when instantiating this call,
20768 /// we provide this method for API completeness.
20769 pub fn file_id(mut self, new_value: &str) -> ParentDeleteCall<'a, C> {
20770 self._file_id = new_value.to_string();
20771 self
20772 }
20773 /// The ID of the parent.
20774 ///
20775 /// Sets the *parent id* path property to the given value.
20776 ///
20777 /// Even though the property as already been set when instantiating this call,
20778 /// we provide this method for API completeness.
20779 pub fn parent_id(mut self, new_value: &str) -> ParentDeleteCall<'a, C> {
20780 self._parent_id = new_value.to_string();
20781 self
20782 }
20783 /// 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.
20784 ///
20785 /// Sets the *enforce single parent* query property to the given value.
20786 pub fn enforce_single_parent(mut self, new_value: bool) -> ParentDeleteCall<'a, C> {
20787 self._enforce_single_parent = Some(new_value);
20788 self
20789 }
20790 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20791 /// while executing the actual API request.
20792 ///
20793 /// ````text
20794 /// It should be used to handle progress information, and to implement a certain level of resilience.
20795 /// ````
20796 ///
20797 /// Sets the *delegate* property to the given value.
20798 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ParentDeleteCall<'a, C> {
20799 self._delegate = Some(new_value);
20800 self
20801 }
20802
20803 /// Set any additional parameter of the query string used in the request.
20804 /// It should be used to set parameters which are not yet available through their own
20805 /// setters.
20806 ///
20807 /// Please note that this method must not be used to set any of the known parameters
20808 /// which have their own setter method. If done anyway, the request will fail.
20809 ///
20810 /// # Additional Parameters
20811 ///
20812 /// * *$.xgafv* (query-string) - V1 error format.
20813 /// * *access_token* (query-string) - OAuth access token.
20814 /// * *alt* (query-string) - Data format for response.
20815 /// * *callback* (query-string) - JSONP
20816 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20817 /// * *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.
20818 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20819 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20820 /// * *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.
20821 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20822 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20823 pub fn param<T>(mut self, name: T, value: T) -> ParentDeleteCall<'a, C>
20824 where
20825 T: AsRef<str>,
20826 {
20827 self._additional_params
20828 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20829 self
20830 }
20831
20832 /// Identifies the authorization scope for the method you are building.
20833 ///
20834 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20835 /// [`Scope::Full`].
20836 ///
20837 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20838 /// tokens for more than one scope.
20839 ///
20840 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20841 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20842 /// sufficient, a read-write scope will do as well.
20843 pub fn add_scope<St>(mut self, scope: St) -> ParentDeleteCall<'a, C>
20844 where
20845 St: AsRef<str>,
20846 {
20847 self._scopes.insert(String::from(scope.as_ref()));
20848 self
20849 }
20850 /// Identifies the authorization scope(s) for the method you are building.
20851 ///
20852 /// See [`Self::add_scope()`] for details.
20853 pub fn add_scopes<I, St>(mut self, scopes: I) -> ParentDeleteCall<'a, C>
20854 where
20855 I: IntoIterator<Item = St>,
20856 St: AsRef<str>,
20857 {
20858 self._scopes
20859 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20860 self
20861 }
20862
20863 /// Removes all scopes, and no default scope will be used either.
20864 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20865 /// for details).
20866 pub fn clear_scopes(mut self) -> ParentDeleteCall<'a, C> {
20867 self._scopes.clear();
20868 self
20869 }
20870}
20871
20872/// Gets a specific parent reference.
20873///
20874/// A builder for the *get* method supported by a *parent* resource.
20875/// It is not used directly, but through a [`ParentMethods`] instance.
20876///
20877/// # Example
20878///
20879/// Instantiate a resource method builder
20880///
20881/// ```test_harness,no_run
20882/// # extern crate hyper;
20883/// # extern crate hyper_rustls;
20884/// # extern crate google_drive2 as drive2;
20885/// # async fn dox() {
20886/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20887///
20888/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20889/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20890/// # .with_native_roots()
20891/// # .unwrap()
20892/// # .https_only()
20893/// # .enable_http2()
20894/// # .build();
20895///
20896/// # let executor = hyper_util::rt::TokioExecutor::new();
20897/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20898/// # secret,
20899/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20900/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20901/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20902/// # ),
20903/// # ).build().await.unwrap();
20904///
20905/// # let client = hyper_util::client::legacy::Client::builder(
20906/// # hyper_util::rt::TokioExecutor::new()
20907/// # )
20908/// # .build(
20909/// # hyper_rustls::HttpsConnectorBuilder::new()
20910/// # .with_native_roots()
20911/// # .unwrap()
20912/// # .https_or_http()
20913/// # .enable_http2()
20914/// # .build()
20915/// # );
20916/// # let mut hub = DriveHub::new(client, auth);
20917/// // You can configure optional parameters by calling the respective setters at will, and
20918/// // execute the final call using `doit()`.
20919/// // Values shown here are possibly random and not representative !
20920/// let result = hub.parents().get("fileId", "parentId")
20921/// .doit().await;
20922/// # }
20923/// ```
20924pub struct ParentGetCall<'a, C>
20925where
20926 C: 'a,
20927{
20928 hub: &'a DriveHub<C>,
20929 _file_id: String,
20930 _parent_id: String,
20931 _delegate: Option<&'a mut dyn common::Delegate>,
20932 _additional_params: HashMap<String, String>,
20933 _scopes: BTreeSet<String>,
20934}
20935
20936impl<'a, C> common::CallBuilder for ParentGetCall<'a, C> {}
20937
20938impl<'a, C> ParentGetCall<'a, C>
20939where
20940 C: common::Connector,
20941{
20942 /// Perform the operation you have build so far.
20943 pub async fn doit(mut self) -> common::Result<(common::Response, ParentReference)> {
20944 use std::borrow::Cow;
20945 use std::io::{Read, Seek};
20946
20947 use common::{url::Params, ToParts};
20948 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20949
20950 let mut dd = common::DefaultDelegate;
20951 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20952 dlg.begin(common::MethodInfo {
20953 id: "drive.parents.get",
20954 http_method: hyper::Method::GET,
20955 });
20956
20957 for &field in ["alt", "fileId", "parentId"].iter() {
20958 if self._additional_params.contains_key(field) {
20959 dlg.finished(false);
20960 return Err(common::Error::FieldClash(field));
20961 }
20962 }
20963
20964 let mut params = Params::with_capacity(4 + self._additional_params.len());
20965 params.push("fileId", self._file_id);
20966 params.push("parentId", self._parent_id);
20967
20968 params.extend(self._additional_params.iter());
20969
20970 params.push("alt", "json");
20971 let mut url = self.hub._base_url.clone() + "files/{fileId}/parents/{parentId}";
20972 if self._scopes.is_empty() {
20973 self._scopes
20974 .insert(Scope::MeetReadonly.as_ref().to_string());
20975 }
20976
20977 #[allow(clippy::single_element_loop)]
20978 for &(find_this, param_name) in [("{fileId}", "fileId"), ("{parentId}", "parentId")].iter()
20979 {
20980 url = params.uri_replacement(url, param_name, find_this, false);
20981 }
20982 {
20983 let to_remove = ["parentId", "fileId"];
20984 params.remove_params(&to_remove);
20985 }
20986
20987 let url = params.parse_with_url(&url);
20988
20989 loop {
20990 let token = match self
20991 .hub
20992 .auth
20993 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20994 .await
20995 {
20996 Ok(token) => token,
20997 Err(e) => match dlg.token(e) {
20998 Ok(token) => token,
20999 Err(e) => {
21000 dlg.finished(false);
21001 return Err(common::Error::MissingToken(e));
21002 }
21003 },
21004 };
21005 let mut req_result = {
21006 let client = &self.hub.client;
21007 dlg.pre_request();
21008 let mut req_builder = hyper::Request::builder()
21009 .method(hyper::Method::GET)
21010 .uri(url.as_str())
21011 .header(USER_AGENT, self.hub._user_agent.clone());
21012
21013 if let Some(token) = token.as_ref() {
21014 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21015 }
21016
21017 let request = req_builder
21018 .header(CONTENT_LENGTH, 0_u64)
21019 .body(common::to_body::<String>(None));
21020
21021 client.request(request.unwrap()).await
21022 };
21023
21024 match req_result {
21025 Err(err) => {
21026 if let common::Retry::After(d) = dlg.http_error(&err) {
21027 sleep(d).await;
21028 continue;
21029 }
21030 dlg.finished(false);
21031 return Err(common::Error::HttpError(err));
21032 }
21033 Ok(res) => {
21034 let (mut parts, body) = res.into_parts();
21035 let mut body = common::Body::new(body);
21036 if !parts.status.is_success() {
21037 let bytes = common::to_bytes(body).await.unwrap_or_default();
21038 let error = serde_json::from_str(&common::to_string(&bytes));
21039 let response = common::to_response(parts, bytes.into());
21040
21041 if let common::Retry::After(d) =
21042 dlg.http_failure(&response, error.as_ref().ok())
21043 {
21044 sleep(d).await;
21045 continue;
21046 }
21047
21048 dlg.finished(false);
21049
21050 return Err(match error {
21051 Ok(value) => common::Error::BadRequest(value),
21052 _ => common::Error::Failure(response),
21053 });
21054 }
21055 let response = {
21056 let bytes = common::to_bytes(body).await.unwrap_or_default();
21057 let encoded = common::to_string(&bytes);
21058 match serde_json::from_str(&encoded) {
21059 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21060 Err(error) => {
21061 dlg.response_json_decode_error(&encoded, &error);
21062 return Err(common::Error::JsonDecodeError(
21063 encoded.to_string(),
21064 error,
21065 ));
21066 }
21067 }
21068 };
21069
21070 dlg.finished(true);
21071 return Ok(response);
21072 }
21073 }
21074 }
21075 }
21076
21077 /// The ID of the file.
21078 ///
21079 /// Sets the *file id* path property to the given value.
21080 ///
21081 /// Even though the property as already been set when instantiating this call,
21082 /// we provide this method for API completeness.
21083 pub fn file_id(mut self, new_value: &str) -> ParentGetCall<'a, C> {
21084 self._file_id = new_value.to_string();
21085 self
21086 }
21087 /// The ID of the parent.
21088 ///
21089 /// Sets the *parent id* path property to the given value.
21090 ///
21091 /// Even though the property as already been set when instantiating this call,
21092 /// we provide this method for API completeness.
21093 pub fn parent_id(mut self, new_value: &str) -> ParentGetCall<'a, C> {
21094 self._parent_id = new_value.to_string();
21095 self
21096 }
21097 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21098 /// while executing the actual API request.
21099 ///
21100 /// ````text
21101 /// It should be used to handle progress information, and to implement a certain level of resilience.
21102 /// ````
21103 ///
21104 /// Sets the *delegate* property to the given value.
21105 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ParentGetCall<'a, C> {
21106 self._delegate = Some(new_value);
21107 self
21108 }
21109
21110 /// Set any additional parameter of the query string used in the request.
21111 /// It should be used to set parameters which are not yet available through their own
21112 /// setters.
21113 ///
21114 /// Please note that this method must not be used to set any of the known parameters
21115 /// which have their own setter method. If done anyway, the request will fail.
21116 ///
21117 /// # Additional Parameters
21118 ///
21119 /// * *$.xgafv* (query-string) - V1 error format.
21120 /// * *access_token* (query-string) - OAuth access token.
21121 /// * *alt* (query-string) - Data format for response.
21122 /// * *callback* (query-string) - JSONP
21123 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21124 /// * *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.
21125 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21126 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21127 /// * *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.
21128 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21129 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21130 pub fn param<T>(mut self, name: T, value: T) -> ParentGetCall<'a, C>
21131 where
21132 T: AsRef<str>,
21133 {
21134 self._additional_params
21135 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21136 self
21137 }
21138
21139 /// Identifies the authorization scope for the method you are building.
21140 ///
21141 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21142 /// [`Scope::MeetReadonly`].
21143 ///
21144 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21145 /// tokens for more than one scope.
21146 ///
21147 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21148 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21149 /// sufficient, a read-write scope will do as well.
21150 pub fn add_scope<St>(mut self, scope: St) -> ParentGetCall<'a, C>
21151 where
21152 St: AsRef<str>,
21153 {
21154 self._scopes.insert(String::from(scope.as_ref()));
21155 self
21156 }
21157 /// Identifies the authorization scope(s) for the method you are building.
21158 ///
21159 /// See [`Self::add_scope()`] for details.
21160 pub fn add_scopes<I, St>(mut self, scopes: I) -> ParentGetCall<'a, C>
21161 where
21162 I: IntoIterator<Item = St>,
21163 St: AsRef<str>,
21164 {
21165 self._scopes
21166 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21167 self
21168 }
21169
21170 /// Removes all scopes, and no default scope will be used either.
21171 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21172 /// for details).
21173 pub fn clear_scopes(mut self) -> ParentGetCall<'a, C> {
21174 self._scopes.clear();
21175 self
21176 }
21177}
21178
21179/// Adds a parent folder for a file.
21180///
21181/// A builder for the *insert* method supported by a *parent* resource.
21182/// It is not used directly, but through a [`ParentMethods`] instance.
21183///
21184/// # Example
21185///
21186/// Instantiate a resource method builder
21187///
21188/// ```test_harness,no_run
21189/// # extern crate hyper;
21190/// # extern crate hyper_rustls;
21191/// # extern crate google_drive2 as drive2;
21192/// use drive2::api::ParentReference;
21193/// # async fn dox() {
21194/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21195///
21196/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21197/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21198/// # .with_native_roots()
21199/// # .unwrap()
21200/// # .https_only()
21201/// # .enable_http2()
21202/// # .build();
21203///
21204/// # let executor = hyper_util::rt::TokioExecutor::new();
21205/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21206/// # secret,
21207/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21208/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21209/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21210/// # ),
21211/// # ).build().await.unwrap();
21212///
21213/// # let client = hyper_util::client::legacy::Client::builder(
21214/// # hyper_util::rt::TokioExecutor::new()
21215/// # )
21216/// # .build(
21217/// # hyper_rustls::HttpsConnectorBuilder::new()
21218/// # .with_native_roots()
21219/// # .unwrap()
21220/// # .https_or_http()
21221/// # .enable_http2()
21222/// # .build()
21223/// # );
21224/// # let mut hub = DriveHub::new(client, auth);
21225/// // As the method needs a request, you would usually fill it with the desired information
21226/// // into the respective structure. Some of the parts shown here might not be applicable !
21227/// // Values shown here are possibly random and not representative !
21228/// let mut req = ParentReference::default();
21229///
21230/// // You can configure optional parameters by calling the respective setters at will, and
21231/// // execute the final call using `doit()`.
21232/// // Values shown here are possibly random and not representative !
21233/// let result = hub.parents().insert(req, "fileId")
21234/// .supports_team_drives(false)
21235/// .supports_all_drives(false)
21236/// .enforce_single_parent(false)
21237/// .doit().await;
21238/// # }
21239/// ```
21240pub struct ParentInsertCall<'a, C>
21241where
21242 C: 'a,
21243{
21244 hub: &'a DriveHub<C>,
21245 _request: ParentReference,
21246 _file_id: String,
21247 _supports_team_drives: Option<bool>,
21248 _supports_all_drives: Option<bool>,
21249 _enforce_single_parent: Option<bool>,
21250 _delegate: Option<&'a mut dyn common::Delegate>,
21251 _additional_params: HashMap<String, String>,
21252 _scopes: BTreeSet<String>,
21253}
21254
21255impl<'a, C> common::CallBuilder for ParentInsertCall<'a, C> {}
21256
21257impl<'a, C> ParentInsertCall<'a, C>
21258where
21259 C: common::Connector,
21260{
21261 /// Perform the operation you have build so far.
21262 pub async fn doit(mut self) -> common::Result<(common::Response, ParentReference)> {
21263 use std::borrow::Cow;
21264 use std::io::{Read, Seek};
21265
21266 use common::{url::Params, ToParts};
21267 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21268
21269 let mut dd = common::DefaultDelegate;
21270 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21271 dlg.begin(common::MethodInfo {
21272 id: "drive.parents.insert",
21273 http_method: hyper::Method::POST,
21274 });
21275
21276 for &field in [
21277 "alt",
21278 "fileId",
21279 "supportsTeamDrives",
21280 "supportsAllDrives",
21281 "enforceSingleParent",
21282 ]
21283 .iter()
21284 {
21285 if self._additional_params.contains_key(field) {
21286 dlg.finished(false);
21287 return Err(common::Error::FieldClash(field));
21288 }
21289 }
21290
21291 let mut params = Params::with_capacity(7 + self._additional_params.len());
21292 params.push("fileId", self._file_id);
21293 if let Some(value) = self._supports_team_drives.as_ref() {
21294 params.push("supportsTeamDrives", value.to_string());
21295 }
21296 if let Some(value) = self._supports_all_drives.as_ref() {
21297 params.push("supportsAllDrives", value.to_string());
21298 }
21299 if let Some(value) = self._enforce_single_parent.as_ref() {
21300 params.push("enforceSingleParent", value.to_string());
21301 }
21302
21303 params.extend(self._additional_params.iter());
21304
21305 params.push("alt", "json");
21306 let mut url = self.hub._base_url.clone() + "files/{fileId}/parents";
21307 if self._scopes.is_empty() {
21308 self._scopes.insert(Scope::Full.as_ref().to_string());
21309 }
21310
21311 #[allow(clippy::single_element_loop)]
21312 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
21313 url = params.uri_replacement(url, param_name, find_this, false);
21314 }
21315 {
21316 let to_remove = ["fileId"];
21317 params.remove_params(&to_remove);
21318 }
21319
21320 let url = params.parse_with_url(&url);
21321
21322 let mut json_mime_type = mime::APPLICATION_JSON;
21323 let mut request_value_reader = {
21324 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21325 common::remove_json_null_values(&mut value);
21326 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21327 serde_json::to_writer(&mut dst, &value).unwrap();
21328 dst
21329 };
21330 let request_size = request_value_reader
21331 .seek(std::io::SeekFrom::End(0))
21332 .unwrap();
21333 request_value_reader
21334 .seek(std::io::SeekFrom::Start(0))
21335 .unwrap();
21336
21337 loop {
21338 let token = match self
21339 .hub
21340 .auth
21341 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21342 .await
21343 {
21344 Ok(token) => token,
21345 Err(e) => match dlg.token(e) {
21346 Ok(token) => token,
21347 Err(e) => {
21348 dlg.finished(false);
21349 return Err(common::Error::MissingToken(e));
21350 }
21351 },
21352 };
21353 request_value_reader
21354 .seek(std::io::SeekFrom::Start(0))
21355 .unwrap();
21356 let mut req_result = {
21357 let client = &self.hub.client;
21358 dlg.pre_request();
21359 let mut req_builder = hyper::Request::builder()
21360 .method(hyper::Method::POST)
21361 .uri(url.as_str())
21362 .header(USER_AGENT, self.hub._user_agent.clone());
21363
21364 if let Some(token) = token.as_ref() {
21365 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21366 }
21367
21368 let request = req_builder
21369 .header(CONTENT_TYPE, json_mime_type.to_string())
21370 .header(CONTENT_LENGTH, request_size as u64)
21371 .body(common::to_body(
21372 request_value_reader.get_ref().clone().into(),
21373 ));
21374
21375 client.request(request.unwrap()).await
21376 };
21377
21378 match req_result {
21379 Err(err) => {
21380 if let common::Retry::After(d) = dlg.http_error(&err) {
21381 sleep(d).await;
21382 continue;
21383 }
21384 dlg.finished(false);
21385 return Err(common::Error::HttpError(err));
21386 }
21387 Ok(res) => {
21388 let (mut parts, body) = res.into_parts();
21389 let mut body = common::Body::new(body);
21390 if !parts.status.is_success() {
21391 let bytes = common::to_bytes(body).await.unwrap_or_default();
21392 let error = serde_json::from_str(&common::to_string(&bytes));
21393 let response = common::to_response(parts, bytes.into());
21394
21395 if let common::Retry::After(d) =
21396 dlg.http_failure(&response, error.as_ref().ok())
21397 {
21398 sleep(d).await;
21399 continue;
21400 }
21401
21402 dlg.finished(false);
21403
21404 return Err(match error {
21405 Ok(value) => common::Error::BadRequest(value),
21406 _ => common::Error::Failure(response),
21407 });
21408 }
21409 let response = {
21410 let bytes = common::to_bytes(body).await.unwrap_or_default();
21411 let encoded = common::to_string(&bytes);
21412 match serde_json::from_str(&encoded) {
21413 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21414 Err(error) => {
21415 dlg.response_json_decode_error(&encoded, &error);
21416 return Err(common::Error::JsonDecodeError(
21417 encoded.to_string(),
21418 error,
21419 ));
21420 }
21421 }
21422 };
21423
21424 dlg.finished(true);
21425 return Ok(response);
21426 }
21427 }
21428 }
21429 }
21430
21431 ///
21432 /// Sets the *request* property to the given value.
21433 ///
21434 /// Even though the property as already been set when instantiating this call,
21435 /// we provide this method for API completeness.
21436 pub fn request(mut self, new_value: ParentReference) -> ParentInsertCall<'a, C> {
21437 self._request = new_value;
21438 self
21439 }
21440 /// The ID of the file.
21441 ///
21442 /// Sets the *file id* path property to the given value.
21443 ///
21444 /// Even though the property as already been set when instantiating this call,
21445 /// we provide this method for API completeness.
21446 pub fn file_id(mut self, new_value: &str) -> ParentInsertCall<'a, C> {
21447 self._file_id = new_value.to_string();
21448 self
21449 }
21450 /// Deprecated: Use `supportsAllDrives` instead.
21451 ///
21452 /// Sets the *supports team drives* query property to the given value.
21453 pub fn supports_team_drives(mut self, new_value: bool) -> ParentInsertCall<'a, C> {
21454 self._supports_team_drives = Some(new_value);
21455 self
21456 }
21457 /// Whether the requesting application supports both My Drives and shared drives.
21458 ///
21459 /// Sets the *supports all drives* query property to the given value.
21460 pub fn supports_all_drives(mut self, new_value: bool) -> ParentInsertCall<'a, C> {
21461 self._supports_all_drives = Some(new_value);
21462 self
21463 }
21464 /// Deprecated: Adding files to multiple folders is no longer supported. Use `shortcuts` instead.
21465 ///
21466 /// Sets the *enforce single parent* query property to the given value.
21467 pub fn enforce_single_parent(mut self, new_value: bool) -> ParentInsertCall<'a, C> {
21468 self._enforce_single_parent = Some(new_value);
21469 self
21470 }
21471 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21472 /// while executing the actual API request.
21473 ///
21474 /// ````text
21475 /// It should be used to handle progress information, and to implement a certain level of resilience.
21476 /// ````
21477 ///
21478 /// Sets the *delegate* property to the given value.
21479 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ParentInsertCall<'a, C> {
21480 self._delegate = Some(new_value);
21481 self
21482 }
21483
21484 /// Set any additional parameter of the query string used in the request.
21485 /// It should be used to set parameters which are not yet available through their own
21486 /// setters.
21487 ///
21488 /// Please note that this method must not be used to set any of the known parameters
21489 /// which have their own setter method. If done anyway, the request will fail.
21490 ///
21491 /// # Additional Parameters
21492 ///
21493 /// * *$.xgafv* (query-string) - V1 error format.
21494 /// * *access_token* (query-string) - OAuth access token.
21495 /// * *alt* (query-string) - Data format for response.
21496 /// * *callback* (query-string) - JSONP
21497 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21498 /// * *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.
21499 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21500 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21501 /// * *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.
21502 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21503 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21504 pub fn param<T>(mut self, name: T, value: T) -> ParentInsertCall<'a, C>
21505 where
21506 T: AsRef<str>,
21507 {
21508 self._additional_params
21509 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21510 self
21511 }
21512
21513 /// Identifies the authorization scope for the method you are building.
21514 ///
21515 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21516 /// [`Scope::Full`].
21517 ///
21518 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21519 /// tokens for more than one scope.
21520 ///
21521 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21522 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21523 /// sufficient, a read-write scope will do as well.
21524 pub fn add_scope<St>(mut self, scope: St) -> ParentInsertCall<'a, C>
21525 where
21526 St: AsRef<str>,
21527 {
21528 self._scopes.insert(String::from(scope.as_ref()));
21529 self
21530 }
21531 /// Identifies the authorization scope(s) for the method you are building.
21532 ///
21533 /// See [`Self::add_scope()`] for details.
21534 pub fn add_scopes<I, St>(mut self, scopes: I) -> ParentInsertCall<'a, C>
21535 where
21536 I: IntoIterator<Item = St>,
21537 St: AsRef<str>,
21538 {
21539 self._scopes
21540 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21541 self
21542 }
21543
21544 /// Removes all scopes, and no default scope will be used either.
21545 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21546 /// for details).
21547 pub fn clear_scopes(mut self) -> ParentInsertCall<'a, C> {
21548 self._scopes.clear();
21549 self
21550 }
21551}
21552
21553/// Lists a file's parents.
21554///
21555/// A builder for the *list* method supported by a *parent* resource.
21556/// It is not used directly, but through a [`ParentMethods`] instance.
21557///
21558/// # Example
21559///
21560/// Instantiate a resource method builder
21561///
21562/// ```test_harness,no_run
21563/// # extern crate hyper;
21564/// # extern crate hyper_rustls;
21565/// # extern crate google_drive2 as drive2;
21566/// # async fn dox() {
21567/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21568///
21569/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21570/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21571/// # .with_native_roots()
21572/// # .unwrap()
21573/// # .https_only()
21574/// # .enable_http2()
21575/// # .build();
21576///
21577/// # let executor = hyper_util::rt::TokioExecutor::new();
21578/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21579/// # secret,
21580/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21581/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21582/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21583/// # ),
21584/// # ).build().await.unwrap();
21585///
21586/// # let client = hyper_util::client::legacy::Client::builder(
21587/// # hyper_util::rt::TokioExecutor::new()
21588/// # )
21589/// # .build(
21590/// # hyper_rustls::HttpsConnectorBuilder::new()
21591/// # .with_native_roots()
21592/// # .unwrap()
21593/// # .https_or_http()
21594/// # .enable_http2()
21595/// # .build()
21596/// # );
21597/// # let mut hub = DriveHub::new(client, auth);
21598/// // You can configure optional parameters by calling the respective setters at will, and
21599/// // execute the final call using `doit()`.
21600/// // Values shown here are possibly random and not representative !
21601/// let result = hub.parents().list("fileId")
21602/// .doit().await;
21603/// # }
21604/// ```
21605pub struct ParentListCall<'a, C>
21606where
21607 C: 'a,
21608{
21609 hub: &'a DriveHub<C>,
21610 _file_id: String,
21611 _delegate: Option<&'a mut dyn common::Delegate>,
21612 _additional_params: HashMap<String, String>,
21613 _scopes: BTreeSet<String>,
21614}
21615
21616impl<'a, C> common::CallBuilder for ParentListCall<'a, C> {}
21617
21618impl<'a, C> ParentListCall<'a, C>
21619where
21620 C: common::Connector,
21621{
21622 /// Perform the operation you have build so far.
21623 pub async fn doit(mut self) -> common::Result<(common::Response, ParentList)> {
21624 use std::borrow::Cow;
21625 use std::io::{Read, Seek};
21626
21627 use common::{url::Params, ToParts};
21628 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21629
21630 let mut dd = common::DefaultDelegate;
21631 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21632 dlg.begin(common::MethodInfo {
21633 id: "drive.parents.list",
21634 http_method: hyper::Method::GET,
21635 });
21636
21637 for &field in ["alt", "fileId"].iter() {
21638 if self._additional_params.contains_key(field) {
21639 dlg.finished(false);
21640 return Err(common::Error::FieldClash(field));
21641 }
21642 }
21643
21644 let mut params = Params::with_capacity(3 + self._additional_params.len());
21645 params.push("fileId", self._file_id);
21646
21647 params.extend(self._additional_params.iter());
21648
21649 params.push("alt", "json");
21650 let mut url = self.hub._base_url.clone() + "files/{fileId}/parents";
21651 if self._scopes.is_empty() {
21652 self._scopes
21653 .insert(Scope::MeetReadonly.as_ref().to_string());
21654 }
21655
21656 #[allow(clippy::single_element_loop)]
21657 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
21658 url = params.uri_replacement(url, param_name, find_this, false);
21659 }
21660 {
21661 let to_remove = ["fileId"];
21662 params.remove_params(&to_remove);
21663 }
21664
21665 let url = params.parse_with_url(&url);
21666
21667 loop {
21668 let token = match self
21669 .hub
21670 .auth
21671 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21672 .await
21673 {
21674 Ok(token) => token,
21675 Err(e) => match dlg.token(e) {
21676 Ok(token) => token,
21677 Err(e) => {
21678 dlg.finished(false);
21679 return Err(common::Error::MissingToken(e));
21680 }
21681 },
21682 };
21683 let mut req_result = {
21684 let client = &self.hub.client;
21685 dlg.pre_request();
21686 let mut req_builder = hyper::Request::builder()
21687 .method(hyper::Method::GET)
21688 .uri(url.as_str())
21689 .header(USER_AGENT, self.hub._user_agent.clone());
21690
21691 if let Some(token) = token.as_ref() {
21692 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21693 }
21694
21695 let request = req_builder
21696 .header(CONTENT_LENGTH, 0_u64)
21697 .body(common::to_body::<String>(None));
21698
21699 client.request(request.unwrap()).await
21700 };
21701
21702 match req_result {
21703 Err(err) => {
21704 if let common::Retry::After(d) = dlg.http_error(&err) {
21705 sleep(d).await;
21706 continue;
21707 }
21708 dlg.finished(false);
21709 return Err(common::Error::HttpError(err));
21710 }
21711 Ok(res) => {
21712 let (mut parts, body) = res.into_parts();
21713 let mut body = common::Body::new(body);
21714 if !parts.status.is_success() {
21715 let bytes = common::to_bytes(body).await.unwrap_or_default();
21716 let error = serde_json::from_str(&common::to_string(&bytes));
21717 let response = common::to_response(parts, bytes.into());
21718
21719 if let common::Retry::After(d) =
21720 dlg.http_failure(&response, error.as_ref().ok())
21721 {
21722 sleep(d).await;
21723 continue;
21724 }
21725
21726 dlg.finished(false);
21727
21728 return Err(match error {
21729 Ok(value) => common::Error::BadRequest(value),
21730 _ => common::Error::Failure(response),
21731 });
21732 }
21733 let response = {
21734 let bytes = common::to_bytes(body).await.unwrap_or_default();
21735 let encoded = common::to_string(&bytes);
21736 match serde_json::from_str(&encoded) {
21737 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21738 Err(error) => {
21739 dlg.response_json_decode_error(&encoded, &error);
21740 return Err(common::Error::JsonDecodeError(
21741 encoded.to_string(),
21742 error,
21743 ));
21744 }
21745 }
21746 };
21747
21748 dlg.finished(true);
21749 return Ok(response);
21750 }
21751 }
21752 }
21753 }
21754
21755 /// The ID of the file.
21756 ///
21757 /// Sets the *file id* path property to the given value.
21758 ///
21759 /// Even though the property as already been set when instantiating this call,
21760 /// we provide this method for API completeness.
21761 pub fn file_id(mut self, new_value: &str) -> ParentListCall<'a, C> {
21762 self._file_id = new_value.to_string();
21763 self
21764 }
21765 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21766 /// while executing the actual API request.
21767 ///
21768 /// ````text
21769 /// It should be used to handle progress information, and to implement a certain level of resilience.
21770 /// ````
21771 ///
21772 /// Sets the *delegate* property to the given value.
21773 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ParentListCall<'a, C> {
21774 self._delegate = Some(new_value);
21775 self
21776 }
21777
21778 /// Set any additional parameter of the query string used in the request.
21779 /// It should be used to set parameters which are not yet available through their own
21780 /// setters.
21781 ///
21782 /// Please note that this method must not be used to set any of the known parameters
21783 /// which have their own setter method. If done anyway, the request will fail.
21784 ///
21785 /// # Additional Parameters
21786 ///
21787 /// * *$.xgafv* (query-string) - V1 error format.
21788 /// * *access_token* (query-string) - OAuth access token.
21789 /// * *alt* (query-string) - Data format for response.
21790 /// * *callback* (query-string) - JSONP
21791 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21792 /// * *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.
21793 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21794 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21795 /// * *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.
21796 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21797 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21798 pub fn param<T>(mut self, name: T, value: T) -> ParentListCall<'a, C>
21799 where
21800 T: AsRef<str>,
21801 {
21802 self._additional_params
21803 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21804 self
21805 }
21806
21807 /// Identifies the authorization scope for the method you are building.
21808 ///
21809 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21810 /// [`Scope::MeetReadonly`].
21811 ///
21812 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21813 /// tokens for more than one scope.
21814 ///
21815 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21816 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21817 /// sufficient, a read-write scope will do as well.
21818 pub fn add_scope<St>(mut self, scope: St) -> ParentListCall<'a, C>
21819 where
21820 St: AsRef<str>,
21821 {
21822 self._scopes.insert(String::from(scope.as_ref()));
21823 self
21824 }
21825 /// Identifies the authorization scope(s) for the method you are building.
21826 ///
21827 /// See [`Self::add_scope()`] for details.
21828 pub fn add_scopes<I, St>(mut self, scopes: I) -> ParentListCall<'a, C>
21829 where
21830 I: IntoIterator<Item = St>,
21831 St: AsRef<str>,
21832 {
21833 self._scopes
21834 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21835 self
21836 }
21837
21838 /// Removes all scopes, and no default scope will be used either.
21839 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21840 /// for details).
21841 pub fn clear_scopes(mut self) -> ParentListCall<'a, C> {
21842 self._scopes.clear();
21843 self
21844 }
21845}
21846
21847/// 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.
21848///
21849/// A builder for the *delete* method supported by a *permission* resource.
21850/// It is not used directly, but through a [`PermissionMethods`] instance.
21851///
21852/// # Example
21853///
21854/// Instantiate a resource method builder
21855///
21856/// ```test_harness,no_run
21857/// # extern crate hyper;
21858/// # extern crate hyper_rustls;
21859/// # extern crate google_drive2 as drive2;
21860/// # async fn dox() {
21861/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21862///
21863/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21864/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21865/// # .with_native_roots()
21866/// # .unwrap()
21867/// # .https_only()
21868/// # .enable_http2()
21869/// # .build();
21870///
21871/// # let executor = hyper_util::rt::TokioExecutor::new();
21872/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21873/// # secret,
21874/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21875/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21876/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21877/// # ),
21878/// # ).build().await.unwrap();
21879///
21880/// # let client = hyper_util::client::legacy::Client::builder(
21881/// # hyper_util::rt::TokioExecutor::new()
21882/// # )
21883/// # .build(
21884/// # hyper_rustls::HttpsConnectorBuilder::new()
21885/// # .with_native_roots()
21886/// # .unwrap()
21887/// # .https_or_http()
21888/// # .enable_http2()
21889/// # .build()
21890/// # );
21891/// # let mut hub = DriveHub::new(client, auth);
21892/// // You can configure optional parameters by calling the respective setters at will, and
21893/// // execute the final call using `doit()`.
21894/// // Values shown here are possibly random and not representative !
21895/// let result = hub.permissions().delete("fileId", "permissionId")
21896/// .use_domain_admin_access(true)
21897/// .supports_team_drives(true)
21898/// .supports_all_drives(true)
21899/// .enforce_expansive_access(false)
21900/// .doit().await;
21901/// # }
21902/// ```
21903pub struct PermissionDeleteCall<'a, C>
21904where
21905 C: 'a,
21906{
21907 hub: &'a DriveHub<C>,
21908 _file_id: String,
21909 _permission_id: String,
21910 _use_domain_admin_access: Option<bool>,
21911 _supports_team_drives: Option<bool>,
21912 _supports_all_drives: Option<bool>,
21913 _enforce_expansive_access: Option<bool>,
21914 _delegate: Option<&'a mut dyn common::Delegate>,
21915 _additional_params: HashMap<String, String>,
21916 _scopes: BTreeSet<String>,
21917}
21918
21919impl<'a, C> common::CallBuilder for PermissionDeleteCall<'a, C> {}
21920
21921impl<'a, C> PermissionDeleteCall<'a, C>
21922where
21923 C: common::Connector,
21924{
21925 /// Perform the operation you have build so far.
21926 pub async fn doit(mut self) -> common::Result<common::Response> {
21927 use std::borrow::Cow;
21928 use std::io::{Read, Seek};
21929
21930 use common::{url::Params, ToParts};
21931 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21932
21933 let mut dd = common::DefaultDelegate;
21934 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21935 dlg.begin(common::MethodInfo {
21936 id: "drive.permissions.delete",
21937 http_method: hyper::Method::DELETE,
21938 });
21939
21940 for &field in [
21941 "fileId",
21942 "permissionId",
21943 "useDomainAdminAccess",
21944 "supportsTeamDrives",
21945 "supportsAllDrives",
21946 "enforceExpansiveAccess",
21947 ]
21948 .iter()
21949 {
21950 if self._additional_params.contains_key(field) {
21951 dlg.finished(false);
21952 return Err(common::Error::FieldClash(field));
21953 }
21954 }
21955
21956 let mut params = Params::with_capacity(7 + self._additional_params.len());
21957 params.push("fileId", self._file_id);
21958 params.push("permissionId", self._permission_id);
21959 if let Some(value) = self._use_domain_admin_access.as_ref() {
21960 params.push("useDomainAdminAccess", value.to_string());
21961 }
21962 if let Some(value) = self._supports_team_drives.as_ref() {
21963 params.push("supportsTeamDrives", value.to_string());
21964 }
21965 if let Some(value) = self._supports_all_drives.as_ref() {
21966 params.push("supportsAllDrives", value.to_string());
21967 }
21968 if let Some(value) = self._enforce_expansive_access.as_ref() {
21969 params.push("enforceExpansiveAccess", value.to_string());
21970 }
21971
21972 params.extend(self._additional_params.iter());
21973
21974 let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}";
21975 if self._scopes.is_empty() {
21976 self._scopes.insert(Scope::Full.as_ref().to_string());
21977 }
21978
21979 #[allow(clippy::single_element_loop)]
21980 for &(find_this, param_name) in
21981 [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter()
21982 {
21983 url = params.uri_replacement(url, param_name, find_this, false);
21984 }
21985 {
21986 let to_remove = ["permissionId", "fileId"];
21987 params.remove_params(&to_remove);
21988 }
21989
21990 let url = params.parse_with_url(&url);
21991
21992 loop {
21993 let token = match self
21994 .hub
21995 .auth
21996 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21997 .await
21998 {
21999 Ok(token) => token,
22000 Err(e) => match dlg.token(e) {
22001 Ok(token) => token,
22002 Err(e) => {
22003 dlg.finished(false);
22004 return Err(common::Error::MissingToken(e));
22005 }
22006 },
22007 };
22008 let mut req_result = {
22009 let client = &self.hub.client;
22010 dlg.pre_request();
22011 let mut req_builder = hyper::Request::builder()
22012 .method(hyper::Method::DELETE)
22013 .uri(url.as_str())
22014 .header(USER_AGENT, self.hub._user_agent.clone());
22015
22016 if let Some(token) = token.as_ref() {
22017 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22018 }
22019
22020 let request = req_builder
22021 .header(CONTENT_LENGTH, 0_u64)
22022 .body(common::to_body::<String>(None));
22023
22024 client.request(request.unwrap()).await
22025 };
22026
22027 match req_result {
22028 Err(err) => {
22029 if let common::Retry::After(d) = dlg.http_error(&err) {
22030 sleep(d).await;
22031 continue;
22032 }
22033 dlg.finished(false);
22034 return Err(common::Error::HttpError(err));
22035 }
22036 Ok(res) => {
22037 let (mut parts, body) = res.into_parts();
22038 let mut body = common::Body::new(body);
22039 if !parts.status.is_success() {
22040 let bytes = common::to_bytes(body).await.unwrap_or_default();
22041 let error = serde_json::from_str(&common::to_string(&bytes));
22042 let response = common::to_response(parts, bytes.into());
22043
22044 if let common::Retry::After(d) =
22045 dlg.http_failure(&response, error.as_ref().ok())
22046 {
22047 sleep(d).await;
22048 continue;
22049 }
22050
22051 dlg.finished(false);
22052
22053 return Err(match error {
22054 Ok(value) => common::Error::BadRequest(value),
22055 _ => common::Error::Failure(response),
22056 });
22057 }
22058 let response = common::Response::from_parts(parts, body);
22059
22060 dlg.finished(true);
22061 return Ok(response);
22062 }
22063 }
22064 }
22065 }
22066
22067 /// The ID for the file or shared drive.
22068 ///
22069 /// Sets the *file id* path property to the given value.
22070 ///
22071 /// Even though the property as already been set when instantiating this call,
22072 /// we provide this method for API completeness.
22073 pub fn file_id(mut self, new_value: &str) -> PermissionDeleteCall<'a, C> {
22074 self._file_id = new_value.to_string();
22075 self
22076 }
22077 /// The ID for the permission.
22078 ///
22079 /// Sets the *permission id* path property to the given value.
22080 ///
22081 /// Even though the property as already been set when instantiating this call,
22082 /// we provide this method for API completeness.
22083 pub fn permission_id(mut self, new_value: &str) -> PermissionDeleteCall<'a, C> {
22084 self._permission_id = new_value.to_string();
22085 self
22086 }
22087 /// 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.
22088 ///
22089 /// Sets the *use domain admin access* query property to the given value.
22090 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionDeleteCall<'a, C> {
22091 self._use_domain_admin_access = Some(new_value);
22092 self
22093 }
22094 /// Deprecated: Use `supportsAllDrives` instead.
22095 ///
22096 /// Sets the *supports team drives* query property to the given value.
22097 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionDeleteCall<'a, C> {
22098 self._supports_team_drives = Some(new_value);
22099 self
22100 }
22101 /// Whether the requesting application supports both My Drives and shared drives.
22102 ///
22103 /// Sets the *supports all drives* query property to the given value.
22104 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionDeleteCall<'a, C> {
22105 self._supports_all_drives = Some(new_value);
22106 self
22107 }
22108 /// Whether the request should enforce expansive access rules.
22109 ///
22110 /// Sets the *enforce expansive access* query property to the given value.
22111 pub fn enforce_expansive_access(mut self, new_value: bool) -> PermissionDeleteCall<'a, C> {
22112 self._enforce_expansive_access = Some(new_value);
22113 self
22114 }
22115 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22116 /// while executing the actual API request.
22117 ///
22118 /// ````text
22119 /// It should be used to handle progress information, and to implement a certain level of resilience.
22120 /// ````
22121 ///
22122 /// Sets the *delegate* property to the given value.
22123 pub fn delegate(
22124 mut self,
22125 new_value: &'a mut dyn common::Delegate,
22126 ) -> PermissionDeleteCall<'a, C> {
22127 self._delegate = Some(new_value);
22128 self
22129 }
22130
22131 /// Set any additional parameter of the query string used in the request.
22132 /// It should be used to set parameters which are not yet available through their own
22133 /// setters.
22134 ///
22135 /// Please note that this method must not be used to set any of the known parameters
22136 /// which have their own setter method. If done anyway, the request will fail.
22137 ///
22138 /// # Additional Parameters
22139 ///
22140 /// * *$.xgafv* (query-string) - V1 error format.
22141 /// * *access_token* (query-string) - OAuth access token.
22142 /// * *alt* (query-string) - Data format for response.
22143 /// * *callback* (query-string) - JSONP
22144 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22145 /// * *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.
22146 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22147 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22148 /// * *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.
22149 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22150 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22151 pub fn param<T>(mut self, name: T, value: T) -> PermissionDeleteCall<'a, C>
22152 where
22153 T: AsRef<str>,
22154 {
22155 self._additional_params
22156 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22157 self
22158 }
22159
22160 /// Identifies the authorization scope for the method you are building.
22161 ///
22162 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22163 /// [`Scope::Full`].
22164 ///
22165 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22166 /// tokens for more than one scope.
22167 ///
22168 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22169 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22170 /// sufficient, a read-write scope will do as well.
22171 pub fn add_scope<St>(mut self, scope: St) -> PermissionDeleteCall<'a, C>
22172 where
22173 St: AsRef<str>,
22174 {
22175 self._scopes.insert(String::from(scope.as_ref()));
22176 self
22177 }
22178 /// Identifies the authorization scope(s) for the method you are building.
22179 ///
22180 /// See [`Self::add_scope()`] for details.
22181 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionDeleteCall<'a, C>
22182 where
22183 I: IntoIterator<Item = St>,
22184 St: AsRef<str>,
22185 {
22186 self._scopes
22187 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22188 self
22189 }
22190
22191 /// Removes all scopes, and no default scope will be used either.
22192 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22193 /// for details).
22194 pub fn clear_scopes(mut self) -> PermissionDeleteCall<'a, C> {
22195 self._scopes.clear();
22196 self
22197 }
22198}
22199
22200/// Gets a permission by ID.
22201///
22202/// A builder for the *get* method supported by a *permission* resource.
22203/// It is not used directly, but through a [`PermissionMethods`] instance.
22204///
22205/// # Example
22206///
22207/// Instantiate a resource method builder
22208///
22209/// ```test_harness,no_run
22210/// # extern crate hyper;
22211/// # extern crate hyper_rustls;
22212/// # extern crate google_drive2 as drive2;
22213/// # async fn dox() {
22214/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22215///
22216/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22217/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22218/// # .with_native_roots()
22219/// # .unwrap()
22220/// # .https_only()
22221/// # .enable_http2()
22222/// # .build();
22223///
22224/// # let executor = hyper_util::rt::TokioExecutor::new();
22225/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22226/// # secret,
22227/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22228/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22229/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22230/// # ),
22231/// # ).build().await.unwrap();
22232///
22233/// # let client = hyper_util::client::legacy::Client::builder(
22234/// # hyper_util::rt::TokioExecutor::new()
22235/// # )
22236/// # .build(
22237/// # hyper_rustls::HttpsConnectorBuilder::new()
22238/// # .with_native_roots()
22239/// # .unwrap()
22240/// # .https_or_http()
22241/// # .enable_http2()
22242/// # .build()
22243/// # );
22244/// # let mut hub = DriveHub::new(client, auth);
22245/// // You can configure optional parameters by calling the respective setters at will, and
22246/// // execute the final call using `doit()`.
22247/// // Values shown here are possibly random and not representative !
22248/// let result = hub.permissions().get("fileId", "permissionId")
22249/// .use_domain_admin_access(false)
22250/// .supports_team_drives(false)
22251/// .supports_all_drives(false)
22252/// .doit().await;
22253/// # }
22254/// ```
22255pub struct PermissionGetCall<'a, C>
22256where
22257 C: 'a,
22258{
22259 hub: &'a DriveHub<C>,
22260 _file_id: String,
22261 _permission_id: String,
22262 _use_domain_admin_access: Option<bool>,
22263 _supports_team_drives: Option<bool>,
22264 _supports_all_drives: Option<bool>,
22265 _delegate: Option<&'a mut dyn common::Delegate>,
22266 _additional_params: HashMap<String, String>,
22267 _scopes: BTreeSet<String>,
22268}
22269
22270impl<'a, C> common::CallBuilder for PermissionGetCall<'a, C> {}
22271
22272impl<'a, C> PermissionGetCall<'a, C>
22273where
22274 C: common::Connector,
22275{
22276 /// Perform the operation you have build so far.
22277 pub async fn doit(mut self) -> common::Result<(common::Response, Permission)> {
22278 use std::borrow::Cow;
22279 use std::io::{Read, Seek};
22280
22281 use common::{url::Params, ToParts};
22282 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22283
22284 let mut dd = common::DefaultDelegate;
22285 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22286 dlg.begin(common::MethodInfo {
22287 id: "drive.permissions.get",
22288 http_method: hyper::Method::GET,
22289 });
22290
22291 for &field in [
22292 "alt",
22293 "fileId",
22294 "permissionId",
22295 "useDomainAdminAccess",
22296 "supportsTeamDrives",
22297 "supportsAllDrives",
22298 ]
22299 .iter()
22300 {
22301 if self._additional_params.contains_key(field) {
22302 dlg.finished(false);
22303 return Err(common::Error::FieldClash(field));
22304 }
22305 }
22306
22307 let mut params = Params::with_capacity(7 + self._additional_params.len());
22308 params.push("fileId", self._file_id);
22309 params.push("permissionId", self._permission_id);
22310 if let Some(value) = self._use_domain_admin_access.as_ref() {
22311 params.push("useDomainAdminAccess", value.to_string());
22312 }
22313 if let Some(value) = self._supports_team_drives.as_ref() {
22314 params.push("supportsTeamDrives", value.to_string());
22315 }
22316 if let Some(value) = self._supports_all_drives.as_ref() {
22317 params.push("supportsAllDrives", value.to_string());
22318 }
22319
22320 params.extend(self._additional_params.iter());
22321
22322 params.push("alt", "json");
22323 let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}";
22324 if self._scopes.is_empty() {
22325 self._scopes
22326 .insert(Scope::MeetReadonly.as_ref().to_string());
22327 }
22328
22329 #[allow(clippy::single_element_loop)]
22330 for &(find_this, param_name) in
22331 [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter()
22332 {
22333 url = params.uri_replacement(url, param_name, find_this, false);
22334 }
22335 {
22336 let to_remove = ["permissionId", "fileId"];
22337 params.remove_params(&to_remove);
22338 }
22339
22340 let url = params.parse_with_url(&url);
22341
22342 loop {
22343 let token = match self
22344 .hub
22345 .auth
22346 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22347 .await
22348 {
22349 Ok(token) => token,
22350 Err(e) => match dlg.token(e) {
22351 Ok(token) => token,
22352 Err(e) => {
22353 dlg.finished(false);
22354 return Err(common::Error::MissingToken(e));
22355 }
22356 },
22357 };
22358 let mut req_result = {
22359 let client = &self.hub.client;
22360 dlg.pre_request();
22361 let mut req_builder = hyper::Request::builder()
22362 .method(hyper::Method::GET)
22363 .uri(url.as_str())
22364 .header(USER_AGENT, self.hub._user_agent.clone());
22365
22366 if let Some(token) = token.as_ref() {
22367 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22368 }
22369
22370 let request = req_builder
22371 .header(CONTENT_LENGTH, 0_u64)
22372 .body(common::to_body::<String>(None));
22373
22374 client.request(request.unwrap()).await
22375 };
22376
22377 match req_result {
22378 Err(err) => {
22379 if let common::Retry::After(d) = dlg.http_error(&err) {
22380 sleep(d).await;
22381 continue;
22382 }
22383 dlg.finished(false);
22384 return Err(common::Error::HttpError(err));
22385 }
22386 Ok(res) => {
22387 let (mut parts, body) = res.into_parts();
22388 let mut body = common::Body::new(body);
22389 if !parts.status.is_success() {
22390 let bytes = common::to_bytes(body).await.unwrap_or_default();
22391 let error = serde_json::from_str(&common::to_string(&bytes));
22392 let response = common::to_response(parts, bytes.into());
22393
22394 if let common::Retry::After(d) =
22395 dlg.http_failure(&response, error.as_ref().ok())
22396 {
22397 sleep(d).await;
22398 continue;
22399 }
22400
22401 dlg.finished(false);
22402
22403 return Err(match error {
22404 Ok(value) => common::Error::BadRequest(value),
22405 _ => common::Error::Failure(response),
22406 });
22407 }
22408 let response = {
22409 let bytes = common::to_bytes(body).await.unwrap_or_default();
22410 let encoded = common::to_string(&bytes);
22411 match serde_json::from_str(&encoded) {
22412 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22413 Err(error) => {
22414 dlg.response_json_decode_error(&encoded, &error);
22415 return Err(common::Error::JsonDecodeError(
22416 encoded.to_string(),
22417 error,
22418 ));
22419 }
22420 }
22421 };
22422
22423 dlg.finished(true);
22424 return Ok(response);
22425 }
22426 }
22427 }
22428 }
22429
22430 /// The ID for the file or shared drive.
22431 ///
22432 /// Sets the *file id* path property to the given value.
22433 ///
22434 /// Even though the property as already been set when instantiating this call,
22435 /// we provide this method for API completeness.
22436 pub fn file_id(mut self, new_value: &str) -> PermissionGetCall<'a, C> {
22437 self._file_id = new_value.to_string();
22438 self
22439 }
22440 /// The ID for the permission.
22441 ///
22442 /// Sets the *permission id* path property to the given value.
22443 ///
22444 /// Even though the property as already been set when instantiating this call,
22445 /// we provide this method for API completeness.
22446 pub fn permission_id(mut self, new_value: &str) -> PermissionGetCall<'a, C> {
22447 self._permission_id = new_value.to_string();
22448 self
22449 }
22450 /// 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.
22451 ///
22452 /// Sets the *use domain admin access* query property to the given value.
22453 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionGetCall<'a, C> {
22454 self._use_domain_admin_access = Some(new_value);
22455 self
22456 }
22457 /// Deprecated: Use `supportsAllDrives` instead.
22458 ///
22459 /// Sets the *supports team drives* query property to the given value.
22460 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionGetCall<'a, C> {
22461 self._supports_team_drives = Some(new_value);
22462 self
22463 }
22464 /// Whether the requesting application supports both My Drives and shared drives.
22465 ///
22466 /// Sets the *supports all drives* query property to the given value.
22467 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionGetCall<'a, C> {
22468 self._supports_all_drives = Some(new_value);
22469 self
22470 }
22471 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22472 /// while executing the actual API request.
22473 ///
22474 /// ````text
22475 /// It should be used to handle progress information, and to implement a certain level of resilience.
22476 /// ````
22477 ///
22478 /// Sets the *delegate* property to the given value.
22479 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PermissionGetCall<'a, C> {
22480 self._delegate = Some(new_value);
22481 self
22482 }
22483
22484 /// Set any additional parameter of the query string used in the request.
22485 /// It should be used to set parameters which are not yet available through their own
22486 /// setters.
22487 ///
22488 /// Please note that this method must not be used to set any of the known parameters
22489 /// which have their own setter method. If done anyway, the request will fail.
22490 ///
22491 /// # Additional Parameters
22492 ///
22493 /// * *$.xgafv* (query-string) - V1 error format.
22494 /// * *access_token* (query-string) - OAuth access token.
22495 /// * *alt* (query-string) - Data format for response.
22496 /// * *callback* (query-string) - JSONP
22497 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22498 /// * *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.
22499 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22500 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22501 /// * *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.
22502 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22503 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22504 pub fn param<T>(mut self, name: T, value: T) -> PermissionGetCall<'a, C>
22505 where
22506 T: AsRef<str>,
22507 {
22508 self._additional_params
22509 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22510 self
22511 }
22512
22513 /// Identifies the authorization scope for the method you are building.
22514 ///
22515 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22516 /// [`Scope::MeetReadonly`].
22517 ///
22518 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22519 /// tokens for more than one scope.
22520 ///
22521 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22522 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22523 /// sufficient, a read-write scope will do as well.
22524 pub fn add_scope<St>(mut self, scope: St) -> PermissionGetCall<'a, C>
22525 where
22526 St: AsRef<str>,
22527 {
22528 self._scopes.insert(String::from(scope.as_ref()));
22529 self
22530 }
22531 /// Identifies the authorization scope(s) for the method you are building.
22532 ///
22533 /// See [`Self::add_scope()`] for details.
22534 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionGetCall<'a, C>
22535 where
22536 I: IntoIterator<Item = St>,
22537 St: AsRef<str>,
22538 {
22539 self._scopes
22540 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22541 self
22542 }
22543
22544 /// Removes all scopes, and no default scope will be used either.
22545 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22546 /// for details).
22547 pub fn clear_scopes(mut self) -> PermissionGetCall<'a, C> {
22548 self._scopes.clear();
22549 self
22550 }
22551}
22552
22553/// Returns the permission ID for an email address.
22554///
22555/// A builder for the *getIdForEmail* method supported by a *permission* resource.
22556/// It is not used directly, but through a [`PermissionMethods`] instance.
22557///
22558/// # Example
22559///
22560/// Instantiate a resource method builder
22561///
22562/// ```test_harness,no_run
22563/// # extern crate hyper;
22564/// # extern crate hyper_rustls;
22565/// # extern crate google_drive2 as drive2;
22566/// # async fn dox() {
22567/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22568///
22569/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22570/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22571/// # .with_native_roots()
22572/// # .unwrap()
22573/// # .https_only()
22574/// # .enable_http2()
22575/// # .build();
22576///
22577/// # let executor = hyper_util::rt::TokioExecutor::new();
22578/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22579/// # secret,
22580/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22581/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22582/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22583/// # ),
22584/// # ).build().await.unwrap();
22585///
22586/// # let client = hyper_util::client::legacy::Client::builder(
22587/// # hyper_util::rt::TokioExecutor::new()
22588/// # )
22589/// # .build(
22590/// # hyper_rustls::HttpsConnectorBuilder::new()
22591/// # .with_native_roots()
22592/// # .unwrap()
22593/// # .https_or_http()
22594/// # .enable_http2()
22595/// # .build()
22596/// # );
22597/// # let mut hub = DriveHub::new(client, auth);
22598/// // You can configure optional parameters by calling the respective setters at will, and
22599/// // execute the final call using `doit()`.
22600/// // Values shown here are possibly random and not representative !
22601/// let result = hub.permissions().get_id_for_email("email")
22602/// .doit().await;
22603/// # }
22604/// ```
22605pub struct PermissionGetIdForEmailCall<'a, C>
22606where
22607 C: 'a,
22608{
22609 hub: &'a DriveHub<C>,
22610 _email: String,
22611 _delegate: Option<&'a mut dyn common::Delegate>,
22612 _additional_params: HashMap<String, String>,
22613 _scopes: BTreeSet<String>,
22614}
22615
22616impl<'a, C> common::CallBuilder for PermissionGetIdForEmailCall<'a, C> {}
22617
22618impl<'a, C> PermissionGetIdForEmailCall<'a, C>
22619where
22620 C: common::Connector,
22621{
22622 /// Perform the operation you have build so far.
22623 pub async fn doit(mut self) -> common::Result<(common::Response, PermissionId)> {
22624 use std::borrow::Cow;
22625 use std::io::{Read, Seek};
22626
22627 use common::{url::Params, ToParts};
22628 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22629
22630 let mut dd = common::DefaultDelegate;
22631 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22632 dlg.begin(common::MethodInfo {
22633 id: "drive.permissions.getIdForEmail",
22634 http_method: hyper::Method::GET,
22635 });
22636
22637 for &field in ["alt", "email"].iter() {
22638 if self._additional_params.contains_key(field) {
22639 dlg.finished(false);
22640 return Err(common::Error::FieldClash(field));
22641 }
22642 }
22643
22644 let mut params = Params::with_capacity(3 + self._additional_params.len());
22645 params.push("email", self._email);
22646
22647 params.extend(self._additional_params.iter());
22648
22649 params.push("alt", "json");
22650 let mut url = self.hub._base_url.clone() + "permissionIds/{email}";
22651 if self._scopes.is_empty() {
22652 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
22653 }
22654
22655 #[allow(clippy::single_element_loop)]
22656 for &(find_this, param_name) in [("{email}", "email")].iter() {
22657 url = params.uri_replacement(url, param_name, find_this, false);
22658 }
22659 {
22660 let to_remove = ["email"];
22661 params.remove_params(&to_remove);
22662 }
22663
22664 let url = params.parse_with_url(&url);
22665
22666 loop {
22667 let token = match self
22668 .hub
22669 .auth
22670 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22671 .await
22672 {
22673 Ok(token) => token,
22674 Err(e) => match dlg.token(e) {
22675 Ok(token) => token,
22676 Err(e) => {
22677 dlg.finished(false);
22678 return Err(common::Error::MissingToken(e));
22679 }
22680 },
22681 };
22682 let mut req_result = {
22683 let client = &self.hub.client;
22684 dlg.pre_request();
22685 let mut req_builder = hyper::Request::builder()
22686 .method(hyper::Method::GET)
22687 .uri(url.as_str())
22688 .header(USER_AGENT, self.hub._user_agent.clone());
22689
22690 if let Some(token) = token.as_ref() {
22691 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22692 }
22693
22694 let request = req_builder
22695 .header(CONTENT_LENGTH, 0_u64)
22696 .body(common::to_body::<String>(None));
22697
22698 client.request(request.unwrap()).await
22699 };
22700
22701 match req_result {
22702 Err(err) => {
22703 if let common::Retry::After(d) = dlg.http_error(&err) {
22704 sleep(d).await;
22705 continue;
22706 }
22707 dlg.finished(false);
22708 return Err(common::Error::HttpError(err));
22709 }
22710 Ok(res) => {
22711 let (mut parts, body) = res.into_parts();
22712 let mut body = common::Body::new(body);
22713 if !parts.status.is_success() {
22714 let bytes = common::to_bytes(body).await.unwrap_or_default();
22715 let error = serde_json::from_str(&common::to_string(&bytes));
22716 let response = common::to_response(parts, bytes.into());
22717
22718 if let common::Retry::After(d) =
22719 dlg.http_failure(&response, error.as_ref().ok())
22720 {
22721 sleep(d).await;
22722 continue;
22723 }
22724
22725 dlg.finished(false);
22726
22727 return Err(match error {
22728 Ok(value) => common::Error::BadRequest(value),
22729 _ => common::Error::Failure(response),
22730 });
22731 }
22732 let response = {
22733 let bytes = common::to_bytes(body).await.unwrap_or_default();
22734 let encoded = common::to_string(&bytes);
22735 match serde_json::from_str(&encoded) {
22736 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22737 Err(error) => {
22738 dlg.response_json_decode_error(&encoded, &error);
22739 return Err(common::Error::JsonDecodeError(
22740 encoded.to_string(),
22741 error,
22742 ));
22743 }
22744 }
22745 };
22746
22747 dlg.finished(true);
22748 return Ok(response);
22749 }
22750 }
22751 }
22752 }
22753
22754 /// The email address for which to return a permission ID
22755 ///
22756 /// Sets the *email* path property to the given value.
22757 ///
22758 /// Even though the property as already been set when instantiating this call,
22759 /// we provide this method for API completeness.
22760 pub fn email(mut self, new_value: &str) -> PermissionGetIdForEmailCall<'a, C> {
22761 self._email = new_value.to_string();
22762 self
22763 }
22764 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22765 /// while executing the actual API request.
22766 ///
22767 /// ````text
22768 /// It should be used to handle progress information, and to implement a certain level of resilience.
22769 /// ````
22770 ///
22771 /// Sets the *delegate* property to the given value.
22772 pub fn delegate(
22773 mut self,
22774 new_value: &'a mut dyn common::Delegate,
22775 ) -> PermissionGetIdForEmailCall<'a, C> {
22776 self._delegate = Some(new_value);
22777 self
22778 }
22779
22780 /// Set any additional parameter of the query string used in the request.
22781 /// It should be used to set parameters which are not yet available through their own
22782 /// setters.
22783 ///
22784 /// Please note that this method must not be used to set any of the known parameters
22785 /// which have their own setter method. If done anyway, the request will fail.
22786 ///
22787 /// # Additional Parameters
22788 ///
22789 /// * *$.xgafv* (query-string) - V1 error format.
22790 /// * *access_token* (query-string) - OAuth access token.
22791 /// * *alt* (query-string) - Data format for response.
22792 /// * *callback* (query-string) - JSONP
22793 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22794 /// * *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.
22795 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22796 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22797 /// * *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.
22798 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22799 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22800 pub fn param<T>(mut self, name: T, value: T) -> PermissionGetIdForEmailCall<'a, C>
22801 where
22802 T: AsRef<str>,
22803 {
22804 self._additional_params
22805 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22806 self
22807 }
22808
22809 /// Identifies the authorization scope for the method you are building.
22810 ///
22811 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22812 /// [`Scope::AppReadonly`].
22813 ///
22814 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22815 /// tokens for more than one scope.
22816 ///
22817 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22818 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22819 /// sufficient, a read-write scope will do as well.
22820 pub fn add_scope<St>(mut self, scope: St) -> PermissionGetIdForEmailCall<'a, C>
22821 where
22822 St: AsRef<str>,
22823 {
22824 self._scopes.insert(String::from(scope.as_ref()));
22825 self
22826 }
22827 /// Identifies the authorization scope(s) for the method you are building.
22828 ///
22829 /// See [`Self::add_scope()`] for details.
22830 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionGetIdForEmailCall<'a, C>
22831 where
22832 I: IntoIterator<Item = St>,
22833 St: AsRef<str>,
22834 {
22835 self._scopes
22836 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22837 self
22838 }
22839
22840 /// Removes all scopes, and no default scope will be used either.
22841 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22842 /// for details).
22843 pub fn clear_scopes(mut self) -> PermissionGetIdForEmailCall<'a, C> {
22844 self._scopes.clear();
22845 self
22846 }
22847}
22848
22849/// 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.
22850///
22851/// A builder for the *insert* method supported by a *permission* resource.
22852/// It is not used directly, but through a [`PermissionMethods`] instance.
22853///
22854/// # Example
22855///
22856/// Instantiate a resource method builder
22857///
22858/// ```test_harness,no_run
22859/// # extern crate hyper;
22860/// # extern crate hyper_rustls;
22861/// # extern crate google_drive2 as drive2;
22862/// use drive2::api::Permission;
22863/// # async fn dox() {
22864/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22865///
22866/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22867/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22868/// # .with_native_roots()
22869/// # .unwrap()
22870/// # .https_only()
22871/// # .enable_http2()
22872/// # .build();
22873///
22874/// # let executor = hyper_util::rt::TokioExecutor::new();
22875/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22876/// # secret,
22877/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22878/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22879/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22880/// # ),
22881/// # ).build().await.unwrap();
22882///
22883/// # let client = hyper_util::client::legacy::Client::builder(
22884/// # hyper_util::rt::TokioExecutor::new()
22885/// # )
22886/// # .build(
22887/// # hyper_rustls::HttpsConnectorBuilder::new()
22888/// # .with_native_roots()
22889/// # .unwrap()
22890/// # .https_or_http()
22891/// # .enable_http2()
22892/// # .build()
22893/// # );
22894/// # let mut hub = DriveHub::new(client, auth);
22895/// // As the method needs a request, you would usually fill it with the desired information
22896/// // into the respective structure. Some of the parts shown here might not be applicable !
22897/// // Values shown here are possibly random and not representative !
22898/// let mut req = Permission::default();
22899///
22900/// // You can configure optional parameters by calling the respective setters at will, and
22901/// // execute the final call using `doit()`.
22902/// // Values shown here are possibly random and not representative !
22903/// let result = hub.permissions().insert(req, "fileId")
22904/// .use_domain_admin_access(false)
22905/// .supports_team_drives(false)
22906/// .supports_all_drives(true)
22907/// .send_notification_emails(false)
22908/// .move_to_new_owners_root(false)
22909/// .enforce_single_parent(false)
22910/// .enforce_expansive_access(false)
22911/// .email_message("consetetur")
22912/// .doit().await;
22913/// # }
22914/// ```
22915pub struct PermissionInsertCall<'a, C>
22916where
22917 C: 'a,
22918{
22919 hub: &'a DriveHub<C>,
22920 _request: Permission,
22921 _file_id: String,
22922 _use_domain_admin_access: Option<bool>,
22923 _supports_team_drives: Option<bool>,
22924 _supports_all_drives: Option<bool>,
22925 _send_notification_emails: Option<bool>,
22926 _move_to_new_owners_root: Option<bool>,
22927 _enforce_single_parent: Option<bool>,
22928 _enforce_expansive_access: Option<bool>,
22929 _email_message: Option<String>,
22930 _delegate: Option<&'a mut dyn common::Delegate>,
22931 _additional_params: HashMap<String, String>,
22932 _scopes: BTreeSet<String>,
22933}
22934
22935impl<'a, C> common::CallBuilder for PermissionInsertCall<'a, C> {}
22936
22937impl<'a, C> PermissionInsertCall<'a, C>
22938where
22939 C: common::Connector,
22940{
22941 /// Perform the operation you have build so far.
22942 pub async fn doit(mut self) -> common::Result<(common::Response, Permission)> {
22943 use std::borrow::Cow;
22944 use std::io::{Read, Seek};
22945
22946 use common::{url::Params, ToParts};
22947 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22948
22949 let mut dd = common::DefaultDelegate;
22950 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22951 dlg.begin(common::MethodInfo {
22952 id: "drive.permissions.insert",
22953 http_method: hyper::Method::POST,
22954 });
22955
22956 for &field in [
22957 "alt",
22958 "fileId",
22959 "useDomainAdminAccess",
22960 "supportsTeamDrives",
22961 "supportsAllDrives",
22962 "sendNotificationEmails",
22963 "moveToNewOwnersRoot",
22964 "enforceSingleParent",
22965 "enforceExpansiveAccess",
22966 "emailMessage",
22967 ]
22968 .iter()
22969 {
22970 if self._additional_params.contains_key(field) {
22971 dlg.finished(false);
22972 return Err(common::Error::FieldClash(field));
22973 }
22974 }
22975
22976 let mut params = Params::with_capacity(12 + self._additional_params.len());
22977 params.push("fileId", self._file_id);
22978 if let Some(value) = self._use_domain_admin_access.as_ref() {
22979 params.push("useDomainAdminAccess", value.to_string());
22980 }
22981 if let Some(value) = self._supports_team_drives.as_ref() {
22982 params.push("supportsTeamDrives", value.to_string());
22983 }
22984 if let Some(value) = self._supports_all_drives.as_ref() {
22985 params.push("supportsAllDrives", value.to_string());
22986 }
22987 if let Some(value) = self._send_notification_emails.as_ref() {
22988 params.push("sendNotificationEmails", value.to_string());
22989 }
22990 if let Some(value) = self._move_to_new_owners_root.as_ref() {
22991 params.push("moveToNewOwnersRoot", value.to_string());
22992 }
22993 if let Some(value) = self._enforce_single_parent.as_ref() {
22994 params.push("enforceSingleParent", value.to_string());
22995 }
22996 if let Some(value) = self._enforce_expansive_access.as_ref() {
22997 params.push("enforceExpansiveAccess", value.to_string());
22998 }
22999 if let Some(value) = self._email_message.as_ref() {
23000 params.push("emailMessage", value);
23001 }
23002
23003 params.extend(self._additional_params.iter());
23004
23005 params.push("alt", "json");
23006 let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions";
23007 if self._scopes.is_empty() {
23008 self._scopes.insert(Scope::Full.as_ref().to_string());
23009 }
23010
23011 #[allow(clippy::single_element_loop)]
23012 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
23013 url = params.uri_replacement(url, param_name, find_this, false);
23014 }
23015 {
23016 let to_remove = ["fileId"];
23017 params.remove_params(&to_remove);
23018 }
23019
23020 let url = params.parse_with_url(&url);
23021
23022 let mut json_mime_type = mime::APPLICATION_JSON;
23023 let mut request_value_reader = {
23024 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23025 common::remove_json_null_values(&mut value);
23026 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23027 serde_json::to_writer(&mut dst, &value).unwrap();
23028 dst
23029 };
23030 let request_size = request_value_reader
23031 .seek(std::io::SeekFrom::End(0))
23032 .unwrap();
23033 request_value_reader
23034 .seek(std::io::SeekFrom::Start(0))
23035 .unwrap();
23036
23037 loop {
23038 let token = match self
23039 .hub
23040 .auth
23041 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23042 .await
23043 {
23044 Ok(token) => token,
23045 Err(e) => match dlg.token(e) {
23046 Ok(token) => token,
23047 Err(e) => {
23048 dlg.finished(false);
23049 return Err(common::Error::MissingToken(e));
23050 }
23051 },
23052 };
23053 request_value_reader
23054 .seek(std::io::SeekFrom::Start(0))
23055 .unwrap();
23056 let mut req_result = {
23057 let client = &self.hub.client;
23058 dlg.pre_request();
23059 let mut req_builder = hyper::Request::builder()
23060 .method(hyper::Method::POST)
23061 .uri(url.as_str())
23062 .header(USER_AGENT, self.hub._user_agent.clone());
23063
23064 if let Some(token) = token.as_ref() {
23065 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23066 }
23067
23068 let request = req_builder
23069 .header(CONTENT_TYPE, json_mime_type.to_string())
23070 .header(CONTENT_LENGTH, request_size as u64)
23071 .body(common::to_body(
23072 request_value_reader.get_ref().clone().into(),
23073 ));
23074
23075 client.request(request.unwrap()).await
23076 };
23077
23078 match req_result {
23079 Err(err) => {
23080 if let common::Retry::After(d) = dlg.http_error(&err) {
23081 sleep(d).await;
23082 continue;
23083 }
23084 dlg.finished(false);
23085 return Err(common::Error::HttpError(err));
23086 }
23087 Ok(res) => {
23088 let (mut parts, body) = res.into_parts();
23089 let mut body = common::Body::new(body);
23090 if !parts.status.is_success() {
23091 let bytes = common::to_bytes(body).await.unwrap_or_default();
23092 let error = serde_json::from_str(&common::to_string(&bytes));
23093 let response = common::to_response(parts, bytes.into());
23094
23095 if let common::Retry::After(d) =
23096 dlg.http_failure(&response, error.as_ref().ok())
23097 {
23098 sleep(d).await;
23099 continue;
23100 }
23101
23102 dlg.finished(false);
23103
23104 return Err(match error {
23105 Ok(value) => common::Error::BadRequest(value),
23106 _ => common::Error::Failure(response),
23107 });
23108 }
23109 let response = {
23110 let bytes = common::to_bytes(body).await.unwrap_or_default();
23111 let encoded = common::to_string(&bytes);
23112 match serde_json::from_str(&encoded) {
23113 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23114 Err(error) => {
23115 dlg.response_json_decode_error(&encoded, &error);
23116 return Err(common::Error::JsonDecodeError(
23117 encoded.to_string(),
23118 error,
23119 ));
23120 }
23121 }
23122 };
23123
23124 dlg.finished(true);
23125 return Ok(response);
23126 }
23127 }
23128 }
23129 }
23130
23131 ///
23132 /// Sets the *request* property to the given value.
23133 ///
23134 /// Even though the property as already been set when instantiating this call,
23135 /// we provide this method for API completeness.
23136 pub fn request(mut self, new_value: Permission) -> PermissionInsertCall<'a, C> {
23137 self._request = new_value;
23138 self
23139 }
23140 /// The ID for the file or shared drive.
23141 ///
23142 /// Sets the *file id* path property to the given value.
23143 ///
23144 /// Even though the property as already been set when instantiating this call,
23145 /// we provide this method for API completeness.
23146 pub fn file_id(mut self, new_value: &str) -> PermissionInsertCall<'a, C> {
23147 self._file_id = new_value.to_string();
23148 self
23149 }
23150 /// 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.
23151 ///
23152 /// Sets the *use domain admin access* query property to the given value.
23153 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionInsertCall<'a, C> {
23154 self._use_domain_admin_access = Some(new_value);
23155 self
23156 }
23157 /// Deprecated: Use `supportsAllDrives` instead.
23158 ///
23159 /// Sets the *supports team drives* query property to the given value.
23160 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionInsertCall<'a, C> {
23161 self._supports_team_drives = Some(new_value);
23162 self
23163 }
23164 /// Whether the requesting application supports both My Drives and shared drives.
23165 ///
23166 /// Sets the *supports all drives* query property to the given value.
23167 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionInsertCall<'a, C> {
23168 self._supports_all_drives = Some(new_value);
23169 self
23170 }
23171 /// 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`.
23172 ///
23173 /// Sets the *send notification emails* query property to the given value.
23174 pub fn send_notification_emails(mut self, new_value: bool) -> PermissionInsertCall<'a, C> {
23175 self._send_notification_emails = Some(new_value);
23176 self
23177 }
23178 /// 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.
23179 ///
23180 /// Sets the *move to new owners root* query property to the given value.
23181 pub fn move_to_new_owners_root(mut self, new_value: bool) -> PermissionInsertCall<'a, C> {
23182 self._move_to_new_owners_root = Some(new_value);
23183 self
23184 }
23185 /// Deprecated: See `moveToNewOwnersRoot` for details.
23186 ///
23187 /// Sets the *enforce single parent* query property to the given value.
23188 pub fn enforce_single_parent(mut self, new_value: bool) -> PermissionInsertCall<'a, C> {
23189 self._enforce_single_parent = Some(new_value);
23190 self
23191 }
23192 /// Whether the request should enforce expansive access rules.
23193 ///
23194 /// Sets the *enforce expansive access* query property to the given value.
23195 pub fn enforce_expansive_access(mut self, new_value: bool) -> PermissionInsertCall<'a, C> {
23196 self._enforce_expansive_access = Some(new_value);
23197 self
23198 }
23199 /// A plain text custom message to include in notification emails.
23200 ///
23201 /// Sets the *email message* query property to the given value.
23202 pub fn email_message(mut self, new_value: &str) -> PermissionInsertCall<'a, C> {
23203 self._email_message = Some(new_value.to_string());
23204 self
23205 }
23206 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23207 /// while executing the actual API request.
23208 ///
23209 /// ````text
23210 /// It should be used to handle progress information, and to implement a certain level of resilience.
23211 /// ````
23212 ///
23213 /// Sets the *delegate* property to the given value.
23214 pub fn delegate(
23215 mut self,
23216 new_value: &'a mut dyn common::Delegate,
23217 ) -> PermissionInsertCall<'a, C> {
23218 self._delegate = Some(new_value);
23219 self
23220 }
23221
23222 /// Set any additional parameter of the query string used in the request.
23223 /// It should be used to set parameters which are not yet available through their own
23224 /// setters.
23225 ///
23226 /// Please note that this method must not be used to set any of the known parameters
23227 /// which have their own setter method. If done anyway, the request will fail.
23228 ///
23229 /// # Additional Parameters
23230 ///
23231 /// * *$.xgafv* (query-string) - V1 error format.
23232 /// * *access_token* (query-string) - OAuth access token.
23233 /// * *alt* (query-string) - Data format for response.
23234 /// * *callback* (query-string) - JSONP
23235 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23236 /// * *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.
23237 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23238 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23239 /// * *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.
23240 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23241 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23242 pub fn param<T>(mut self, name: T, value: T) -> PermissionInsertCall<'a, C>
23243 where
23244 T: AsRef<str>,
23245 {
23246 self._additional_params
23247 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23248 self
23249 }
23250
23251 /// Identifies the authorization scope for the method you are building.
23252 ///
23253 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23254 /// [`Scope::Full`].
23255 ///
23256 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23257 /// tokens for more than one scope.
23258 ///
23259 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23260 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23261 /// sufficient, a read-write scope will do as well.
23262 pub fn add_scope<St>(mut self, scope: St) -> PermissionInsertCall<'a, C>
23263 where
23264 St: AsRef<str>,
23265 {
23266 self._scopes.insert(String::from(scope.as_ref()));
23267 self
23268 }
23269 /// Identifies the authorization scope(s) for the method you are building.
23270 ///
23271 /// See [`Self::add_scope()`] for details.
23272 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionInsertCall<'a, C>
23273 where
23274 I: IntoIterator<Item = St>,
23275 St: AsRef<str>,
23276 {
23277 self._scopes
23278 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23279 self
23280 }
23281
23282 /// Removes all scopes, and no default scope will be used either.
23283 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23284 /// for details).
23285 pub fn clear_scopes(mut self) -> PermissionInsertCall<'a, C> {
23286 self._scopes.clear();
23287 self
23288 }
23289}
23290
23291/// Lists a file's or shared drive's permissions.
23292///
23293/// A builder for the *list* method supported by a *permission* resource.
23294/// It is not used directly, but through a [`PermissionMethods`] instance.
23295///
23296/// # Example
23297///
23298/// Instantiate a resource method builder
23299///
23300/// ```test_harness,no_run
23301/// # extern crate hyper;
23302/// # extern crate hyper_rustls;
23303/// # extern crate google_drive2 as drive2;
23304/// # async fn dox() {
23305/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23306///
23307/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23308/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23309/// # .with_native_roots()
23310/// # .unwrap()
23311/// # .https_only()
23312/// # .enable_http2()
23313/// # .build();
23314///
23315/// # let executor = hyper_util::rt::TokioExecutor::new();
23316/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23317/// # secret,
23318/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23319/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23320/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23321/// # ),
23322/// # ).build().await.unwrap();
23323///
23324/// # let client = hyper_util::client::legacy::Client::builder(
23325/// # hyper_util::rt::TokioExecutor::new()
23326/// # )
23327/// # .build(
23328/// # hyper_rustls::HttpsConnectorBuilder::new()
23329/// # .with_native_roots()
23330/// # .unwrap()
23331/// # .https_or_http()
23332/// # .enable_http2()
23333/// # .build()
23334/// # );
23335/// # let mut hub = DriveHub::new(client, auth);
23336/// // You can configure optional parameters by calling the respective setters at will, and
23337/// // execute the final call using `doit()`.
23338/// // Values shown here are possibly random and not representative !
23339/// let result = hub.permissions().list("fileId")
23340/// .use_domain_admin_access(true)
23341/// .supports_team_drives(true)
23342/// .supports_all_drives(false)
23343/// .page_token("sea")
23344/// .max_results(-20)
23345/// .include_permissions_for_view("sea")
23346/// .doit().await;
23347/// # }
23348/// ```
23349pub struct PermissionListCall<'a, C>
23350where
23351 C: 'a,
23352{
23353 hub: &'a DriveHub<C>,
23354 _file_id: String,
23355 _use_domain_admin_access: Option<bool>,
23356 _supports_team_drives: Option<bool>,
23357 _supports_all_drives: Option<bool>,
23358 _page_token: Option<String>,
23359 _max_results: Option<i32>,
23360 _include_permissions_for_view: Option<String>,
23361 _delegate: Option<&'a mut dyn common::Delegate>,
23362 _additional_params: HashMap<String, String>,
23363 _scopes: BTreeSet<String>,
23364}
23365
23366impl<'a, C> common::CallBuilder for PermissionListCall<'a, C> {}
23367
23368impl<'a, C> PermissionListCall<'a, C>
23369where
23370 C: common::Connector,
23371{
23372 /// Perform the operation you have build so far.
23373 pub async fn doit(mut self) -> common::Result<(common::Response, PermissionList)> {
23374 use std::borrow::Cow;
23375 use std::io::{Read, Seek};
23376
23377 use common::{url::Params, ToParts};
23378 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23379
23380 let mut dd = common::DefaultDelegate;
23381 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23382 dlg.begin(common::MethodInfo {
23383 id: "drive.permissions.list",
23384 http_method: hyper::Method::GET,
23385 });
23386
23387 for &field in [
23388 "alt",
23389 "fileId",
23390 "useDomainAdminAccess",
23391 "supportsTeamDrives",
23392 "supportsAllDrives",
23393 "pageToken",
23394 "maxResults",
23395 "includePermissionsForView",
23396 ]
23397 .iter()
23398 {
23399 if self._additional_params.contains_key(field) {
23400 dlg.finished(false);
23401 return Err(common::Error::FieldClash(field));
23402 }
23403 }
23404
23405 let mut params = Params::with_capacity(9 + self._additional_params.len());
23406 params.push("fileId", self._file_id);
23407 if let Some(value) = self._use_domain_admin_access.as_ref() {
23408 params.push("useDomainAdminAccess", value.to_string());
23409 }
23410 if let Some(value) = self._supports_team_drives.as_ref() {
23411 params.push("supportsTeamDrives", value.to_string());
23412 }
23413 if let Some(value) = self._supports_all_drives.as_ref() {
23414 params.push("supportsAllDrives", value.to_string());
23415 }
23416 if let Some(value) = self._page_token.as_ref() {
23417 params.push("pageToken", value);
23418 }
23419 if let Some(value) = self._max_results.as_ref() {
23420 params.push("maxResults", value.to_string());
23421 }
23422 if let Some(value) = self._include_permissions_for_view.as_ref() {
23423 params.push("includePermissionsForView", value);
23424 }
23425
23426 params.extend(self._additional_params.iter());
23427
23428 params.push("alt", "json");
23429 let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions";
23430 if self._scopes.is_empty() {
23431 self._scopes
23432 .insert(Scope::MeetReadonly.as_ref().to_string());
23433 }
23434
23435 #[allow(clippy::single_element_loop)]
23436 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
23437 url = params.uri_replacement(url, param_name, find_this, false);
23438 }
23439 {
23440 let to_remove = ["fileId"];
23441 params.remove_params(&to_remove);
23442 }
23443
23444 let url = params.parse_with_url(&url);
23445
23446 loop {
23447 let token = match self
23448 .hub
23449 .auth
23450 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23451 .await
23452 {
23453 Ok(token) => token,
23454 Err(e) => match dlg.token(e) {
23455 Ok(token) => token,
23456 Err(e) => {
23457 dlg.finished(false);
23458 return Err(common::Error::MissingToken(e));
23459 }
23460 },
23461 };
23462 let mut req_result = {
23463 let client = &self.hub.client;
23464 dlg.pre_request();
23465 let mut req_builder = hyper::Request::builder()
23466 .method(hyper::Method::GET)
23467 .uri(url.as_str())
23468 .header(USER_AGENT, self.hub._user_agent.clone());
23469
23470 if let Some(token) = token.as_ref() {
23471 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23472 }
23473
23474 let request = req_builder
23475 .header(CONTENT_LENGTH, 0_u64)
23476 .body(common::to_body::<String>(None));
23477
23478 client.request(request.unwrap()).await
23479 };
23480
23481 match req_result {
23482 Err(err) => {
23483 if let common::Retry::After(d) = dlg.http_error(&err) {
23484 sleep(d).await;
23485 continue;
23486 }
23487 dlg.finished(false);
23488 return Err(common::Error::HttpError(err));
23489 }
23490 Ok(res) => {
23491 let (mut parts, body) = res.into_parts();
23492 let mut body = common::Body::new(body);
23493 if !parts.status.is_success() {
23494 let bytes = common::to_bytes(body).await.unwrap_or_default();
23495 let error = serde_json::from_str(&common::to_string(&bytes));
23496 let response = common::to_response(parts, bytes.into());
23497
23498 if let common::Retry::After(d) =
23499 dlg.http_failure(&response, error.as_ref().ok())
23500 {
23501 sleep(d).await;
23502 continue;
23503 }
23504
23505 dlg.finished(false);
23506
23507 return Err(match error {
23508 Ok(value) => common::Error::BadRequest(value),
23509 _ => common::Error::Failure(response),
23510 });
23511 }
23512 let response = {
23513 let bytes = common::to_bytes(body).await.unwrap_or_default();
23514 let encoded = common::to_string(&bytes);
23515 match serde_json::from_str(&encoded) {
23516 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23517 Err(error) => {
23518 dlg.response_json_decode_error(&encoded, &error);
23519 return Err(common::Error::JsonDecodeError(
23520 encoded.to_string(),
23521 error,
23522 ));
23523 }
23524 }
23525 };
23526
23527 dlg.finished(true);
23528 return Ok(response);
23529 }
23530 }
23531 }
23532 }
23533
23534 /// The ID for the file or shared drive.
23535 ///
23536 /// Sets the *file id* path property to the given value.
23537 ///
23538 /// Even though the property as already been set when instantiating this call,
23539 /// we provide this method for API completeness.
23540 pub fn file_id(mut self, new_value: &str) -> PermissionListCall<'a, C> {
23541 self._file_id = new_value.to_string();
23542 self
23543 }
23544 /// 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.
23545 ///
23546 /// Sets the *use domain admin access* query property to the given value.
23547 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionListCall<'a, C> {
23548 self._use_domain_admin_access = Some(new_value);
23549 self
23550 }
23551 /// Deprecated: Use `supportsAllDrives` instead.
23552 ///
23553 /// Sets the *supports team drives* query property to the given value.
23554 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionListCall<'a, C> {
23555 self._supports_team_drives = Some(new_value);
23556 self
23557 }
23558 /// Whether the requesting application supports both My Drives and shared drives.
23559 ///
23560 /// Sets the *supports all drives* query property to the given value.
23561 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionListCall<'a, C> {
23562 self._supports_all_drives = Some(new_value);
23563 self
23564 }
23565 /// 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.
23566 ///
23567 /// Sets the *page token* query property to the given value.
23568 pub fn page_token(mut self, new_value: &str) -> PermissionListCall<'a, C> {
23569 self._page_token = Some(new_value.to_string());
23570 self
23571 }
23572 /// 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.
23573 ///
23574 /// Sets the *max results* query property to the given value.
23575 pub fn max_results(mut self, new_value: i32) -> PermissionListCall<'a, C> {
23576 self._max_results = Some(new_value);
23577 self
23578 }
23579 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
23580 ///
23581 /// Sets the *include permissions for view* query property to the given value.
23582 pub fn include_permissions_for_view(mut self, new_value: &str) -> PermissionListCall<'a, C> {
23583 self._include_permissions_for_view = Some(new_value.to_string());
23584 self
23585 }
23586 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23587 /// while executing the actual API request.
23588 ///
23589 /// ````text
23590 /// It should be used to handle progress information, and to implement a certain level of resilience.
23591 /// ````
23592 ///
23593 /// Sets the *delegate* property to the given value.
23594 pub fn delegate(
23595 mut self,
23596 new_value: &'a mut dyn common::Delegate,
23597 ) -> PermissionListCall<'a, C> {
23598 self._delegate = Some(new_value);
23599 self
23600 }
23601
23602 /// Set any additional parameter of the query string used in the request.
23603 /// It should be used to set parameters which are not yet available through their own
23604 /// setters.
23605 ///
23606 /// Please note that this method must not be used to set any of the known parameters
23607 /// which have their own setter method. If done anyway, the request will fail.
23608 ///
23609 /// # Additional Parameters
23610 ///
23611 /// * *$.xgafv* (query-string) - V1 error format.
23612 /// * *access_token* (query-string) - OAuth access token.
23613 /// * *alt* (query-string) - Data format for response.
23614 /// * *callback* (query-string) - JSONP
23615 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23616 /// * *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.
23617 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23618 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23619 /// * *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.
23620 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23621 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23622 pub fn param<T>(mut self, name: T, value: T) -> PermissionListCall<'a, C>
23623 where
23624 T: AsRef<str>,
23625 {
23626 self._additional_params
23627 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23628 self
23629 }
23630
23631 /// Identifies the authorization scope for the method you are building.
23632 ///
23633 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23634 /// [`Scope::MeetReadonly`].
23635 ///
23636 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23637 /// tokens for more than one scope.
23638 ///
23639 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23640 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23641 /// sufficient, a read-write scope will do as well.
23642 pub fn add_scope<St>(mut self, scope: St) -> PermissionListCall<'a, C>
23643 where
23644 St: AsRef<str>,
23645 {
23646 self._scopes.insert(String::from(scope.as_ref()));
23647 self
23648 }
23649 /// Identifies the authorization scope(s) for the method you are building.
23650 ///
23651 /// See [`Self::add_scope()`] for details.
23652 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionListCall<'a, C>
23653 where
23654 I: IntoIterator<Item = St>,
23655 St: AsRef<str>,
23656 {
23657 self._scopes
23658 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23659 self
23660 }
23661
23662 /// Removes all scopes, and no default scope will be used either.
23663 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23664 /// for details).
23665 pub fn clear_scopes(mut self) -> PermissionListCall<'a, C> {
23666 self._scopes.clear();
23667 self
23668 }
23669}
23670
23671/// Updates a permission using patch semantics. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied.
23672///
23673/// A builder for the *patch* method supported by a *permission* resource.
23674/// It is not used directly, but through a [`PermissionMethods`] instance.
23675///
23676/// # Example
23677///
23678/// Instantiate a resource method builder
23679///
23680/// ```test_harness,no_run
23681/// # extern crate hyper;
23682/// # extern crate hyper_rustls;
23683/// # extern crate google_drive2 as drive2;
23684/// use drive2::api::Permission;
23685/// # async fn dox() {
23686/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23687///
23688/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23689/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23690/// # .with_native_roots()
23691/// # .unwrap()
23692/// # .https_only()
23693/// # .enable_http2()
23694/// # .build();
23695///
23696/// # let executor = hyper_util::rt::TokioExecutor::new();
23697/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23698/// # secret,
23699/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23700/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23701/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23702/// # ),
23703/// # ).build().await.unwrap();
23704///
23705/// # let client = hyper_util::client::legacy::Client::builder(
23706/// # hyper_util::rt::TokioExecutor::new()
23707/// # )
23708/// # .build(
23709/// # hyper_rustls::HttpsConnectorBuilder::new()
23710/// # .with_native_roots()
23711/// # .unwrap()
23712/// # .https_or_http()
23713/// # .enable_http2()
23714/// # .build()
23715/// # );
23716/// # let mut hub = DriveHub::new(client, auth);
23717/// // As the method needs a request, you would usually fill it with the desired information
23718/// // into the respective structure. Some of the parts shown here might not be applicable !
23719/// // Values shown here are possibly random and not representative !
23720/// let mut req = Permission::default();
23721///
23722/// // You can configure optional parameters by calling the respective setters at will, and
23723/// // execute the final call using `doit()`.
23724/// // Values shown here are possibly random and not representative !
23725/// let result = hub.permissions().patch(req, "fileId", "permissionId")
23726/// .use_domain_admin_access(true)
23727/// .transfer_ownership(true)
23728/// .supports_team_drives(true)
23729/// .supports_all_drives(false)
23730/// .remove_expiration(true)
23731/// .enforce_expansive_access(true)
23732/// .doit().await;
23733/// # }
23734/// ```
23735pub struct PermissionPatchCall<'a, C>
23736where
23737 C: 'a,
23738{
23739 hub: &'a DriveHub<C>,
23740 _request: Permission,
23741 _file_id: String,
23742 _permission_id: String,
23743 _use_domain_admin_access: Option<bool>,
23744 _transfer_ownership: Option<bool>,
23745 _supports_team_drives: Option<bool>,
23746 _supports_all_drives: Option<bool>,
23747 _remove_expiration: Option<bool>,
23748 _enforce_expansive_access: Option<bool>,
23749 _delegate: Option<&'a mut dyn common::Delegate>,
23750 _additional_params: HashMap<String, String>,
23751 _scopes: BTreeSet<String>,
23752}
23753
23754impl<'a, C> common::CallBuilder for PermissionPatchCall<'a, C> {}
23755
23756impl<'a, C> PermissionPatchCall<'a, C>
23757where
23758 C: common::Connector,
23759{
23760 /// Perform the operation you have build so far.
23761 pub async fn doit(mut self) -> common::Result<(common::Response, Permission)> {
23762 use std::borrow::Cow;
23763 use std::io::{Read, Seek};
23764
23765 use common::{url::Params, ToParts};
23766 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23767
23768 let mut dd = common::DefaultDelegate;
23769 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23770 dlg.begin(common::MethodInfo {
23771 id: "drive.permissions.patch",
23772 http_method: hyper::Method::PATCH,
23773 });
23774
23775 for &field in [
23776 "alt",
23777 "fileId",
23778 "permissionId",
23779 "useDomainAdminAccess",
23780 "transferOwnership",
23781 "supportsTeamDrives",
23782 "supportsAllDrives",
23783 "removeExpiration",
23784 "enforceExpansiveAccess",
23785 ]
23786 .iter()
23787 {
23788 if self._additional_params.contains_key(field) {
23789 dlg.finished(false);
23790 return Err(common::Error::FieldClash(field));
23791 }
23792 }
23793
23794 let mut params = Params::with_capacity(11 + self._additional_params.len());
23795 params.push("fileId", self._file_id);
23796 params.push("permissionId", self._permission_id);
23797 if let Some(value) = self._use_domain_admin_access.as_ref() {
23798 params.push("useDomainAdminAccess", value.to_string());
23799 }
23800 if let Some(value) = self._transfer_ownership.as_ref() {
23801 params.push("transferOwnership", value.to_string());
23802 }
23803 if let Some(value) = self._supports_team_drives.as_ref() {
23804 params.push("supportsTeamDrives", value.to_string());
23805 }
23806 if let Some(value) = self._supports_all_drives.as_ref() {
23807 params.push("supportsAllDrives", value.to_string());
23808 }
23809 if let Some(value) = self._remove_expiration.as_ref() {
23810 params.push("removeExpiration", value.to_string());
23811 }
23812 if let Some(value) = self._enforce_expansive_access.as_ref() {
23813 params.push("enforceExpansiveAccess", value.to_string());
23814 }
23815
23816 params.extend(self._additional_params.iter());
23817
23818 params.push("alt", "json");
23819 let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}";
23820 if self._scopes.is_empty() {
23821 self._scopes.insert(Scope::Full.as_ref().to_string());
23822 }
23823
23824 #[allow(clippy::single_element_loop)]
23825 for &(find_this, param_name) in
23826 [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter()
23827 {
23828 url = params.uri_replacement(url, param_name, find_this, false);
23829 }
23830 {
23831 let to_remove = ["permissionId", "fileId"];
23832 params.remove_params(&to_remove);
23833 }
23834
23835 let url = params.parse_with_url(&url);
23836
23837 let mut json_mime_type = mime::APPLICATION_JSON;
23838 let mut request_value_reader = {
23839 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23840 common::remove_json_null_values(&mut value);
23841 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23842 serde_json::to_writer(&mut dst, &value).unwrap();
23843 dst
23844 };
23845 let request_size = request_value_reader
23846 .seek(std::io::SeekFrom::End(0))
23847 .unwrap();
23848 request_value_reader
23849 .seek(std::io::SeekFrom::Start(0))
23850 .unwrap();
23851
23852 loop {
23853 let token = match self
23854 .hub
23855 .auth
23856 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23857 .await
23858 {
23859 Ok(token) => token,
23860 Err(e) => match dlg.token(e) {
23861 Ok(token) => token,
23862 Err(e) => {
23863 dlg.finished(false);
23864 return Err(common::Error::MissingToken(e));
23865 }
23866 },
23867 };
23868 request_value_reader
23869 .seek(std::io::SeekFrom::Start(0))
23870 .unwrap();
23871 let mut req_result = {
23872 let client = &self.hub.client;
23873 dlg.pre_request();
23874 let mut req_builder = hyper::Request::builder()
23875 .method(hyper::Method::PATCH)
23876 .uri(url.as_str())
23877 .header(USER_AGENT, self.hub._user_agent.clone());
23878
23879 if let Some(token) = token.as_ref() {
23880 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23881 }
23882
23883 let request = req_builder
23884 .header(CONTENT_TYPE, json_mime_type.to_string())
23885 .header(CONTENT_LENGTH, request_size as u64)
23886 .body(common::to_body(
23887 request_value_reader.get_ref().clone().into(),
23888 ));
23889
23890 client.request(request.unwrap()).await
23891 };
23892
23893 match req_result {
23894 Err(err) => {
23895 if let common::Retry::After(d) = dlg.http_error(&err) {
23896 sleep(d).await;
23897 continue;
23898 }
23899 dlg.finished(false);
23900 return Err(common::Error::HttpError(err));
23901 }
23902 Ok(res) => {
23903 let (mut parts, body) = res.into_parts();
23904 let mut body = common::Body::new(body);
23905 if !parts.status.is_success() {
23906 let bytes = common::to_bytes(body).await.unwrap_or_default();
23907 let error = serde_json::from_str(&common::to_string(&bytes));
23908 let response = common::to_response(parts, bytes.into());
23909
23910 if let common::Retry::After(d) =
23911 dlg.http_failure(&response, error.as_ref().ok())
23912 {
23913 sleep(d).await;
23914 continue;
23915 }
23916
23917 dlg.finished(false);
23918
23919 return Err(match error {
23920 Ok(value) => common::Error::BadRequest(value),
23921 _ => common::Error::Failure(response),
23922 });
23923 }
23924 let response = {
23925 let bytes = common::to_bytes(body).await.unwrap_or_default();
23926 let encoded = common::to_string(&bytes);
23927 match serde_json::from_str(&encoded) {
23928 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23929 Err(error) => {
23930 dlg.response_json_decode_error(&encoded, &error);
23931 return Err(common::Error::JsonDecodeError(
23932 encoded.to_string(),
23933 error,
23934 ));
23935 }
23936 }
23937 };
23938
23939 dlg.finished(true);
23940 return Ok(response);
23941 }
23942 }
23943 }
23944 }
23945
23946 ///
23947 /// Sets the *request* property to the given value.
23948 ///
23949 /// Even though the property as already been set when instantiating this call,
23950 /// we provide this method for API completeness.
23951 pub fn request(mut self, new_value: Permission) -> PermissionPatchCall<'a, C> {
23952 self._request = new_value;
23953 self
23954 }
23955 /// The ID for the file or shared drive.
23956 ///
23957 /// Sets the *file id* path property to the given value.
23958 ///
23959 /// Even though the property as already been set when instantiating this call,
23960 /// we provide this method for API completeness.
23961 pub fn file_id(mut self, new_value: &str) -> PermissionPatchCall<'a, C> {
23962 self._file_id = new_value.to_string();
23963 self
23964 }
23965 /// The ID for the permission.
23966 ///
23967 /// Sets the *permission id* path property to the given value.
23968 ///
23969 /// Even though the property as already been set when instantiating this call,
23970 /// we provide this method for API completeness.
23971 pub fn permission_id(mut self, new_value: &str) -> PermissionPatchCall<'a, C> {
23972 self._permission_id = new_value.to_string();
23973 self
23974 }
23975 /// 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.
23976 ///
23977 /// Sets the *use domain admin access* query property to the given value.
23978 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionPatchCall<'a, C> {
23979 self._use_domain_admin_access = Some(new_value);
23980 self
23981 }
23982 /// Whether changing a role to `owner` downgrades the current owners to writers. Does nothing if the specified role is not `owner`.
23983 ///
23984 /// Sets the *transfer ownership* query property to the given value.
23985 pub fn transfer_ownership(mut self, new_value: bool) -> PermissionPatchCall<'a, C> {
23986 self._transfer_ownership = Some(new_value);
23987 self
23988 }
23989 /// Deprecated: Use `supportsAllDrives` instead.
23990 ///
23991 /// Sets the *supports team drives* query property to the given value.
23992 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionPatchCall<'a, C> {
23993 self._supports_team_drives = Some(new_value);
23994 self
23995 }
23996 /// Whether the requesting application supports both My Drives and shared drives.
23997 ///
23998 /// Sets the *supports all drives* query property to the given value.
23999 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionPatchCall<'a, C> {
24000 self._supports_all_drives = Some(new_value);
24001 self
24002 }
24003 /// Whether to remove the expiration date.
24004 ///
24005 /// Sets the *remove expiration* query property to the given value.
24006 pub fn remove_expiration(mut self, new_value: bool) -> PermissionPatchCall<'a, C> {
24007 self._remove_expiration = Some(new_value);
24008 self
24009 }
24010 /// Whether the request should enforce expansive access rules.
24011 ///
24012 /// Sets the *enforce expansive access* query property to the given value.
24013 pub fn enforce_expansive_access(mut self, new_value: bool) -> PermissionPatchCall<'a, C> {
24014 self._enforce_expansive_access = Some(new_value);
24015 self
24016 }
24017 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24018 /// while executing the actual API request.
24019 ///
24020 /// ````text
24021 /// It should be used to handle progress information, and to implement a certain level of resilience.
24022 /// ````
24023 ///
24024 /// Sets the *delegate* property to the given value.
24025 pub fn delegate(
24026 mut self,
24027 new_value: &'a mut dyn common::Delegate,
24028 ) -> PermissionPatchCall<'a, C> {
24029 self._delegate = Some(new_value);
24030 self
24031 }
24032
24033 /// Set any additional parameter of the query string used in the request.
24034 /// It should be used to set parameters which are not yet available through their own
24035 /// setters.
24036 ///
24037 /// Please note that this method must not be used to set any of the known parameters
24038 /// which have their own setter method. If done anyway, the request will fail.
24039 ///
24040 /// # Additional Parameters
24041 ///
24042 /// * *$.xgafv* (query-string) - V1 error format.
24043 /// * *access_token* (query-string) - OAuth access token.
24044 /// * *alt* (query-string) - Data format for response.
24045 /// * *callback* (query-string) - JSONP
24046 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24047 /// * *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.
24048 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24049 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24050 /// * *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.
24051 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24052 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24053 pub fn param<T>(mut self, name: T, value: T) -> PermissionPatchCall<'a, C>
24054 where
24055 T: AsRef<str>,
24056 {
24057 self._additional_params
24058 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24059 self
24060 }
24061
24062 /// Identifies the authorization scope for the method you are building.
24063 ///
24064 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24065 /// [`Scope::Full`].
24066 ///
24067 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24068 /// tokens for more than one scope.
24069 ///
24070 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24071 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24072 /// sufficient, a read-write scope will do as well.
24073 pub fn add_scope<St>(mut self, scope: St) -> PermissionPatchCall<'a, C>
24074 where
24075 St: AsRef<str>,
24076 {
24077 self._scopes.insert(String::from(scope.as_ref()));
24078 self
24079 }
24080 /// Identifies the authorization scope(s) for the method you are building.
24081 ///
24082 /// See [`Self::add_scope()`] for details.
24083 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionPatchCall<'a, C>
24084 where
24085 I: IntoIterator<Item = St>,
24086 St: AsRef<str>,
24087 {
24088 self._scopes
24089 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24090 self
24091 }
24092
24093 /// Removes all scopes, and no default scope will be used either.
24094 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24095 /// for details).
24096 pub fn clear_scopes(mut self) -> PermissionPatchCall<'a, C> {
24097 self._scopes.clear();
24098 self
24099 }
24100}
24101
24102/// Updates a permission. **Warning:** Concurrent permissions operations on the same file are not supported; only the last update is applied.
24103///
24104/// A builder for the *update* method supported by a *permission* resource.
24105/// It is not used directly, but through a [`PermissionMethods`] instance.
24106///
24107/// # Example
24108///
24109/// Instantiate a resource method builder
24110///
24111/// ```test_harness,no_run
24112/// # extern crate hyper;
24113/// # extern crate hyper_rustls;
24114/// # extern crate google_drive2 as drive2;
24115/// use drive2::api::Permission;
24116/// # async fn dox() {
24117/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24118///
24119/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24120/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24121/// # .with_native_roots()
24122/// # .unwrap()
24123/// # .https_only()
24124/// # .enable_http2()
24125/// # .build();
24126///
24127/// # let executor = hyper_util::rt::TokioExecutor::new();
24128/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24129/// # secret,
24130/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24131/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24132/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24133/// # ),
24134/// # ).build().await.unwrap();
24135///
24136/// # let client = hyper_util::client::legacy::Client::builder(
24137/// # hyper_util::rt::TokioExecutor::new()
24138/// # )
24139/// # .build(
24140/// # hyper_rustls::HttpsConnectorBuilder::new()
24141/// # .with_native_roots()
24142/// # .unwrap()
24143/// # .https_or_http()
24144/// # .enable_http2()
24145/// # .build()
24146/// # );
24147/// # let mut hub = DriveHub::new(client, auth);
24148/// // As the method needs a request, you would usually fill it with the desired information
24149/// // into the respective structure. Some of the parts shown here might not be applicable !
24150/// // Values shown here are possibly random and not representative !
24151/// let mut req = Permission::default();
24152///
24153/// // You can configure optional parameters by calling the respective setters at will, and
24154/// // execute the final call using `doit()`.
24155/// // Values shown here are possibly random and not representative !
24156/// let result = hub.permissions().update(req, "fileId", "permissionId")
24157/// .use_domain_admin_access(false)
24158/// .transfer_ownership(false)
24159/// .supports_team_drives(false)
24160/// .supports_all_drives(true)
24161/// .remove_expiration(true)
24162/// .enforce_expansive_access(false)
24163/// .doit().await;
24164/// # }
24165/// ```
24166pub struct PermissionUpdateCall<'a, C>
24167where
24168 C: 'a,
24169{
24170 hub: &'a DriveHub<C>,
24171 _request: Permission,
24172 _file_id: String,
24173 _permission_id: String,
24174 _use_domain_admin_access: Option<bool>,
24175 _transfer_ownership: Option<bool>,
24176 _supports_team_drives: Option<bool>,
24177 _supports_all_drives: Option<bool>,
24178 _remove_expiration: Option<bool>,
24179 _enforce_expansive_access: Option<bool>,
24180 _delegate: Option<&'a mut dyn common::Delegate>,
24181 _additional_params: HashMap<String, String>,
24182 _scopes: BTreeSet<String>,
24183}
24184
24185impl<'a, C> common::CallBuilder for PermissionUpdateCall<'a, C> {}
24186
24187impl<'a, C> PermissionUpdateCall<'a, C>
24188where
24189 C: common::Connector,
24190{
24191 /// Perform the operation you have build so far.
24192 pub async fn doit(mut self) -> common::Result<(common::Response, Permission)> {
24193 use std::borrow::Cow;
24194 use std::io::{Read, Seek};
24195
24196 use common::{url::Params, ToParts};
24197 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24198
24199 let mut dd = common::DefaultDelegate;
24200 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24201 dlg.begin(common::MethodInfo {
24202 id: "drive.permissions.update",
24203 http_method: hyper::Method::PUT,
24204 });
24205
24206 for &field in [
24207 "alt",
24208 "fileId",
24209 "permissionId",
24210 "useDomainAdminAccess",
24211 "transferOwnership",
24212 "supportsTeamDrives",
24213 "supportsAllDrives",
24214 "removeExpiration",
24215 "enforceExpansiveAccess",
24216 ]
24217 .iter()
24218 {
24219 if self._additional_params.contains_key(field) {
24220 dlg.finished(false);
24221 return Err(common::Error::FieldClash(field));
24222 }
24223 }
24224
24225 let mut params = Params::with_capacity(11 + self._additional_params.len());
24226 params.push("fileId", self._file_id);
24227 params.push("permissionId", self._permission_id);
24228 if let Some(value) = self._use_domain_admin_access.as_ref() {
24229 params.push("useDomainAdminAccess", value.to_string());
24230 }
24231 if let Some(value) = self._transfer_ownership.as_ref() {
24232 params.push("transferOwnership", value.to_string());
24233 }
24234 if let Some(value) = self._supports_team_drives.as_ref() {
24235 params.push("supportsTeamDrives", value.to_string());
24236 }
24237 if let Some(value) = self._supports_all_drives.as_ref() {
24238 params.push("supportsAllDrives", value.to_string());
24239 }
24240 if let Some(value) = self._remove_expiration.as_ref() {
24241 params.push("removeExpiration", value.to_string());
24242 }
24243 if let Some(value) = self._enforce_expansive_access.as_ref() {
24244 params.push("enforceExpansiveAccess", value.to_string());
24245 }
24246
24247 params.extend(self._additional_params.iter());
24248
24249 params.push("alt", "json");
24250 let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}";
24251 if self._scopes.is_empty() {
24252 self._scopes.insert(Scope::Full.as_ref().to_string());
24253 }
24254
24255 #[allow(clippy::single_element_loop)]
24256 for &(find_this, param_name) in
24257 [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter()
24258 {
24259 url = params.uri_replacement(url, param_name, find_this, false);
24260 }
24261 {
24262 let to_remove = ["permissionId", "fileId"];
24263 params.remove_params(&to_remove);
24264 }
24265
24266 let url = params.parse_with_url(&url);
24267
24268 let mut json_mime_type = mime::APPLICATION_JSON;
24269 let mut request_value_reader = {
24270 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24271 common::remove_json_null_values(&mut value);
24272 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24273 serde_json::to_writer(&mut dst, &value).unwrap();
24274 dst
24275 };
24276 let request_size = request_value_reader
24277 .seek(std::io::SeekFrom::End(0))
24278 .unwrap();
24279 request_value_reader
24280 .seek(std::io::SeekFrom::Start(0))
24281 .unwrap();
24282
24283 loop {
24284 let token = match self
24285 .hub
24286 .auth
24287 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24288 .await
24289 {
24290 Ok(token) => token,
24291 Err(e) => match dlg.token(e) {
24292 Ok(token) => token,
24293 Err(e) => {
24294 dlg.finished(false);
24295 return Err(common::Error::MissingToken(e));
24296 }
24297 },
24298 };
24299 request_value_reader
24300 .seek(std::io::SeekFrom::Start(0))
24301 .unwrap();
24302 let mut req_result = {
24303 let client = &self.hub.client;
24304 dlg.pre_request();
24305 let mut req_builder = hyper::Request::builder()
24306 .method(hyper::Method::PUT)
24307 .uri(url.as_str())
24308 .header(USER_AGENT, self.hub._user_agent.clone());
24309
24310 if let Some(token) = token.as_ref() {
24311 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24312 }
24313
24314 let request = req_builder
24315 .header(CONTENT_TYPE, json_mime_type.to_string())
24316 .header(CONTENT_LENGTH, request_size as u64)
24317 .body(common::to_body(
24318 request_value_reader.get_ref().clone().into(),
24319 ));
24320
24321 client.request(request.unwrap()).await
24322 };
24323
24324 match req_result {
24325 Err(err) => {
24326 if let common::Retry::After(d) = dlg.http_error(&err) {
24327 sleep(d).await;
24328 continue;
24329 }
24330 dlg.finished(false);
24331 return Err(common::Error::HttpError(err));
24332 }
24333 Ok(res) => {
24334 let (mut parts, body) = res.into_parts();
24335 let mut body = common::Body::new(body);
24336 if !parts.status.is_success() {
24337 let bytes = common::to_bytes(body).await.unwrap_or_default();
24338 let error = serde_json::from_str(&common::to_string(&bytes));
24339 let response = common::to_response(parts, bytes.into());
24340
24341 if let common::Retry::After(d) =
24342 dlg.http_failure(&response, error.as_ref().ok())
24343 {
24344 sleep(d).await;
24345 continue;
24346 }
24347
24348 dlg.finished(false);
24349
24350 return Err(match error {
24351 Ok(value) => common::Error::BadRequest(value),
24352 _ => common::Error::Failure(response),
24353 });
24354 }
24355 let response = {
24356 let bytes = common::to_bytes(body).await.unwrap_or_default();
24357 let encoded = common::to_string(&bytes);
24358 match serde_json::from_str(&encoded) {
24359 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24360 Err(error) => {
24361 dlg.response_json_decode_error(&encoded, &error);
24362 return Err(common::Error::JsonDecodeError(
24363 encoded.to_string(),
24364 error,
24365 ));
24366 }
24367 }
24368 };
24369
24370 dlg.finished(true);
24371 return Ok(response);
24372 }
24373 }
24374 }
24375 }
24376
24377 ///
24378 /// Sets the *request* property to the given value.
24379 ///
24380 /// Even though the property as already been set when instantiating this call,
24381 /// we provide this method for API completeness.
24382 pub fn request(mut self, new_value: Permission) -> PermissionUpdateCall<'a, C> {
24383 self._request = new_value;
24384 self
24385 }
24386 /// The ID for the file or shared drive.
24387 ///
24388 /// Sets the *file id* path property to the given value.
24389 ///
24390 /// Even though the property as already been set when instantiating this call,
24391 /// we provide this method for API completeness.
24392 pub fn file_id(mut self, new_value: &str) -> PermissionUpdateCall<'a, C> {
24393 self._file_id = new_value.to_string();
24394 self
24395 }
24396 /// The ID for the permission.
24397 ///
24398 /// Sets the *permission id* path property to the given value.
24399 ///
24400 /// Even though the property as already been set when instantiating this call,
24401 /// we provide this method for API completeness.
24402 pub fn permission_id(mut self, new_value: &str) -> PermissionUpdateCall<'a, C> {
24403 self._permission_id = new_value.to_string();
24404 self
24405 }
24406 /// 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.
24407 ///
24408 /// Sets the *use domain admin access* query property to the given value.
24409 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
24410 self._use_domain_admin_access = Some(new_value);
24411 self
24412 }
24413 /// Whether changing a role to `owner` downgrades the current owners to writers. Does nothing if the specified role is not `owner`.
24414 ///
24415 /// Sets the *transfer ownership* query property to the given value.
24416 pub fn transfer_ownership(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
24417 self._transfer_ownership = Some(new_value);
24418 self
24419 }
24420 /// Deprecated: Use `supportsAllDrives` instead.
24421 ///
24422 /// Sets the *supports team drives* query property to the given value.
24423 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
24424 self._supports_team_drives = Some(new_value);
24425 self
24426 }
24427 /// Whether the requesting application supports both My Drives and shared drives.
24428 ///
24429 /// Sets the *supports all drives* query property to the given value.
24430 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
24431 self._supports_all_drives = Some(new_value);
24432 self
24433 }
24434 /// Whether to remove the expiration date.
24435 ///
24436 /// Sets the *remove expiration* query property to the given value.
24437 pub fn remove_expiration(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
24438 self._remove_expiration = Some(new_value);
24439 self
24440 }
24441 /// Whether the request should enforce expansive access rules.
24442 ///
24443 /// Sets the *enforce expansive access* query property to the given value.
24444 pub fn enforce_expansive_access(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
24445 self._enforce_expansive_access = Some(new_value);
24446 self
24447 }
24448 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24449 /// while executing the actual API request.
24450 ///
24451 /// ````text
24452 /// It should be used to handle progress information, and to implement a certain level of resilience.
24453 /// ````
24454 ///
24455 /// Sets the *delegate* property to the given value.
24456 pub fn delegate(
24457 mut self,
24458 new_value: &'a mut dyn common::Delegate,
24459 ) -> PermissionUpdateCall<'a, C> {
24460 self._delegate = Some(new_value);
24461 self
24462 }
24463
24464 /// Set any additional parameter of the query string used in the request.
24465 /// It should be used to set parameters which are not yet available through their own
24466 /// setters.
24467 ///
24468 /// Please note that this method must not be used to set any of the known parameters
24469 /// which have their own setter method. If done anyway, the request will fail.
24470 ///
24471 /// # Additional Parameters
24472 ///
24473 /// * *$.xgafv* (query-string) - V1 error format.
24474 /// * *access_token* (query-string) - OAuth access token.
24475 /// * *alt* (query-string) - Data format for response.
24476 /// * *callback* (query-string) - JSONP
24477 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24478 /// * *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.
24479 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24480 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24481 /// * *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.
24482 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24483 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24484 pub fn param<T>(mut self, name: T, value: T) -> PermissionUpdateCall<'a, C>
24485 where
24486 T: AsRef<str>,
24487 {
24488 self._additional_params
24489 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24490 self
24491 }
24492
24493 /// Identifies the authorization scope for the method you are building.
24494 ///
24495 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24496 /// [`Scope::Full`].
24497 ///
24498 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24499 /// tokens for more than one scope.
24500 ///
24501 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24502 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24503 /// sufficient, a read-write scope will do as well.
24504 pub fn add_scope<St>(mut self, scope: St) -> PermissionUpdateCall<'a, C>
24505 where
24506 St: AsRef<str>,
24507 {
24508 self._scopes.insert(String::from(scope.as_ref()));
24509 self
24510 }
24511 /// Identifies the authorization scope(s) for the method you are building.
24512 ///
24513 /// See [`Self::add_scope()`] for details.
24514 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionUpdateCall<'a, C>
24515 where
24516 I: IntoIterator<Item = St>,
24517 St: AsRef<str>,
24518 {
24519 self._scopes
24520 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24521 self
24522 }
24523
24524 /// Removes all scopes, and no default scope will be used either.
24525 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24526 /// for details).
24527 pub fn clear_scopes(mut self) -> PermissionUpdateCall<'a, C> {
24528 self._scopes.clear();
24529 self
24530 }
24531}
24532
24533/// Deletes a property.
24534///
24535/// A builder for the *delete* method supported by a *property* resource.
24536/// It is not used directly, but through a [`PropertyMethods`] instance.
24537///
24538/// # Example
24539///
24540/// Instantiate a resource method builder
24541///
24542/// ```test_harness,no_run
24543/// # extern crate hyper;
24544/// # extern crate hyper_rustls;
24545/// # extern crate google_drive2 as drive2;
24546/// # async fn dox() {
24547/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24548///
24549/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24550/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24551/// # .with_native_roots()
24552/// # .unwrap()
24553/// # .https_only()
24554/// # .enable_http2()
24555/// # .build();
24556///
24557/// # let executor = hyper_util::rt::TokioExecutor::new();
24558/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24559/// # secret,
24560/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24561/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24562/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24563/// # ),
24564/// # ).build().await.unwrap();
24565///
24566/// # let client = hyper_util::client::legacy::Client::builder(
24567/// # hyper_util::rt::TokioExecutor::new()
24568/// # )
24569/// # .build(
24570/// # hyper_rustls::HttpsConnectorBuilder::new()
24571/// # .with_native_roots()
24572/// # .unwrap()
24573/// # .https_or_http()
24574/// # .enable_http2()
24575/// # .build()
24576/// # );
24577/// # let mut hub = DriveHub::new(client, auth);
24578/// // You can configure optional parameters by calling the respective setters at will, and
24579/// // execute the final call using `doit()`.
24580/// // Values shown here are possibly random and not representative !
24581/// let result = hub.properties().delete("fileId", "propertyKey")
24582/// .visibility("dolores")
24583/// .doit().await;
24584/// # }
24585/// ```
24586pub struct PropertyDeleteCall<'a, C>
24587where
24588 C: 'a,
24589{
24590 hub: &'a DriveHub<C>,
24591 _file_id: String,
24592 _property_key: String,
24593 _visibility: Option<String>,
24594 _delegate: Option<&'a mut dyn common::Delegate>,
24595 _additional_params: HashMap<String, String>,
24596 _scopes: BTreeSet<String>,
24597}
24598
24599impl<'a, C> common::CallBuilder for PropertyDeleteCall<'a, C> {}
24600
24601impl<'a, C> PropertyDeleteCall<'a, C>
24602where
24603 C: common::Connector,
24604{
24605 /// Perform the operation you have build so far.
24606 pub async fn doit(mut self) -> common::Result<common::Response> {
24607 use std::borrow::Cow;
24608 use std::io::{Read, Seek};
24609
24610 use common::{url::Params, ToParts};
24611 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24612
24613 let mut dd = common::DefaultDelegate;
24614 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24615 dlg.begin(common::MethodInfo {
24616 id: "drive.properties.delete",
24617 http_method: hyper::Method::DELETE,
24618 });
24619
24620 for &field in ["fileId", "propertyKey", "visibility"].iter() {
24621 if self._additional_params.contains_key(field) {
24622 dlg.finished(false);
24623 return Err(common::Error::FieldClash(field));
24624 }
24625 }
24626
24627 let mut params = Params::with_capacity(4 + self._additional_params.len());
24628 params.push("fileId", self._file_id);
24629 params.push("propertyKey", self._property_key);
24630 if let Some(value) = self._visibility.as_ref() {
24631 params.push("visibility", value);
24632 }
24633
24634 params.extend(self._additional_params.iter());
24635
24636 let mut url = self.hub._base_url.clone() + "files/{fileId}/properties/{propertyKey}";
24637 if self._scopes.is_empty() {
24638 self._scopes.insert(Scope::Full.as_ref().to_string());
24639 }
24640
24641 #[allow(clippy::single_element_loop)]
24642 for &(find_this, param_name) in
24643 [("{fileId}", "fileId"), ("{propertyKey}", "propertyKey")].iter()
24644 {
24645 url = params.uri_replacement(url, param_name, find_this, false);
24646 }
24647 {
24648 let to_remove = ["propertyKey", "fileId"];
24649 params.remove_params(&to_remove);
24650 }
24651
24652 let url = params.parse_with_url(&url);
24653
24654 loop {
24655 let token = match self
24656 .hub
24657 .auth
24658 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24659 .await
24660 {
24661 Ok(token) => token,
24662 Err(e) => match dlg.token(e) {
24663 Ok(token) => token,
24664 Err(e) => {
24665 dlg.finished(false);
24666 return Err(common::Error::MissingToken(e));
24667 }
24668 },
24669 };
24670 let mut req_result = {
24671 let client = &self.hub.client;
24672 dlg.pre_request();
24673 let mut req_builder = hyper::Request::builder()
24674 .method(hyper::Method::DELETE)
24675 .uri(url.as_str())
24676 .header(USER_AGENT, self.hub._user_agent.clone());
24677
24678 if let Some(token) = token.as_ref() {
24679 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24680 }
24681
24682 let request = req_builder
24683 .header(CONTENT_LENGTH, 0_u64)
24684 .body(common::to_body::<String>(None));
24685
24686 client.request(request.unwrap()).await
24687 };
24688
24689 match req_result {
24690 Err(err) => {
24691 if let common::Retry::After(d) = dlg.http_error(&err) {
24692 sleep(d).await;
24693 continue;
24694 }
24695 dlg.finished(false);
24696 return Err(common::Error::HttpError(err));
24697 }
24698 Ok(res) => {
24699 let (mut parts, body) = res.into_parts();
24700 let mut body = common::Body::new(body);
24701 if !parts.status.is_success() {
24702 let bytes = common::to_bytes(body).await.unwrap_or_default();
24703 let error = serde_json::from_str(&common::to_string(&bytes));
24704 let response = common::to_response(parts, bytes.into());
24705
24706 if let common::Retry::After(d) =
24707 dlg.http_failure(&response, error.as_ref().ok())
24708 {
24709 sleep(d).await;
24710 continue;
24711 }
24712
24713 dlg.finished(false);
24714
24715 return Err(match error {
24716 Ok(value) => common::Error::BadRequest(value),
24717 _ => common::Error::Failure(response),
24718 });
24719 }
24720 let response = common::Response::from_parts(parts, body);
24721
24722 dlg.finished(true);
24723 return Ok(response);
24724 }
24725 }
24726 }
24727 }
24728
24729 /// The ID of the file.
24730 ///
24731 /// Sets the *file id* path property to the given value.
24732 ///
24733 /// Even though the property as already been set when instantiating this call,
24734 /// we provide this method for API completeness.
24735 pub fn file_id(mut self, new_value: &str) -> PropertyDeleteCall<'a, C> {
24736 self._file_id = new_value.to_string();
24737 self
24738 }
24739 /// The key of the property.
24740 ///
24741 /// Sets the *property key* path property to the given value.
24742 ///
24743 /// Even though the property as already been set when instantiating this call,
24744 /// we provide this method for API completeness.
24745 pub fn property_key(mut self, new_value: &str) -> PropertyDeleteCall<'a, C> {
24746 self._property_key = new_value.to_string();
24747 self
24748 }
24749 /// The visibility of the property.
24750 ///
24751 /// Sets the *visibility* query property to the given value.
24752 pub fn visibility(mut self, new_value: &str) -> PropertyDeleteCall<'a, C> {
24753 self._visibility = Some(new_value.to_string());
24754 self
24755 }
24756 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24757 /// while executing the actual API request.
24758 ///
24759 /// ````text
24760 /// It should be used to handle progress information, and to implement a certain level of resilience.
24761 /// ````
24762 ///
24763 /// Sets the *delegate* property to the given value.
24764 pub fn delegate(
24765 mut self,
24766 new_value: &'a mut dyn common::Delegate,
24767 ) -> PropertyDeleteCall<'a, C> {
24768 self._delegate = Some(new_value);
24769 self
24770 }
24771
24772 /// Set any additional parameter of the query string used in the request.
24773 /// It should be used to set parameters which are not yet available through their own
24774 /// setters.
24775 ///
24776 /// Please note that this method must not be used to set any of the known parameters
24777 /// which have their own setter method. If done anyway, the request will fail.
24778 ///
24779 /// # Additional Parameters
24780 ///
24781 /// * *$.xgafv* (query-string) - V1 error format.
24782 /// * *access_token* (query-string) - OAuth access token.
24783 /// * *alt* (query-string) - Data format for response.
24784 /// * *callback* (query-string) - JSONP
24785 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24786 /// * *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.
24787 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24788 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24789 /// * *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.
24790 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24791 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24792 pub fn param<T>(mut self, name: T, value: T) -> PropertyDeleteCall<'a, C>
24793 where
24794 T: AsRef<str>,
24795 {
24796 self._additional_params
24797 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24798 self
24799 }
24800
24801 /// Identifies the authorization scope for the method you are building.
24802 ///
24803 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24804 /// [`Scope::Full`].
24805 ///
24806 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24807 /// tokens for more than one scope.
24808 ///
24809 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24810 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24811 /// sufficient, a read-write scope will do as well.
24812 pub fn add_scope<St>(mut self, scope: St) -> PropertyDeleteCall<'a, C>
24813 where
24814 St: AsRef<str>,
24815 {
24816 self._scopes.insert(String::from(scope.as_ref()));
24817 self
24818 }
24819 /// Identifies the authorization scope(s) for the method you are building.
24820 ///
24821 /// See [`Self::add_scope()`] for details.
24822 pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyDeleteCall<'a, C>
24823 where
24824 I: IntoIterator<Item = St>,
24825 St: AsRef<str>,
24826 {
24827 self._scopes
24828 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24829 self
24830 }
24831
24832 /// Removes all scopes, and no default scope will be used either.
24833 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24834 /// for details).
24835 pub fn clear_scopes(mut self) -> PropertyDeleteCall<'a, C> {
24836 self._scopes.clear();
24837 self
24838 }
24839}
24840
24841/// Gets a property by its key.
24842///
24843/// A builder for the *get* method supported by a *property* resource.
24844/// It is not used directly, but through a [`PropertyMethods`] instance.
24845///
24846/// # Example
24847///
24848/// Instantiate a resource method builder
24849///
24850/// ```test_harness,no_run
24851/// # extern crate hyper;
24852/// # extern crate hyper_rustls;
24853/// # extern crate google_drive2 as drive2;
24854/// # async fn dox() {
24855/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24856///
24857/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24858/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24859/// # .with_native_roots()
24860/// # .unwrap()
24861/// # .https_only()
24862/// # .enable_http2()
24863/// # .build();
24864///
24865/// # let executor = hyper_util::rt::TokioExecutor::new();
24866/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24867/// # secret,
24868/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24869/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24870/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24871/// # ),
24872/// # ).build().await.unwrap();
24873///
24874/// # let client = hyper_util::client::legacy::Client::builder(
24875/// # hyper_util::rt::TokioExecutor::new()
24876/// # )
24877/// # .build(
24878/// # hyper_rustls::HttpsConnectorBuilder::new()
24879/// # .with_native_roots()
24880/// # .unwrap()
24881/// # .https_or_http()
24882/// # .enable_http2()
24883/// # .build()
24884/// # );
24885/// # let mut hub = DriveHub::new(client, auth);
24886/// // You can configure optional parameters by calling the respective setters at will, and
24887/// // execute the final call using `doit()`.
24888/// // Values shown here are possibly random and not representative !
24889/// let result = hub.properties().get("fileId", "propertyKey")
24890/// .visibility("accusam")
24891/// .doit().await;
24892/// # }
24893/// ```
24894pub struct PropertyGetCall<'a, C>
24895where
24896 C: 'a,
24897{
24898 hub: &'a DriveHub<C>,
24899 _file_id: String,
24900 _property_key: String,
24901 _visibility: Option<String>,
24902 _delegate: Option<&'a mut dyn common::Delegate>,
24903 _additional_params: HashMap<String, String>,
24904 _scopes: BTreeSet<String>,
24905}
24906
24907impl<'a, C> common::CallBuilder for PropertyGetCall<'a, C> {}
24908
24909impl<'a, C> PropertyGetCall<'a, C>
24910where
24911 C: common::Connector,
24912{
24913 /// Perform the operation you have build so far.
24914 pub async fn doit(mut self) -> common::Result<(common::Response, Property)> {
24915 use std::borrow::Cow;
24916 use std::io::{Read, Seek};
24917
24918 use common::{url::Params, ToParts};
24919 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24920
24921 let mut dd = common::DefaultDelegate;
24922 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24923 dlg.begin(common::MethodInfo {
24924 id: "drive.properties.get",
24925 http_method: hyper::Method::GET,
24926 });
24927
24928 for &field in ["alt", "fileId", "propertyKey", "visibility"].iter() {
24929 if self._additional_params.contains_key(field) {
24930 dlg.finished(false);
24931 return Err(common::Error::FieldClash(field));
24932 }
24933 }
24934
24935 let mut params = Params::with_capacity(5 + self._additional_params.len());
24936 params.push("fileId", self._file_id);
24937 params.push("propertyKey", self._property_key);
24938 if let Some(value) = self._visibility.as_ref() {
24939 params.push("visibility", value);
24940 }
24941
24942 params.extend(self._additional_params.iter());
24943
24944 params.push("alt", "json");
24945 let mut url = self.hub._base_url.clone() + "files/{fileId}/properties/{propertyKey}";
24946 if self._scopes.is_empty() {
24947 self._scopes
24948 .insert(Scope::MeetReadonly.as_ref().to_string());
24949 }
24950
24951 #[allow(clippy::single_element_loop)]
24952 for &(find_this, param_name) in
24953 [("{fileId}", "fileId"), ("{propertyKey}", "propertyKey")].iter()
24954 {
24955 url = params.uri_replacement(url, param_name, find_this, false);
24956 }
24957 {
24958 let to_remove = ["propertyKey", "fileId"];
24959 params.remove_params(&to_remove);
24960 }
24961
24962 let url = params.parse_with_url(&url);
24963
24964 loop {
24965 let token = match self
24966 .hub
24967 .auth
24968 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24969 .await
24970 {
24971 Ok(token) => token,
24972 Err(e) => match dlg.token(e) {
24973 Ok(token) => token,
24974 Err(e) => {
24975 dlg.finished(false);
24976 return Err(common::Error::MissingToken(e));
24977 }
24978 },
24979 };
24980 let mut req_result = {
24981 let client = &self.hub.client;
24982 dlg.pre_request();
24983 let mut req_builder = hyper::Request::builder()
24984 .method(hyper::Method::GET)
24985 .uri(url.as_str())
24986 .header(USER_AGENT, self.hub._user_agent.clone());
24987
24988 if let Some(token) = token.as_ref() {
24989 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24990 }
24991
24992 let request = req_builder
24993 .header(CONTENT_LENGTH, 0_u64)
24994 .body(common::to_body::<String>(None));
24995
24996 client.request(request.unwrap()).await
24997 };
24998
24999 match req_result {
25000 Err(err) => {
25001 if let common::Retry::After(d) = dlg.http_error(&err) {
25002 sleep(d).await;
25003 continue;
25004 }
25005 dlg.finished(false);
25006 return Err(common::Error::HttpError(err));
25007 }
25008 Ok(res) => {
25009 let (mut parts, body) = res.into_parts();
25010 let mut body = common::Body::new(body);
25011 if !parts.status.is_success() {
25012 let bytes = common::to_bytes(body).await.unwrap_or_default();
25013 let error = serde_json::from_str(&common::to_string(&bytes));
25014 let response = common::to_response(parts, bytes.into());
25015
25016 if let common::Retry::After(d) =
25017 dlg.http_failure(&response, error.as_ref().ok())
25018 {
25019 sleep(d).await;
25020 continue;
25021 }
25022
25023 dlg.finished(false);
25024
25025 return Err(match error {
25026 Ok(value) => common::Error::BadRequest(value),
25027 _ => common::Error::Failure(response),
25028 });
25029 }
25030 let response = {
25031 let bytes = common::to_bytes(body).await.unwrap_or_default();
25032 let encoded = common::to_string(&bytes);
25033 match serde_json::from_str(&encoded) {
25034 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25035 Err(error) => {
25036 dlg.response_json_decode_error(&encoded, &error);
25037 return Err(common::Error::JsonDecodeError(
25038 encoded.to_string(),
25039 error,
25040 ));
25041 }
25042 }
25043 };
25044
25045 dlg.finished(true);
25046 return Ok(response);
25047 }
25048 }
25049 }
25050 }
25051
25052 /// The ID of the file.
25053 ///
25054 /// Sets the *file id* path property to the given value.
25055 ///
25056 /// Even though the property as already been set when instantiating this call,
25057 /// we provide this method for API completeness.
25058 pub fn file_id(mut self, new_value: &str) -> PropertyGetCall<'a, C> {
25059 self._file_id = new_value.to_string();
25060 self
25061 }
25062 /// The key of the property.
25063 ///
25064 /// Sets the *property key* path property to the given value.
25065 ///
25066 /// Even though the property as already been set when instantiating this call,
25067 /// we provide this method for API completeness.
25068 pub fn property_key(mut self, new_value: &str) -> PropertyGetCall<'a, C> {
25069 self._property_key = new_value.to_string();
25070 self
25071 }
25072 /// The visibility of the property.
25073 ///
25074 /// Sets the *visibility* query property to the given value.
25075 pub fn visibility(mut self, new_value: &str) -> PropertyGetCall<'a, C> {
25076 self._visibility = Some(new_value.to_string());
25077 self
25078 }
25079 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25080 /// while executing the actual API request.
25081 ///
25082 /// ````text
25083 /// It should be used to handle progress information, and to implement a certain level of resilience.
25084 /// ````
25085 ///
25086 /// Sets the *delegate* property to the given value.
25087 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PropertyGetCall<'a, C> {
25088 self._delegate = Some(new_value);
25089 self
25090 }
25091
25092 /// Set any additional parameter of the query string used in the request.
25093 /// It should be used to set parameters which are not yet available through their own
25094 /// setters.
25095 ///
25096 /// Please note that this method must not be used to set any of the known parameters
25097 /// which have their own setter method. If done anyway, the request will fail.
25098 ///
25099 /// # Additional Parameters
25100 ///
25101 /// * *$.xgafv* (query-string) - V1 error format.
25102 /// * *access_token* (query-string) - OAuth access token.
25103 /// * *alt* (query-string) - Data format for response.
25104 /// * *callback* (query-string) - JSONP
25105 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25106 /// * *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.
25107 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25108 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25109 /// * *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.
25110 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25111 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25112 pub fn param<T>(mut self, name: T, value: T) -> PropertyGetCall<'a, C>
25113 where
25114 T: AsRef<str>,
25115 {
25116 self._additional_params
25117 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25118 self
25119 }
25120
25121 /// Identifies the authorization scope for the method you are building.
25122 ///
25123 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25124 /// [`Scope::MeetReadonly`].
25125 ///
25126 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25127 /// tokens for more than one scope.
25128 ///
25129 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25130 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25131 /// sufficient, a read-write scope will do as well.
25132 pub fn add_scope<St>(mut self, scope: St) -> PropertyGetCall<'a, C>
25133 where
25134 St: AsRef<str>,
25135 {
25136 self._scopes.insert(String::from(scope.as_ref()));
25137 self
25138 }
25139 /// Identifies the authorization scope(s) for the method you are building.
25140 ///
25141 /// See [`Self::add_scope()`] for details.
25142 pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyGetCall<'a, C>
25143 where
25144 I: IntoIterator<Item = St>,
25145 St: AsRef<str>,
25146 {
25147 self._scopes
25148 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25149 self
25150 }
25151
25152 /// Removes all scopes, and no default scope will be used either.
25153 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25154 /// for details).
25155 pub fn clear_scopes(mut self) -> PropertyGetCall<'a, C> {
25156 self._scopes.clear();
25157 self
25158 }
25159}
25160
25161/// Adds a property to a file, or updates it if it already exists.
25162///
25163/// A builder for the *insert* method supported by a *property* resource.
25164/// It is not used directly, but through a [`PropertyMethods`] instance.
25165///
25166/// # Example
25167///
25168/// Instantiate a resource method builder
25169///
25170/// ```test_harness,no_run
25171/// # extern crate hyper;
25172/// # extern crate hyper_rustls;
25173/// # extern crate google_drive2 as drive2;
25174/// use drive2::api::Property;
25175/// # async fn dox() {
25176/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25177///
25178/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25179/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25180/// # .with_native_roots()
25181/// # .unwrap()
25182/// # .https_only()
25183/// # .enable_http2()
25184/// # .build();
25185///
25186/// # let executor = hyper_util::rt::TokioExecutor::new();
25187/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25188/// # secret,
25189/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25190/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25191/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25192/// # ),
25193/// # ).build().await.unwrap();
25194///
25195/// # let client = hyper_util::client::legacy::Client::builder(
25196/// # hyper_util::rt::TokioExecutor::new()
25197/// # )
25198/// # .build(
25199/// # hyper_rustls::HttpsConnectorBuilder::new()
25200/// # .with_native_roots()
25201/// # .unwrap()
25202/// # .https_or_http()
25203/// # .enable_http2()
25204/// # .build()
25205/// # );
25206/// # let mut hub = DriveHub::new(client, auth);
25207/// // As the method needs a request, you would usually fill it with the desired information
25208/// // into the respective structure. Some of the parts shown here might not be applicable !
25209/// // Values shown here are possibly random and not representative !
25210/// let mut req = Property::default();
25211///
25212/// // You can configure optional parameters by calling the respective setters at will, and
25213/// // execute the final call using `doit()`.
25214/// // Values shown here are possibly random and not representative !
25215/// let result = hub.properties().insert(req, "fileId")
25216/// .doit().await;
25217/// # }
25218/// ```
25219pub struct PropertyInsertCall<'a, C>
25220where
25221 C: 'a,
25222{
25223 hub: &'a DriveHub<C>,
25224 _request: Property,
25225 _file_id: String,
25226 _delegate: Option<&'a mut dyn common::Delegate>,
25227 _additional_params: HashMap<String, String>,
25228 _scopes: BTreeSet<String>,
25229}
25230
25231impl<'a, C> common::CallBuilder for PropertyInsertCall<'a, C> {}
25232
25233impl<'a, C> PropertyInsertCall<'a, C>
25234where
25235 C: common::Connector,
25236{
25237 /// Perform the operation you have build so far.
25238 pub async fn doit(mut self) -> common::Result<(common::Response, Property)> {
25239 use std::borrow::Cow;
25240 use std::io::{Read, Seek};
25241
25242 use common::{url::Params, ToParts};
25243 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25244
25245 let mut dd = common::DefaultDelegate;
25246 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25247 dlg.begin(common::MethodInfo {
25248 id: "drive.properties.insert",
25249 http_method: hyper::Method::POST,
25250 });
25251
25252 for &field in ["alt", "fileId"].iter() {
25253 if self._additional_params.contains_key(field) {
25254 dlg.finished(false);
25255 return Err(common::Error::FieldClash(field));
25256 }
25257 }
25258
25259 let mut params = Params::with_capacity(4 + self._additional_params.len());
25260 params.push("fileId", self._file_id);
25261
25262 params.extend(self._additional_params.iter());
25263
25264 params.push("alt", "json");
25265 let mut url = self.hub._base_url.clone() + "files/{fileId}/properties";
25266 if self._scopes.is_empty() {
25267 self._scopes.insert(Scope::Full.as_ref().to_string());
25268 }
25269
25270 #[allow(clippy::single_element_loop)]
25271 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
25272 url = params.uri_replacement(url, param_name, find_this, false);
25273 }
25274 {
25275 let to_remove = ["fileId"];
25276 params.remove_params(&to_remove);
25277 }
25278
25279 let url = params.parse_with_url(&url);
25280
25281 let mut json_mime_type = mime::APPLICATION_JSON;
25282 let mut request_value_reader = {
25283 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25284 common::remove_json_null_values(&mut value);
25285 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25286 serde_json::to_writer(&mut dst, &value).unwrap();
25287 dst
25288 };
25289 let request_size = request_value_reader
25290 .seek(std::io::SeekFrom::End(0))
25291 .unwrap();
25292 request_value_reader
25293 .seek(std::io::SeekFrom::Start(0))
25294 .unwrap();
25295
25296 loop {
25297 let token = match self
25298 .hub
25299 .auth
25300 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25301 .await
25302 {
25303 Ok(token) => token,
25304 Err(e) => match dlg.token(e) {
25305 Ok(token) => token,
25306 Err(e) => {
25307 dlg.finished(false);
25308 return Err(common::Error::MissingToken(e));
25309 }
25310 },
25311 };
25312 request_value_reader
25313 .seek(std::io::SeekFrom::Start(0))
25314 .unwrap();
25315 let mut req_result = {
25316 let client = &self.hub.client;
25317 dlg.pre_request();
25318 let mut req_builder = hyper::Request::builder()
25319 .method(hyper::Method::POST)
25320 .uri(url.as_str())
25321 .header(USER_AGENT, self.hub._user_agent.clone());
25322
25323 if let Some(token) = token.as_ref() {
25324 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25325 }
25326
25327 let request = req_builder
25328 .header(CONTENT_TYPE, json_mime_type.to_string())
25329 .header(CONTENT_LENGTH, request_size as u64)
25330 .body(common::to_body(
25331 request_value_reader.get_ref().clone().into(),
25332 ));
25333
25334 client.request(request.unwrap()).await
25335 };
25336
25337 match req_result {
25338 Err(err) => {
25339 if let common::Retry::After(d) = dlg.http_error(&err) {
25340 sleep(d).await;
25341 continue;
25342 }
25343 dlg.finished(false);
25344 return Err(common::Error::HttpError(err));
25345 }
25346 Ok(res) => {
25347 let (mut parts, body) = res.into_parts();
25348 let mut body = common::Body::new(body);
25349 if !parts.status.is_success() {
25350 let bytes = common::to_bytes(body).await.unwrap_or_default();
25351 let error = serde_json::from_str(&common::to_string(&bytes));
25352 let response = common::to_response(parts, bytes.into());
25353
25354 if let common::Retry::After(d) =
25355 dlg.http_failure(&response, error.as_ref().ok())
25356 {
25357 sleep(d).await;
25358 continue;
25359 }
25360
25361 dlg.finished(false);
25362
25363 return Err(match error {
25364 Ok(value) => common::Error::BadRequest(value),
25365 _ => common::Error::Failure(response),
25366 });
25367 }
25368 let response = {
25369 let bytes = common::to_bytes(body).await.unwrap_or_default();
25370 let encoded = common::to_string(&bytes);
25371 match serde_json::from_str(&encoded) {
25372 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25373 Err(error) => {
25374 dlg.response_json_decode_error(&encoded, &error);
25375 return Err(common::Error::JsonDecodeError(
25376 encoded.to_string(),
25377 error,
25378 ));
25379 }
25380 }
25381 };
25382
25383 dlg.finished(true);
25384 return Ok(response);
25385 }
25386 }
25387 }
25388 }
25389
25390 ///
25391 /// Sets the *request* property to the given value.
25392 ///
25393 /// Even though the property as already been set when instantiating this call,
25394 /// we provide this method for API completeness.
25395 pub fn request(mut self, new_value: Property) -> PropertyInsertCall<'a, C> {
25396 self._request = new_value;
25397 self
25398 }
25399 /// The ID of the file.
25400 ///
25401 /// Sets the *file id* path property to the given value.
25402 ///
25403 /// Even though the property as already been set when instantiating this call,
25404 /// we provide this method for API completeness.
25405 pub fn file_id(mut self, new_value: &str) -> PropertyInsertCall<'a, C> {
25406 self._file_id = new_value.to_string();
25407 self
25408 }
25409 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25410 /// while executing the actual API request.
25411 ///
25412 /// ````text
25413 /// It should be used to handle progress information, and to implement a certain level of resilience.
25414 /// ````
25415 ///
25416 /// Sets the *delegate* property to the given value.
25417 pub fn delegate(
25418 mut self,
25419 new_value: &'a mut dyn common::Delegate,
25420 ) -> PropertyInsertCall<'a, C> {
25421 self._delegate = Some(new_value);
25422 self
25423 }
25424
25425 /// Set any additional parameter of the query string used in the request.
25426 /// It should be used to set parameters which are not yet available through their own
25427 /// setters.
25428 ///
25429 /// Please note that this method must not be used to set any of the known parameters
25430 /// which have their own setter method. If done anyway, the request will fail.
25431 ///
25432 /// # Additional Parameters
25433 ///
25434 /// * *$.xgafv* (query-string) - V1 error format.
25435 /// * *access_token* (query-string) - OAuth access token.
25436 /// * *alt* (query-string) - Data format for response.
25437 /// * *callback* (query-string) - JSONP
25438 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25439 /// * *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.
25440 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25441 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25442 /// * *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.
25443 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25444 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25445 pub fn param<T>(mut self, name: T, value: T) -> PropertyInsertCall<'a, C>
25446 where
25447 T: AsRef<str>,
25448 {
25449 self._additional_params
25450 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25451 self
25452 }
25453
25454 /// Identifies the authorization scope for the method you are building.
25455 ///
25456 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25457 /// [`Scope::Full`].
25458 ///
25459 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25460 /// tokens for more than one scope.
25461 ///
25462 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25463 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25464 /// sufficient, a read-write scope will do as well.
25465 pub fn add_scope<St>(mut self, scope: St) -> PropertyInsertCall<'a, C>
25466 where
25467 St: AsRef<str>,
25468 {
25469 self._scopes.insert(String::from(scope.as_ref()));
25470 self
25471 }
25472 /// Identifies the authorization scope(s) for the method you are building.
25473 ///
25474 /// See [`Self::add_scope()`] for details.
25475 pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyInsertCall<'a, C>
25476 where
25477 I: IntoIterator<Item = St>,
25478 St: AsRef<str>,
25479 {
25480 self._scopes
25481 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25482 self
25483 }
25484
25485 /// Removes all scopes, and no default scope will be used either.
25486 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25487 /// for details).
25488 pub fn clear_scopes(mut self) -> PropertyInsertCall<'a, C> {
25489 self._scopes.clear();
25490 self
25491 }
25492}
25493
25494/// Lists a file's properties.
25495///
25496/// A builder for the *list* method supported by a *property* resource.
25497/// It is not used directly, but through a [`PropertyMethods`] instance.
25498///
25499/// # Example
25500///
25501/// Instantiate a resource method builder
25502///
25503/// ```test_harness,no_run
25504/// # extern crate hyper;
25505/// # extern crate hyper_rustls;
25506/// # extern crate google_drive2 as drive2;
25507/// # async fn dox() {
25508/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25509///
25510/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25511/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25512/// # .with_native_roots()
25513/// # .unwrap()
25514/// # .https_only()
25515/// # .enable_http2()
25516/// # .build();
25517///
25518/// # let executor = hyper_util::rt::TokioExecutor::new();
25519/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25520/// # secret,
25521/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25522/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25523/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25524/// # ),
25525/// # ).build().await.unwrap();
25526///
25527/// # let client = hyper_util::client::legacy::Client::builder(
25528/// # hyper_util::rt::TokioExecutor::new()
25529/// # )
25530/// # .build(
25531/// # hyper_rustls::HttpsConnectorBuilder::new()
25532/// # .with_native_roots()
25533/// # .unwrap()
25534/// # .https_or_http()
25535/// # .enable_http2()
25536/// # .build()
25537/// # );
25538/// # let mut hub = DriveHub::new(client, auth);
25539/// // You can configure optional parameters by calling the respective setters at will, and
25540/// // execute the final call using `doit()`.
25541/// // Values shown here are possibly random and not representative !
25542/// let result = hub.properties().list("fileId")
25543/// .doit().await;
25544/// # }
25545/// ```
25546pub struct PropertyListCall<'a, C>
25547where
25548 C: 'a,
25549{
25550 hub: &'a DriveHub<C>,
25551 _file_id: String,
25552 _delegate: Option<&'a mut dyn common::Delegate>,
25553 _additional_params: HashMap<String, String>,
25554 _scopes: BTreeSet<String>,
25555}
25556
25557impl<'a, C> common::CallBuilder for PropertyListCall<'a, C> {}
25558
25559impl<'a, C> PropertyListCall<'a, C>
25560where
25561 C: common::Connector,
25562{
25563 /// Perform the operation you have build so far.
25564 pub async fn doit(mut self) -> common::Result<(common::Response, PropertyList)> {
25565 use std::borrow::Cow;
25566 use std::io::{Read, Seek};
25567
25568 use common::{url::Params, ToParts};
25569 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25570
25571 let mut dd = common::DefaultDelegate;
25572 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25573 dlg.begin(common::MethodInfo {
25574 id: "drive.properties.list",
25575 http_method: hyper::Method::GET,
25576 });
25577
25578 for &field in ["alt", "fileId"].iter() {
25579 if self._additional_params.contains_key(field) {
25580 dlg.finished(false);
25581 return Err(common::Error::FieldClash(field));
25582 }
25583 }
25584
25585 let mut params = Params::with_capacity(3 + self._additional_params.len());
25586 params.push("fileId", self._file_id);
25587
25588 params.extend(self._additional_params.iter());
25589
25590 params.push("alt", "json");
25591 let mut url = self.hub._base_url.clone() + "files/{fileId}/properties";
25592 if self._scopes.is_empty() {
25593 self._scopes
25594 .insert(Scope::MeetReadonly.as_ref().to_string());
25595 }
25596
25597 #[allow(clippy::single_element_loop)]
25598 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
25599 url = params.uri_replacement(url, param_name, find_this, false);
25600 }
25601 {
25602 let to_remove = ["fileId"];
25603 params.remove_params(&to_remove);
25604 }
25605
25606 let url = params.parse_with_url(&url);
25607
25608 loop {
25609 let token = match self
25610 .hub
25611 .auth
25612 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25613 .await
25614 {
25615 Ok(token) => token,
25616 Err(e) => match dlg.token(e) {
25617 Ok(token) => token,
25618 Err(e) => {
25619 dlg.finished(false);
25620 return Err(common::Error::MissingToken(e));
25621 }
25622 },
25623 };
25624 let mut req_result = {
25625 let client = &self.hub.client;
25626 dlg.pre_request();
25627 let mut req_builder = hyper::Request::builder()
25628 .method(hyper::Method::GET)
25629 .uri(url.as_str())
25630 .header(USER_AGENT, self.hub._user_agent.clone());
25631
25632 if let Some(token) = token.as_ref() {
25633 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25634 }
25635
25636 let request = req_builder
25637 .header(CONTENT_LENGTH, 0_u64)
25638 .body(common::to_body::<String>(None));
25639
25640 client.request(request.unwrap()).await
25641 };
25642
25643 match req_result {
25644 Err(err) => {
25645 if let common::Retry::After(d) = dlg.http_error(&err) {
25646 sleep(d).await;
25647 continue;
25648 }
25649 dlg.finished(false);
25650 return Err(common::Error::HttpError(err));
25651 }
25652 Ok(res) => {
25653 let (mut parts, body) = res.into_parts();
25654 let mut body = common::Body::new(body);
25655 if !parts.status.is_success() {
25656 let bytes = common::to_bytes(body).await.unwrap_or_default();
25657 let error = serde_json::from_str(&common::to_string(&bytes));
25658 let response = common::to_response(parts, bytes.into());
25659
25660 if let common::Retry::After(d) =
25661 dlg.http_failure(&response, error.as_ref().ok())
25662 {
25663 sleep(d).await;
25664 continue;
25665 }
25666
25667 dlg.finished(false);
25668
25669 return Err(match error {
25670 Ok(value) => common::Error::BadRequest(value),
25671 _ => common::Error::Failure(response),
25672 });
25673 }
25674 let response = {
25675 let bytes = common::to_bytes(body).await.unwrap_or_default();
25676 let encoded = common::to_string(&bytes);
25677 match serde_json::from_str(&encoded) {
25678 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25679 Err(error) => {
25680 dlg.response_json_decode_error(&encoded, &error);
25681 return Err(common::Error::JsonDecodeError(
25682 encoded.to_string(),
25683 error,
25684 ));
25685 }
25686 }
25687 };
25688
25689 dlg.finished(true);
25690 return Ok(response);
25691 }
25692 }
25693 }
25694 }
25695
25696 /// The ID of the file.
25697 ///
25698 /// Sets the *file id* path property to the given value.
25699 ///
25700 /// Even though the property as already been set when instantiating this call,
25701 /// we provide this method for API completeness.
25702 pub fn file_id(mut self, new_value: &str) -> PropertyListCall<'a, C> {
25703 self._file_id = new_value.to_string();
25704 self
25705 }
25706 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25707 /// while executing the actual API request.
25708 ///
25709 /// ````text
25710 /// It should be used to handle progress information, and to implement a certain level of resilience.
25711 /// ````
25712 ///
25713 /// Sets the *delegate* property to the given value.
25714 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PropertyListCall<'a, C> {
25715 self._delegate = Some(new_value);
25716 self
25717 }
25718
25719 /// Set any additional parameter of the query string used in the request.
25720 /// It should be used to set parameters which are not yet available through their own
25721 /// setters.
25722 ///
25723 /// Please note that this method must not be used to set any of the known parameters
25724 /// which have their own setter method. If done anyway, the request will fail.
25725 ///
25726 /// # Additional Parameters
25727 ///
25728 /// * *$.xgafv* (query-string) - V1 error format.
25729 /// * *access_token* (query-string) - OAuth access token.
25730 /// * *alt* (query-string) - Data format for response.
25731 /// * *callback* (query-string) - JSONP
25732 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25733 /// * *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.
25734 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25735 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25736 /// * *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.
25737 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25738 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25739 pub fn param<T>(mut self, name: T, value: T) -> PropertyListCall<'a, C>
25740 where
25741 T: AsRef<str>,
25742 {
25743 self._additional_params
25744 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25745 self
25746 }
25747
25748 /// Identifies the authorization scope for the method you are building.
25749 ///
25750 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25751 /// [`Scope::MeetReadonly`].
25752 ///
25753 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25754 /// tokens for more than one scope.
25755 ///
25756 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25757 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25758 /// sufficient, a read-write scope will do as well.
25759 pub fn add_scope<St>(mut self, scope: St) -> PropertyListCall<'a, C>
25760 where
25761 St: AsRef<str>,
25762 {
25763 self._scopes.insert(String::from(scope.as_ref()));
25764 self
25765 }
25766 /// Identifies the authorization scope(s) for the method you are building.
25767 ///
25768 /// See [`Self::add_scope()`] for details.
25769 pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyListCall<'a, C>
25770 where
25771 I: IntoIterator<Item = St>,
25772 St: AsRef<str>,
25773 {
25774 self._scopes
25775 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25776 self
25777 }
25778
25779 /// Removes all scopes, and no default scope will be used either.
25780 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25781 /// for details).
25782 pub fn clear_scopes(mut self) -> PropertyListCall<'a, C> {
25783 self._scopes.clear();
25784 self
25785 }
25786}
25787
25788/// Updates a property.
25789///
25790/// A builder for the *patch* method supported by a *property* resource.
25791/// It is not used directly, but through a [`PropertyMethods`] instance.
25792///
25793/// # Example
25794///
25795/// Instantiate a resource method builder
25796///
25797/// ```test_harness,no_run
25798/// # extern crate hyper;
25799/// # extern crate hyper_rustls;
25800/// # extern crate google_drive2 as drive2;
25801/// use drive2::api::Property;
25802/// # async fn dox() {
25803/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25804///
25805/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25806/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25807/// # .with_native_roots()
25808/// # .unwrap()
25809/// # .https_only()
25810/// # .enable_http2()
25811/// # .build();
25812///
25813/// # let executor = hyper_util::rt::TokioExecutor::new();
25814/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25815/// # secret,
25816/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25817/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25818/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25819/// # ),
25820/// # ).build().await.unwrap();
25821///
25822/// # let client = hyper_util::client::legacy::Client::builder(
25823/// # hyper_util::rt::TokioExecutor::new()
25824/// # )
25825/// # .build(
25826/// # hyper_rustls::HttpsConnectorBuilder::new()
25827/// # .with_native_roots()
25828/// # .unwrap()
25829/// # .https_or_http()
25830/// # .enable_http2()
25831/// # .build()
25832/// # );
25833/// # let mut hub = DriveHub::new(client, auth);
25834/// // As the method needs a request, you would usually fill it with the desired information
25835/// // into the respective structure. Some of the parts shown here might not be applicable !
25836/// // Values shown here are possibly random and not representative !
25837/// let mut req = Property::default();
25838///
25839/// // You can configure optional parameters by calling the respective setters at will, and
25840/// // execute the final call using `doit()`.
25841/// // Values shown here are possibly random and not representative !
25842/// let result = hub.properties().patch(req, "fileId", "propertyKey")
25843/// .visibility("sea")
25844/// .doit().await;
25845/// # }
25846/// ```
25847pub struct PropertyPatchCall<'a, C>
25848where
25849 C: 'a,
25850{
25851 hub: &'a DriveHub<C>,
25852 _request: Property,
25853 _file_id: String,
25854 _property_key: String,
25855 _visibility: Option<String>,
25856 _delegate: Option<&'a mut dyn common::Delegate>,
25857 _additional_params: HashMap<String, String>,
25858 _scopes: BTreeSet<String>,
25859}
25860
25861impl<'a, C> common::CallBuilder for PropertyPatchCall<'a, C> {}
25862
25863impl<'a, C> PropertyPatchCall<'a, C>
25864where
25865 C: common::Connector,
25866{
25867 /// Perform the operation you have build so far.
25868 pub async fn doit(mut self) -> common::Result<(common::Response, Property)> {
25869 use std::borrow::Cow;
25870 use std::io::{Read, Seek};
25871
25872 use common::{url::Params, ToParts};
25873 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25874
25875 let mut dd = common::DefaultDelegate;
25876 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25877 dlg.begin(common::MethodInfo {
25878 id: "drive.properties.patch",
25879 http_method: hyper::Method::PATCH,
25880 });
25881
25882 for &field in ["alt", "fileId", "propertyKey", "visibility"].iter() {
25883 if self._additional_params.contains_key(field) {
25884 dlg.finished(false);
25885 return Err(common::Error::FieldClash(field));
25886 }
25887 }
25888
25889 let mut params = Params::with_capacity(6 + self._additional_params.len());
25890 params.push("fileId", self._file_id);
25891 params.push("propertyKey", self._property_key);
25892 if let Some(value) = self._visibility.as_ref() {
25893 params.push("visibility", value);
25894 }
25895
25896 params.extend(self._additional_params.iter());
25897
25898 params.push("alt", "json");
25899 let mut url = self.hub._base_url.clone() + "files/{fileId}/properties/{propertyKey}";
25900 if self._scopes.is_empty() {
25901 self._scopes.insert(Scope::Full.as_ref().to_string());
25902 }
25903
25904 #[allow(clippy::single_element_loop)]
25905 for &(find_this, param_name) in
25906 [("{fileId}", "fileId"), ("{propertyKey}", "propertyKey")].iter()
25907 {
25908 url = params.uri_replacement(url, param_name, find_this, false);
25909 }
25910 {
25911 let to_remove = ["propertyKey", "fileId"];
25912 params.remove_params(&to_remove);
25913 }
25914
25915 let url = params.parse_with_url(&url);
25916
25917 let mut json_mime_type = mime::APPLICATION_JSON;
25918 let mut request_value_reader = {
25919 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25920 common::remove_json_null_values(&mut value);
25921 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25922 serde_json::to_writer(&mut dst, &value).unwrap();
25923 dst
25924 };
25925 let request_size = request_value_reader
25926 .seek(std::io::SeekFrom::End(0))
25927 .unwrap();
25928 request_value_reader
25929 .seek(std::io::SeekFrom::Start(0))
25930 .unwrap();
25931
25932 loop {
25933 let token = match self
25934 .hub
25935 .auth
25936 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25937 .await
25938 {
25939 Ok(token) => token,
25940 Err(e) => match dlg.token(e) {
25941 Ok(token) => token,
25942 Err(e) => {
25943 dlg.finished(false);
25944 return Err(common::Error::MissingToken(e));
25945 }
25946 },
25947 };
25948 request_value_reader
25949 .seek(std::io::SeekFrom::Start(0))
25950 .unwrap();
25951 let mut req_result = {
25952 let client = &self.hub.client;
25953 dlg.pre_request();
25954 let mut req_builder = hyper::Request::builder()
25955 .method(hyper::Method::PATCH)
25956 .uri(url.as_str())
25957 .header(USER_AGENT, self.hub._user_agent.clone());
25958
25959 if let Some(token) = token.as_ref() {
25960 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25961 }
25962
25963 let request = req_builder
25964 .header(CONTENT_TYPE, json_mime_type.to_string())
25965 .header(CONTENT_LENGTH, request_size as u64)
25966 .body(common::to_body(
25967 request_value_reader.get_ref().clone().into(),
25968 ));
25969
25970 client.request(request.unwrap()).await
25971 };
25972
25973 match req_result {
25974 Err(err) => {
25975 if let common::Retry::After(d) = dlg.http_error(&err) {
25976 sleep(d).await;
25977 continue;
25978 }
25979 dlg.finished(false);
25980 return Err(common::Error::HttpError(err));
25981 }
25982 Ok(res) => {
25983 let (mut parts, body) = res.into_parts();
25984 let mut body = common::Body::new(body);
25985 if !parts.status.is_success() {
25986 let bytes = common::to_bytes(body).await.unwrap_or_default();
25987 let error = serde_json::from_str(&common::to_string(&bytes));
25988 let response = common::to_response(parts, bytes.into());
25989
25990 if let common::Retry::After(d) =
25991 dlg.http_failure(&response, error.as_ref().ok())
25992 {
25993 sleep(d).await;
25994 continue;
25995 }
25996
25997 dlg.finished(false);
25998
25999 return Err(match error {
26000 Ok(value) => common::Error::BadRequest(value),
26001 _ => common::Error::Failure(response),
26002 });
26003 }
26004 let response = {
26005 let bytes = common::to_bytes(body).await.unwrap_or_default();
26006 let encoded = common::to_string(&bytes);
26007 match serde_json::from_str(&encoded) {
26008 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26009 Err(error) => {
26010 dlg.response_json_decode_error(&encoded, &error);
26011 return Err(common::Error::JsonDecodeError(
26012 encoded.to_string(),
26013 error,
26014 ));
26015 }
26016 }
26017 };
26018
26019 dlg.finished(true);
26020 return Ok(response);
26021 }
26022 }
26023 }
26024 }
26025
26026 ///
26027 /// Sets the *request* property to the given value.
26028 ///
26029 /// Even though the property as already been set when instantiating this call,
26030 /// we provide this method for API completeness.
26031 pub fn request(mut self, new_value: Property) -> PropertyPatchCall<'a, C> {
26032 self._request = new_value;
26033 self
26034 }
26035 /// The ID of the file.
26036 ///
26037 /// Sets the *file id* path property to the given value.
26038 ///
26039 /// Even though the property as already been set when instantiating this call,
26040 /// we provide this method for API completeness.
26041 pub fn file_id(mut self, new_value: &str) -> PropertyPatchCall<'a, C> {
26042 self._file_id = new_value.to_string();
26043 self
26044 }
26045 /// The key of the property.
26046 ///
26047 /// Sets the *property key* path property to the given value.
26048 ///
26049 /// Even though the property as already been set when instantiating this call,
26050 /// we provide this method for API completeness.
26051 pub fn property_key(mut self, new_value: &str) -> PropertyPatchCall<'a, C> {
26052 self._property_key = new_value.to_string();
26053 self
26054 }
26055 /// The visibility of the property. Allowed values are PRIVATE and PUBLIC. (Default: PRIVATE)
26056 ///
26057 /// Sets the *visibility* query property to the given value.
26058 pub fn visibility(mut self, new_value: &str) -> PropertyPatchCall<'a, C> {
26059 self._visibility = Some(new_value.to_string());
26060 self
26061 }
26062 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26063 /// while executing the actual API request.
26064 ///
26065 /// ````text
26066 /// It should be used to handle progress information, and to implement a certain level of resilience.
26067 /// ````
26068 ///
26069 /// Sets the *delegate* property to the given value.
26070 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PropertyPatchCall<'a, C> {
26071 self._delegate = Some(new_value);
26072 self
26073 }
26074
26075 /// Set any additional parameter of the query string used in the request.
26076 /// It should be used to set parameters which are not yet available through their own
26077 /// setters.
26078 ///
26079 /// Please note that this method must not be used to set any of the known parameters
26080 /// which have their own setter method. If done anyway, the request will fail.
26081 ///
26082 /// # Additional Parameters
26083 ///
26084 /// * *$.xgafv* (query-string) - V1 error format.
26085 /// * *access_token* (query-string) - OAuth access token.
26086 /// * *alt* (query-string) - Data format for response.
26087 /// * *callback* (query-string) - JSONP
26088 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26089 /// * *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.
26090 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26091 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26092 /// * *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.
26093 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26094 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26095 pub fn param<T>(mut self, name: T, value: T) -> PropertyPatchCall<'a, C>
26096 where
26097 T: AsRef<str>,
26098 {
26099 self._additional_params
26100 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26101 self
26102 }
26103
26104 /// Identifies the authorization scope for the method you are building.
26105 ///
26106 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26107 /// [`Scope::Full`].
26108 ///
26109 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26110 /// tokens for more than one scope.
26111 ///
26112 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26113 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26114 /// sufficient, a read-write scope will do as well.
26115 pub fn add_scope<St>(mut self, scope: St) -> PropertyPatchCall<'a, C>
26116 where
26117 St: AsRef<str>,
26118 {
26119 self._scopes.insert(String::from(scope.as_ref()));
26120 self
26121 }
26122 /// Identifies the authorization scope(s) for the method you are building.
26123 ///
26124 /// See [`Self::add_scope()`] for details.
26125 pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyPatchCall<'a, C>
26126 where
26127 I: IntoIterator<Item = St>,
26128 St: AsRef<str>,
26129 {
26130 self._scopes
26131 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26132 self
26133 }
26134
26135 /// Removes all scopes, and no default scope will be used either.
26136 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26137 /// for details).
26138 pub fn clear_scopes(mut self) -> PropertyPatchCall<'a, C> {
26139 self._scopes.clear();
26140 self
26141 }
26142}
26143
26144/// Updates a property.
26145///
26146/// A builder for the *update* method supported by a *property* resource.
26147/// It is not used directly, but through a [`PropertyMethods`] instance.
26148///
26149/// # Example
26150///
26151/// Instantiate a resource method builder
26152///
26153/// ```test_harness,no_run
26154/// # extern crate hyper;
26155/// # extern crate hyper_rustls;
26156/// # extern crate google_drive2 as drive2;
26157/// use drive2::api::Property;
26158/// # async fn dox() {
26159/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26160///
26161/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26162/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26163/// # .with_native_roots()
26164/// # .unwrap()
26165/// # .https_only()
26166/// # .enable_http2()
26167/// # .build();
26168///
26169/// # let executor = hyper_util::rt::TokioExecutor::new();
26170/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26171/// # secret,
26172/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26173/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26174/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26175/// # ),
26176/// # ).build().await.unwrap();
26177///
26178/// # let client = hyper_util::client::legacy::Client::builder(
26179/// # hyper_util::rt::TokioExecutor::new()
26180/// # )
26181/// # .build(
26182/// # hyper_rustls::HttpsConnectorBuilder::new()
26183/// # .with_native_roots()
26184/// # .unwrap()
26185/// # .https_or_http()
26186/// # .enable_http2()
26187/// # .build()
26188/// # );
26189/// # let mut hub = DriveHub::new(client, auth);
26190/// // As the method needs a request, you would usually fill it with the desired information
26191/// // into the respective structure. Some of the parts shown here might not be applicable !
26192/// // Values shown here are possibly random and not representative !
26193/// let mut req = Property::default();
26194///
26195/// // You can configure optional parameters by calling the respective setters at will, and
26196/// // execute the final call using `doit()`.
26197/// // Values shown here are possibly random and not representative !
26198/// let result = hub.properties().update(req, "fileId", "propertyKey")
26199/// .visibility("accusam")
26200/// .doit().await;
26201/// # }
26202/// ```
26203pub struct PropertyUpdateCall<'a, C>
26204where
26205 C: 'a,
26206{
26207 hub: &'a DriveHub<C>,
26208 _request: Property,
26209 _file_id: String,
26210 _property_key: String,
26211 _visibility: Option<String>,
26212 _delegate: Option<&'a mut dyn common::Delegate>,
26213 _additional_params: HashMap<String, String>,
26214 _scopes: BTreeSet<String>,
26215}
26216
26217impl<'a, C> common::CallBuilder for PropertyUpdateCall<'a, C> {}
26218
26219impl<'a, C> PropertyUpdateCall<'a, C>
26220where
26221 C: common::Connector,
26222{
26223 /// Perform the operation you have build so far.
26224 pub async fn doit(mut self) -> common::Result<(common::Response, Property)> {
26225 use std::borrow::Cow;
26226 use std::io::{Read, Seek};
26227
26228 use common::{url::Params, ToParts};
26229 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26230
26231 let mut dd = common::DefaultDelegate;
26232 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26233 dlg.begin(common::MethodInfo {
26234 id: "drive.properties.update",
26235 http_method: hyper::Method::PUT,
26236 });
26237
26238 for &field in ["alt", "fileId", "propertyKey", "visibility"].iter() {
26239 if self._additional_params.contains_key(field) {
26240 dlg.finished(false);
26241 return Err(common::Error::FieldClash(field));
26242 }
26243 }
26244
26245 let mut params = Params::with_capacity(6 + self._additional_params.len());
26246 params.push("fileId", self._file_id);
26247 params.push("propertyKey", self._property_key);
26248 if let Some(value) = self._visibility.as_ref() {
26249 params.push("visibility", value);
26250 }
26251
26252 params.extend(self._additional_params.iter());
26253
26254 params.push("alt", "json");
26255 let mut url = self.hub._base_url.clone() + "files/{fileId}/properties/{propertyKey}";
26256 if self._scopes.is_empty() {
26257 self._scopes.insert(Scope::Full.as_ref().to_string());
26258 }
26259
26260 #[allow(clippy::single_element_loop)]
26261 for &(find_this, param_name) in
26262 [("{fileId}", "fileId"), ("{propertyKey}", "propertyKey")].iter()
26263 {
26264 url = params.uri_replacement(url, param_name, find_this, false);
26265 }
26266 {
26267 let to_remove = ["propertyKey", "fileId"];
26268 params.remove_params(&to_remove);
26269 }
26270
26271 let url = params.parse_with_url(&url);
26272
26273 let mut json_mime_type = mime::APPLICATION_JSON;
26274 let mut request_value_reader = {
26275 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26276 common::remove_json_null_values(&mut value);
26277 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26278 serde_json::to_writer(&mut dst, &value).unwrap();
26279 dst
26280 };
26281 let request_size = request_value_reader
26282 .seek(std::io::SeekFrom::End(0))
26283 .unwrap();
26284 request_value_reader
26285 .seek(std::io::SeekFrom::Start(0))
26286 .unwrap();
26287
26288 loop {
26289 let token = match self
26290 .hub
26291 .auth
26292 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26293 .await
26294 {
26295 Ok(token) => token,
26296 Err(e) => match dlg.token(e) {
26297 Ok(token) => token,
26298 Err(e) => {
26299 dlg.finished(false);
26300 return Err(common::Error::MissingToken(e));
26301 }
26302 },
26303 };
26304 request_value_reader
26305 .seek(std::io::SeekFrom::Start(0))
26306 .unwrap();
26307 let mut req_result = {
26308 let client = &self.hub.client;
26309 dlg.pre_request();
26310 let mut req_builder = hyper::Request::builder()
26311 .method(hyper::Method::PUT)
26312 .uri(url.as_str())
26313 .header(USER_AGENT, self.hub._user_agent.clone());
26314
26315 if let Some(token) = token.as_ref() {
26316 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26317 }
26318
26319 let request = req_builder
26320 .header(CONTENT_TYPE, json_mime_type.to_string())
26321 .header(CONTENT_LENGTH, request_size as u64)
26322 .body(common::to_body(
26323 request_value_reader.get_ref().clone().into(),
26324 ));
26325
26326 client.request(request.unwrap()).await
26327 };
26328
26329 match req_result {
26330 Err(err) => {
26331 if let common::Retry::After(d) = dlg.http_error(&err) {
26332 sleep(d).await;
26333 continue;
26334 }
26335 dlg.finished(false);
26336 return Err(common::Error::HttpError(err));
26337 }
26338 Ok(res) => {
26339 let (mut parts, body) = res.into_parts();
26340 let mut body = common::Body::new(body);
26341 if !parts.status.is_success() {
26342 let bytes = common::to_bytes(body).await.unwrap_or_default();
26343 let error = serde_json::from_str(&common::to_string(&bytes));
26344 let response = common::to_response(parts, bytes.into());
26345
26346 if let common::Retry::After(d) =
26347 dlg.http_failure(&response, error.as_ref().ok())
26348 {
26349 sleep(d).await;
26350 continue;
26351 }
26352
26353 dlg.finished(false);
26354
26355 return Err(match error {
26356 Ok(value) => common::Error::BadRequest(value),
26357 _ => common::Error::Failure(response),
26358 });
26359 }
26360 let response = {
26361 let bytes = common::to_bytes(body).await.unwrap_or_default();
26362 let encoded = common::to_string(&bytes);
26363 match serde_json::from_str(&encoded) {
26364 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26365 Err(error) => {
26366 dlg.response_json_decode_error(&encoded, &error);
26367 return Err(common::Error::JsonDecodeError(
26368 encoded.to_string(),
26369 error,
26370 ));
26371 }
26372 }
26373 };
26374
26375 dlg.finished(true);
26376 return Ok(response);
26377 }
26378 }
26379 }
26380 }
26381
26382 ///
26383 /// Sets the *request* property to the given value.
26384 ///
26385 /// Even though the property as already been set when instantiating this call,
26386 /// we provide this method for API completeness.
26387 pub fn request(mut self, new_value: Property) -> PropertyUpdateCall<'a, C> {
26388 self._request = new_value;
26389 self
26390 }
26391 /// The ID of the file.
26392 ///
26393 /// Sets the *file id* path property to the given value.
26394 ///
26395 /// Even though the property as already been set when instantiating this call,
26396 /// we provide this method for API completeness.
26397 pub fn file_id(mut self, new_value: &str) -> PropertyUpdateCall<'a, C> {
26398 self._file_id = new_value.to_string();
26399 self
26400 }
26401 /// The key of the property.
26402 ///
26403 /// Sets the *property key* path property to the given value.
26404 ///
26405 /// Even though the property as already been set when instantiating this call,
26406 /// we provide this method for API completeness.
26407 pub fn property_key(mut self, new_value: &str) -> PropertyUpdateCall<'a, C> {
26408 self._property_key = new_value.to_string();
26409 self
26410 }
26411 /// The visibility of the property. Allowed values are PRIVATE and PUBLIC. (Default: PRIVATE)
26412 ///
26413 /// Sets the *visibility* query property to the given value.
26414 pub fn visibility(mut self, new_value: &str) -> PropertyUpdateCall<'a, C> {
26415 self._visibility = Some(new_value.to_string());
26416 self
26417 }
26418 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26419 /// while executing the actual API request.
26420 ///
26421 /// ````text
26422 /// It should be used to handle progress information, and to implement a certain level of resilience.
26423 /// ````
26424 ///
26425 /// Sets the *delegate* property to the given value.
26426 pub fn delegate(
26427 mut self,
26428 new_value: &'a mut dyn common::Delegate,
26429 ) -> PropertyUpdateCall<'a, C> {
26430 self._delegate = Some(new_value);
26431 self
26432 }
26433
26434 /// Set any additional parameter of the query string used in the request.
26435 /// It should be used to set parameters which are not yet available through their own
26436 /// setters.
26437 ///
26438 /// Please note that this method must not be used to set any of the known parameters
26439 /// which have their own setter method. If done anyway, the request will fail.
26440 ///
26441 /// # Additional Parameters
26442 ///
26443 /// * *$.xgafv* (query-string) - V1 error format.
26444 /// * *access_token* (query-string) - OAuth access token.
26445 /// * *alt* (query-string) - Data format for response.
26446 /// * *callback* (query-string) - JSONP
26447 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26448 /// * *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.
26449 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26450 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26451 /// * *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.
26452 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26453 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26454 pub fn param<T>(mut self, name: T, value: T) -> PropertyUpdateCall<'a, C>
26455 where
26456 T: AsRef<str>,
26457 {
26458 self._additional_params
26459 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26460 self
26461 }
26462
26463 /// Identifies the authorization scope for the method you are building.
26464 ///
26465 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26466 /// [`Scope::Full`].
26467 ///
26468 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26469 /// tokens for more than one scope.
26470 ///
26471 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26472 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26473 /// sufficient, a read-write scope will do as well.
26474 pub fn add_scope<St>(mut self, scope: St) -> PropertyUpdateCall<'a, C>
26475 where
26476 St: AsRef<str>,
26477 {
26478 self._scopes.insert(String::from(scope.as_ref()));
26479 self
26480 }
26481 /// Identifies the authorization scope(s) for the method you are building.
26482 ///
26483 /// See [`Self::add_scope()`] for details.
26484 pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyUpdateCall<'a, C>
26485 where
26486 I: IntoIterator<Item = St>,
26487 St: AsRef<str>,
26488 {
26489 self._scopes
26490 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26491 self
26492 }
26493
26494 /// Removes all scopes, and no default scope will be used either.
26495 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26496 /// for details).
26497 pub fn clear_scopes(mut self) -> PropertyUpdateCall<'a, C> {
26498 self._scopes.clear();
26499 self
26500 }
26501}
26502
26503/// Deletes a reply.
26504///
26505/// A builder for the *delete* method supported by a *reply* resource.
26506/// It is not used directly, but through a [`ReplyMethods`] instance.
26507///
26508/// # Example
26509///
26510/// Instantiate a resource method builder
26511///
26512/// ```test_harness,no_run
26513/// # extern crate hyper;
26514/// # extern crate hyper_rustls;
26515/// # extern crate google_drive2 as drive2;
26516/// # async fn dox() {
26517/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26518///
26519/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26520/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26521/// # .with_native_roots()
26522/// # .unwrap()
26523/// # .https_only()
26524/// # .enable_http2()
26525/// # .build();
26526///
26527/// # let executor = hyper_util::rt::TokioExecutor::new();
26528/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26529/// # secret,
26530/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26531/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26532/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26533/// # ),
26534/// # ).build().await.unwrap();
26535///
26536/// # let client = hyper_util::client::legacy::Client::builder(
26537/// # hyper_util::rt::TokioExecutor::new()
26538/// # )
26539/// # .build(
26540/// # hyper_rustls::HttpsConnectorBuilder::new()
26541/// # .with_native_roots()
26542/// # .unwrap()
26543/// # .https_or_http()
26544/// # .enable_http2()
26545/// # .build()
26546/// # );
26547/// # let mut hub = DriveHub::new(client, auth);
26548/// // You can configure optional parameters by calling the respective setters at will, and
26549/// // execute the final call using `doit()`.
26550/// // Values shown here are possibly random and not representative !
26551/// let result = hub.replies().delete("fileId", "commentId", "replyId")
26552/// .doit().await;
26553/// # }
26554/// ```
26555pub struct ReplyDeleteCall<'a, C>
26556where
26557 C: 'a,
26558{
26559 hub: &'a DriveHub<C>,
26560 _file_id: String,
26561 _comment_id: String,
26562 _reply_id: String,
26563 _delegate: Option<&'a mut dyn common::Delegate>,
26564 _additional_params: HashMap<String, String>,
26565 _scopes: BTreeSet<String>,
26566}
26567
26568impl<'a, C> common::CallBuilder for ReplyDeleteCall<'a, C> {}
26569
26570impl<'a, C> ReplyDeleteCall<'a, C>
26571where
26572 C: common::Connector,
26573{
26574 /// Perform the operation you have build so far.
26575 pub async fn doit(mut self) -> common::Result<common::Response> {
26576 use std::borrow::Cow;
26577 use std::io::{Read, Seek};
26578
26579 use common::{url::Params, ToParts};
26580 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26581
26582 let mut dd = common::DefaultDelegate;
26583 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26584 dlg.begin(common::MethodInfo {
26585 id: "drive.replies.delete",
26586 http_method: hyper::Method::DELETE,
26587 });
26588
26589 for &field in ["fileId", "commentId", "replyId"].iter() {
26590 if self._additional_params.contains_key(field) {
26591 dlg.finished(false);
26592 return Err(common::Error::FieldClash(field));
26593 }
26594 }
26595
26596 let mut params = Params::with_capacity(4 + self._additional_params.len());
26597 params.push("fileId", self._file_id);
26598 params.push("commentId", self._comment_id);
26599 params.push("replyId", self._reply_id);
26600
26601 params.extend(self._additional_params.iter());
26602
26603 let mut url =
26604 self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}";
26605 if self._scopes.is_empty() {
26606 self._scopes.insert(Scope::Full.as_ref().to_string());
26607 }
26608
26609 #[allow(clippy::single_element_loop)]
26610 for &(find_this, param_name) in [
26611 ("{fileId}", "fileId"),
26612 ("{commentId}", "commentId"),
26613 ("{replyId}", "replyId"),
26614 ]
26615 .iter()
26616 {
26617 url = params.uri_replacement(url, param_name, find_this, false);
26618 }
26619 {
26620 let to_remove = ["replyId", "commentId", "fileId"];
26621 params.remove_params(&to_remove);
26622 }
26623
26624 let url = params.parse_with_url(&url);
26625
26626 loop {
26627 let token = match self
26628 .hub
26629 .auth
26630 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26631 .await
26632 {
26633 Ok(token) => token,
26634 Err(e) => match dlg.token(e) {
26635 Ok(token) => token,
26636 Err(e) => {
26637 dlg.finished(false);
26638 return Err(common::Error::MissingToken(e));
26639 }
26640 },
26641 };
26642 let mut req_result = {
26643 let client = &self.hub.client;
26644 dlg.pre_request();
26645 let mut req_builder = hyper::Request::builder()
26646 .method(hyper::Method::DELETE)
26647 .uri(url.as_str())
26648 .header(USER_AGENT, self.hub._user_agent.clone());
26649
26650 if let Some(token) = token.as_ref() {
26651 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26652 }
26653
26654 let request = req_builder
26655 .header(CONTENT_LENGTH, 0_u64)
26656 .body(common::to_body::<String>(None));
26657
26658 client.request(request.unwrap()).await
26659 };
26660
26661 match req_result {
26662 Err(err) => {
26663 if let common::Retry::After(d) = dlg.http_error(&err) {
26664 sleep(d).await;
26665 continue;
26666 }
26667 dlg.finished(false);
26668 return Err(common::Error::HttpError(err));
26669 }
26670 Ok(res) => {
26671 let (mut parts, body) = res.into_parts();
26672 let mut body = common::Body::new(body);
26673 if !parts.status.is_success() {
26674 let bytes = common::to_bytes(body).await.unwrap_or_default();
26675 let error = serde_json::from_str(&common::to_string(&bytes));
26676 let response = common::to_response(parts, bytes.into());
26677
26678 if let common::Retry::After(d) =
26679 dlg.http_failure(&response, error.as_ref().ok())
26680 {
26681 sleep(d).await;
26682 continue;
26683 }
26684
26685 dlg.finished(false);
26686
26687 return Err(match error {
26688 Ok(value) => common::Error::BadRequest(value),
26689 _ => common::Error::Failure(response),
26690 });
26691 }
26692 let response = common::Response::from_parts(parts, body);
26693
26694 dlg.finished(true);
26695 return Ok(response);
26696 }
26697 }
26698 }
26699 }
26700
26701 /// The ID of the file.
26702 ///
26703 /// Sets the *file id* path property to the given value.
26704 ///
26705 /// Even though the property as already been set when instantiating this call,
26706 /// we provide this method for API completeness.
26707 pub fn file_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, C> {
26708 self._file_id = new_value.to_string();
26709 self
26710 }
26711 /// The ID of the comment.
26712 ///
26713 /// Sets the *comment id* path property to the given value.
26714 ///
26715 /// Even though the property as already been set when instantiating this call,
26716 /// we provide this method for API completeness.
26717 pub fn comment_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, C> {
26718 self._comment_id = new_value.to_string();
26719 self
26720 }
26721 /// The ID of the reply.
26722 ///
26723 /// Sets the *reply id* path property to the given value.
26724 ///
26725 /// Even though the property as already been set when instantiating this call,
26726 /// we provide this method for API completeness.
26727 pub fn reply_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, C> {
26728 self._reply_id = new_value.to_string();
26729 self
26730 }
26731 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26732 /// while executing the actual API request.
26733 ///
26734 /// ````text
26735 /// It should be used to handle progress information, and to implement a certain level of resilience.
26736 /// ````
26737 ///
26738 /// Sets the *delegate* property to the given value.
26739 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyDeleteCall<'a, C> {
26740 self._delegate = Some(new_value);
26741 self
26742 }
26743
26744 /// Set any additional parameter of the query string used in the request.
26745 /// It should be used to set parameters which are not yet available through their own
26746 /// setters.
26747 ///
26748 /// Please note that this method must not be used to set any of the known parameters
26749 /// which have their own setter method. If done anyway, the request will fail.
26750 ///
26751 /// # Additional Parameters
26752 ///
26753 /// * *$.xgafv* (query-string) - V1 error format.
26754 /// * *access_token* (query-string) - OAuth access token.
26755 /// * *alt* (query-string) - Data format for response.
26756 /// * *callback* (query-string) - JSONP
26757 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26758 /// * *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.
26759 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26760 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26761 /// * *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.
26762 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26763 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26764 pub fn param<T>(mut self, name: T, value: T) -> ReplyDeleteCall<'a, C>
26765 where
26766 T: AsRef<str>,
26767 {
26768 self._additional_params
26769 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26770 self
26771 }
26772
26773 /// Identifies the authorization scope for the method you are building.
26774 ///
26775 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26776 /// [`Scope::Full`].
26777 ///
26778 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26779 /// tokens for more than one scope.
26780 ///
26781 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26782 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26783 /// sufficient, a read-write scope will do as well.
26784 pub fn add_scope<St>(mut self, scope: St) -> ReplyDeleteCall<'a, C>
26785 where
26786 St: AsRef<str>,
26787 {
26788 self._scopes.insert(String::from(scope.as_ref()));
26789 self
26790 }
26791 /// Identifies the authorization scope(s) for the method you are building.
26792 ///
26793 /// See [`Self::add_scope()`] for details.
26794 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyDeleteCall<'a, C>
26795 where
26796 I: IntoIterator<Item = St>,
26797 St: AsRef<str>,
26798 {
26799 self._scopes
26800 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26801 self
26802 }
26803
26804 /// Removes all scopes, and no default scope will be used either.
26805 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26806 /// for details).
26807 pub fn clear_scopes(mut self) -> ReplyDeleteCall<'a, C> {
26808 self._scopes.clear();
26809 self
26810 }
26811}
26812
26813/// Gets a reply.
26814///
26815/// A builder for the *get* method supported by a *reply* resource.
26816/// It is not used directly, but through a [`ReplyMethods`] instance.
26817///
26818/// # Example
26819///
26820/// Instantiate a resource method builder
26821///
26822/// ```test_harness,no_run
26823/// # extern crate hyper;
26824/// # extern crate hyper_rustls;
26825/// # extern crate google_drive2 as drive2;
26826/// # async fn dox() {
26827/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26828///
26829/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26830/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26831/// # .with_native_roots()
26832/// # .unwrap()
26833/// # .https_only()
26834/// # .enable_http2()
26835/// # .build();
26836///
26837/// # let executor = hyper_util::rt::TokioExecutor::new();
26838/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26839/// # secret,
26840/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26841/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26842/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26843/// # ),
26844/// # ).build().await.unwrap();
26845///
26846/// # let client = hyper_util::client::legacy::Client::builder(
26847/// # hyper_util::rt::TokioExecutor::new()
26848/// # )
26849/// # .build(
26850/// # hyper_rustls::HttpsConnectorBuilder::new()
26851/// # .with_native_roots()
26852/// # .unwrap()
26853/// # .https_or_http()
26854/// # .enable_http2()
26855/// # .build()
26856/// # );
26857/// # let mut hub = DriveHub::new(client, auth);
26858/// // You can configure optional parameters by calling the respective setters at will, and
26859/// // execute the final call using `doit()`.
26860/// // Values shown here are possibly random and not representative !
26861/// let result = hub.replies().get("fileId", "commentId", "replyId")
26862/// .include_deleted(true)
26863/// .doit().await;
26864/// # }
26865/// ```
26866pub struct ReplyGetCall<'a, C>
26867where
26868 C: 'a,
26869{
26870 hub: &'a DriveHub<C>,
26871 _file_id: String,
26872 _comment_id: String,
26873 _reply_id: String,
26874 _include_deleted: Option<bool>,
26875 _delegate: Option<&'a mut dyn common::Delegate>,
26876 _additional_params: HashMap<String, String>,
26877 _scopes: BTreeSet<String>,
26878}
26879
26880impl<'a, C> common::CallBuilder for ReplyGetCall<'a, C> {}
26881
26882impl<'a, C> ReplyGetCall<'a, C>
26883where
26884 C: common::Connector,
26885{
26886 /// Perform the operation you have build so far.
26887 pub async fn doit(mut self) -> common::Result<(common::Response, CommentReply)> {
26888 use std::borrow::Cow;
26889 use std::io::{Read, Seek};
26890
26891 use common::{url::Params, ToParts};
26892 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26893
26894 let mut dd = common::DefaultDelegate;
26895 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26896 dlg.begin(common::MethodInfo {
26897 id: "drive.replies.get",
26898 http_method: hyper::Method::GET,
26899 });
26900
26901 for &field in ["alt", "fileId", "commentId", "replyId", "includeDeleted"].iter() {
26902 if self._additional_params.contains_key(field) {
26903 dlg.finished(false);
26904 return Err(common::Error::FieldClash(field));
26905 }
26906 }
26907
26908 let mut params = Params::with_capacity(6 + self._additional_params.len());
26909 params.push("fileId", self._file_id);
26910 params.push("commentId", self._comment_id);
26911 params.push("replyId", self._reply_id);
26912 if let Some(value) = self._include_deleted.as_ref() {
26913 params.push("includeDeleted", value.to_string());
26914 }
26915
26916 params.extend(self._additional_params.iter());
26917
26918 params.push("alt", "json");
26919 let mut url =
26920 self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}";
26921 if self._scopes.is_empty() {
26922 self._scopes
26923 .insert(Scope::MeetReadonly.as_ref().to_string());
26924 }
26925
26926 #[allow(clippy::single_element_loop)]
26927 for &(find_this, param_name) in [
26928 ("{fileId}", "fileId"),
26929 ("{commentId}", "commentId"),
26930 ("{replyId}", "replyId"),
26931 ]
26932 .iter()
26933 {
26934 url = params.uri_replacement(url, param_name, find_this, false);
26935 }
26936 {
26937 let to_remove = ["replyId", "commentId", "fileId"];
26938 params.remove_params(&to_remove);
26939 }
26940
26941 let url = params.parse_with_url(&url);
26942
26943 loop {
26944 let token = match self
26945 .hub
26946 .auth
26947 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26948 .await
26949 {
26950 Ok(token) => token,
26951 Err(e) => match dlg.token(e) {
26952 Ok(token) => token,
26953 Err(e) => {
26954 dlg.finished(false);
26955 return Err(common::Error::MissingToken(e));
26956 }
26957 },
26958 };
26959 let mut req_result = {
26960 let client = &self.hub.client;
26961 dlg.pre_request();
26962 let mut req_builder = hyper::Request::builder()
26963 .method(hyper::Method::GET)
26964 .uri(url.as_str())
26965 .header(USER_AGENT, self.hub._user_agent.clone());
26966
26967 if let Some(token) = token.as_ref() {
26968 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26969 }
26970
26971 let request = req_builder
26972 .header(CONTENT_LENGTH, 0_u64)
26973 .body(common::to_body::<String>(None));
26974
26975 client.request(request.unwrap()).await
26976 };
26977
26978 match req_result {
26979 Err(err) => {
26980 if let common::Retry::After(d) = dlg.http_error(&err) {
26981 sleep(d).await;
26982 continue;
26983 }
26984 dlg.finished(false);
26985 return Err(common::Error::HttpError(err));
26986 }
26987 Ok(res) => {
26988 let (mut parts, body) = res.into_parts();
26989 let mut body = common::Body::new(body);
26990 if !parts.status.is_success() {
26991 let bytes = common::to_bytes(body).await.unwrap_or_default();
26992 let error = serde_json::from_str(&common::to_string(&bytes));
26993 let response = common::to_response(parts, bytes.into());
26994
26995 if let common::Retry::After(d) =
26996 dlg.http_failure(&response, error.as_ref().ok())
26997 {
26998 sleep(d).await;
26999 continue;
27000 }
27001
27002 dlg.finished(false);
27003
27004 return Err(match error {
27005 Ok(value) => common::Error::BadRequest(value),
27006 _ => common::Error::Failure(response),
27007 });
27008 }
27009 let response = {
27010 let bytes = common::to_bytes(body).await.unwrap_or_default();
27011 let encoded = common::to_string(&bytes);
27012 match serde_json::from_str(&encoded) {
27013 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27014 Err(error) => {
27015 dlg.response_json_decode_error(&encoded, &error);
27016 return Err(common::Error::JsonDecodeError(
27017 encoded.to_string(),
27018 error,
27019 ));
27020 }
27021 }
27022 };
27023
27024 dlg.finished(true);
27025 return Ok(response);
27026 }
27027 }
27028 }
27029 }
27030
27031 /// The ID of the file.
27032 ///
27033 /// Sets the *file id* path property to the given value.
27034 ///
27035 /// Even though the property as already been set when instantiating this call,
27036 /// we provide this method for API completeness.
27037 pub fn file_id(mut self, new_value: &str) -> ReplyGetCall<'a, C> {
27038 self._file_id = new_value.to_string();
27039 self
27040 }
27041 /// The ID of the comment.
27042 ///
27043 /// Sets the *comment id* path property to the given value.
27044 ///
27045 /// Even though the property as already been set when instantiating this call,
27046 /// we provide this method for API completeness.
27047 pub fn comment_id(mut self, new_value: &str) -> ReplyGetCall<'a, C> {
27048 self._comment_id = new_value.to_string();
27049 self
27050 }
27051 /// The ID of the reply.
27052 ///
27053 /// Sets the *reply id* path property to the given value.
27054 ///
27055 /// Even though the property as already been set when instantiating this call,
27056 /// we provide this method for API completeness.
27057 pub fn reply_id(mut self, new_value: &str) -> ReplyGetCall<'a, C> {
27058 self._reply_id = new_value.to_string();
27059 self
27060 }
27061 /// If set, this will succeed when retrieving a deleted reply.
27062 ///
27063 /// Sets the *include deleted* query property to the given value.
27064 pub fn include_deleted(mut self, new_value: bool) -> ReplyGetCall<'a, C> {
27065 self._include_deleted = Some(new_value);
27066 self
27067 }
27068 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27069 /// while executing the actual API request.
27070 ///
27071 /// ````text
27072 /// It should be used to handle progress information, and to implement a certain level of resilience.
27073 /// ````
27074 ///
27075 /// Sets the *delegate* property to the given value.
27076 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyGetCall<'a, C> {
27077 self._delegate = Some(new_value);
27078 self
27079 }
27080
27081 /// Set any additional parameter of the query string used in the request.
27082 /// It should be used to set parameters which are not yet available through their own
27083 /// setters.
27084 ///
27085 /// Please note that this method must not be used to set any of the known parameters
27086 /// which have their own setter method. If done anyway, the request will fail.
27087 ///
27088 /// # Additional Parameters
27089 ///
27090 /// * *$.xgafv* (query-string) - V1 error format.
27091 /// * *access_token* (query-string) - OAuth access token.
27092 /// * *alt* (query-string) - Data format for response.
27093 /// * *callback* (query-string) - JSONP
27094 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27095 /// * *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.
27096 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27097 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27098 /// * *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.
27099 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27100 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27101 pub fn param<T>(mut self, name: T, value: T) -> ReplyGetCall<'a, C>
27102 where
27103 T: AsRef<str>,
27104 {
27105 self._additional_params
27106 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27107 self
27108 }
27109
27110 /// Identifies the authorization scope for the method you are building.
27111 ///
27112 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27113 /// [`Scope::MeetReadonly`].
27114 ///
27115 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27116 /// tokens for more than one scope.
27117 ///
27118 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27119 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27120 /// sufficient, a read-write scope will do as well.
27121 pub fn add_scope<St>(mut self, scope: St) -> ReplyGetCall<'a, C>
27122 where
27123 St: AsRef<str>,
27124 {
27125 self._scopes.insert(String::from(scope.as_ref()));
27126 self
27127 }
27128 /// Identifies the authorization scope(s) for the method you are building.
27129 ///
27130 /// See [`Self::add_scope()`] for details.
27131 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyGetCall<'a, C>
27132 where
27133 I: IntoIterator<Item = St>,
27134 St: AsRef<str>,
27135 {
27136 self._scopes
27137 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27138 self
27139 }
27140
27141 /// Removes all scopes, and no default scope will be used either.
27142 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27143 /// for details).
27144 pub fn clear_scopes(mut self) -> ReplyGetCall<'a, C> {
27145 self._scopes.clear();
27146 self
27147 }
27148}
27149
27150/// Creates a new reply to the given comment.
27151///
27152/// A builder for the *insert* method supported by a *reply* resource.
27153/// It is not used directly, but through a [`ReplyMethods`] instance.
27154///
27155/// # Example
27156///
27157/// Instantiate a resource method builder
27158///
27159/// ```test_harness,no_run
27160/// # extern crate hyper;
27161/// # extern crate hyper_rustls;
27162/// # extern crate google_drive2 as drive2;
27163/// use drive2::api::CommentReply;
27164/// # async fn dox() {
27165/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27166///
27167/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27168/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27169/// # .with_native_roots()
27170/// # .unwrap()
27171/// # .https_only()
27172/// # .enable_http2()
27173/// # .build();
27174///
27175/// # let executor = hyper_util::rt::TokioExecutor::new();
27176/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27177/// # secret,
27178/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27179/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27180/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27181/// # ),
27182/// # ).build().await.unwrap();
27183///
27184/// # let client = hyper_util::client::legacy::Client::builder(
27185/// # hyper_util::rt::TokioExecutor::new()
27186/// # )
27187/// # .build(
27188/// # hyper_rustls::HttpsConnectorBuilder::new()
27189/// # .with_native_roots()
27190/// # .unwrap()
27191/// # .https_or_http()
27192/// # .enable_http2()
27193/// # .build()
27194/// # );
27195/// # let mut hub = DriveHub::new(client, auth);
27196/// // As the method needs a request, you would usually fill it with the desired information
27197/// // into the respective structure. Some of the parts shown here might not be applicable !
27198/// // Values shown here are possibly random and not representative !
27199/// let mut req = CommentReply::default();
27200///
27201/// // You can configure optional parameters by calling the respective setters at will, and
27202/// // execute the final call using `doit()`.
27203/// // Values shown here are possibly random and not representative !
27204/// let result = hub.replies().insert(req, "fileId", "commentId")
27205/// .doit().await;
27206/// # }
27207/// ```
27208pub struct ReplyInsertCall<'a, C>
27209where
27210 C: 'a,
27211{
27212 hub: &'a DriveHub<C>,
27213 _request: CommentReply,
27214 _file_id: String,
27215 _comment_id: String,
27216 _delegate: Option<&'a mut dyn common::Delegate>,
27217 _additional_params: HashMap<String, String>,
27218 _scopes: BTreeSet<String>,
27219}
27220
27221impl<'a, C> common::CallBuilder for ReplyInsertCall<'a, C> {}
27222
27223impl<'a, C> ReplyInsertCall<'a, C>
27224where
27225 C: common::Connector,
27226{
27227 /// Perform the operation you have build so far.
27228 pub async fn doit(mut self) -> common::Result<(common::Response, CommentReply)> {
27229 use std::borrow::Cow;
27230 use std::io::{Read, Seek};
27231
27232 use common::{url::Params, ToParts};
27233 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27234
27235 let mut dd = common::DefaultDelegate;
27236 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27237 dlg.begin(common::MethodInfo {
27238 id: "drive.replies.insert",
27239 http_method: hyper::Method::POST,
27240 });
27241
27242 for &field in ["alt", "fileId", "commentId"].iter() {
27243 if self._additional_params.contains_key(field) {
27244 dlg.finished(false);
27245 return Err(common::Error::FieldClash(field));
27246 }
27247 }
27248
27249 let mut params = Params::with_capacity(5 + self._additional_params.len());
27250 params.push("fileId", self._file_id);
27251 params.push("commentId", self._comment_id);
27252
27253 params.extend(self._additional_params.iter());
27254
27255 params.push("alt", "json");
27256 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies";
27257 if self._scopes.is_empty() {
27258 self._scopes.insert(Scope::Full.as_ref().to_string());
27259 }
27260
27261 #[allow(clippy::single_element_loop)]
27262 for &(find_this, param_name) in
27263 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
27264 {
27265 url = params.uri_replacement(url, param_name, find_this, false);
27266 }
27267 {
27268 let to_remove = ["commentId", "fileId"];
27269 params.remove_params(&to_remove);
27270 }
27271
27272 let url = params.parse_with_url(&url);
27273
27274 let mut json_mime_type = mime::APPLICATION_JSON;
27275 let mut request_value_reader = {
27276 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27277 common::remove_json_null_values(&mut value);
27278 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27279 serde_json::to_writer(&mut dst, &value).unwrap();
27280 dst
27281 };
27282 let request_size = request_value_reader
27283 .seek(std::io::SeekFrom::End(0))
27284 .unwrap();
27285 request_value_reader
27286 .seek(std::io::SeekFrom::Start(0))
27287 .unwrap();
27288
27289 loop {
27290 let token = match self
27291 .hub
27292 .auth
27293 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27294 .await
27295 {
27296 Ok(token) => token,
27297 Err(e) => match dlg.token(e) {
27298 Ok(token) => token,
27299 Err(e) => {
27300 dlg.finished(false);
27301 return Err(common::Error::MissingToken(e));
27302 }
27303 },
27304 };
27305 request_value_reader
27306 .seek(std::io::SeekFrom::Start(0))
27307 .unwrap();
27308 let mut req_result = {
27309 let client = &self.hub.client;
27310 dlg.pre_request();
27311 let mut req_builder = hyper::Request::builder()
27312 .method(hyper::Method::POST)
27313 .uri(url.as_str())
27314 .header(USER_AGENT, self.hub._user_agent.clone());
27315
27316 if let Some(token) = token.as_ref() {
27317 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27318 }
27319
27320 let request = req_builder
27321 .header(CONTENT_TYPE, json_mime_type.to_string())
27322 .header(CONTENT_LENGTH, request_size as u64)
27323 .body(common::to_body(
27324 request_value_reader.get_ref().clone().into(),
27325 ));
27326
27327 client.request(request.unwrap()).await
27328 };
27329
27330 match req_result {
27331 Err(err) => {
27332 if let common::Retry::After(d) = dlg.http_error(&err) {
27333 sleep(d).await;
27334 continue;
27335 }
27336 dlg.finished(false);
27337 return Err(common::Error::HttpError(err));
27338 }
27339 Ok(res) => {
27340 let (mut parts, body) = res.into_parts();
27341 let mut body = common::Body::new(body);
27342 if !parts.status.is_success() {
27343 let bytes = common::to_bytes(body).await.unwrap_or_default();
27344 let error = serde_json::from_str(&common::to_string(&bytes));
27345 let response = common::to_response(parts, bytes.into());
27346
27347 if let common::Retry::After(d) =
27348 dlg.http_failure(&response, error.as_ref().ok())
27349 {
27350 sleep(d).await;
27351 continue;
27352 }
27353
27354 dlg.finished(false);
27355
27356 return Err(match error {
27357 Ok(value) => common::Error::BadRequest(value),
27358 _ => common::Error::Failure(response),
27359 });
27360 }
27361 let response = {
27362 let bytes = common::to_bytes(body).await.unwrap_or_default();
27363 let encoded = common::to_string(&bytes);
27364 match serde_json::from_str(&encoded) {
27365 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27366 Err(error) => {
27367 dlg.response_json_decode_error(&encoded, &error);
27368 return Err(common::Error::JsonDecodeError(
27369 encoded.to_string(),
27370 error,
27371 ));
27372 }
27373 }
27374 };
27375
27376 dlg.finished(true);
27377 return Ok(response);
27378 }
27379 }
27380 }
27381 }
27382
27383 ///
27384 /// Sets the *request* property to the given value.
27385 ///
27386 /// Even though the property as already been set when instantiating this call,
27387 /// we provide this method for API completeness.
27388 pub fn request(mut self, new_value: CommentReply) -> ReplyInsertCall<'a, C> {
27389 self._request = new_value;
27390 self
27391 }
27392 /// The ID of the file.
27393 ///
27394 /// Sets the *file id* path property to the given value.
27395 ///
27396 /// Even though the property as already been set when instantiating this call,
27397 /// we provide this method for API completeness.
27398 pub fn file_id(mut self, new_value: &str) -> ReplyInsertCall<'a, C> {
27399 self._file_id = new_value.to_string();
27400 self
27401 }
27402 /// The ID of the comment.
27403 ///
27404 /// Sets the *comment id* path property to the given value.
27405 ///
27406 /// Even though the property as already been set when instantiating this call,
27407 /// we provide this method for API completeness.
27408 pub fn comment_id(mut self, new_value: &str) -> ReplyInsertCall<'a, C> {
27409 self._comment_id = new_value.to_string();
27410 self
27411 }
27412 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27413 /// while executing the actual API request.
27414 ///
27415 /// ````text
27416 /// It should be used to handle progress information, and to implement a certain level of resilience.
27417 /// ````
27418 ///
27419 /// Sets the *delegate* property to the given value.
27420 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyInsertCall<'a, C> {
27421 self._delegate = Some(new_value);
27422 self
27423 }
27424
27425 /// Set any additional parameter of the query string used in the request.
27426 /// It should be used to set parameters which are not yet available through their own
27427 /// setters.
27428 ///
27429 /// Please note that this method must not be used to set any of the known parameters
27430 /// which have their own setter method. If done anyway, the request will fail.
27431 ///
27432 /// # Additional Parameters
27433 ///
27434 /// * *$.xgafv* (query-string) - V1 error format.
27435 /// * *access_token* (query-string) - OAuth access token.
27436 /// * *alt* (query-string) - Data format for response.
27437 /// * *callback* (query-string) - JSONP
27438 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27439 /// * *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.
27440 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27441 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27442 /// * *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.
27443 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27444 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27445 pub fn param<T>(mut self, name: T, value: T) -> ReplyInsertCall<'a, C>
27446 where
27447 T: AsRef<str>,
27448 {
27449 self._additional_params
27450 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27451 self
27452 }
27453
27454 /// Identifies the authorization scope for the method you are building.
27455 ///
27456 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27457 /// [`Scope::Full`].
27458 ///
27459 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27460 /// tokens for more than one scope.
27461 ///
27462 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27463 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27464 /// sufficient, a read-write scope will do as well.
27465 pub fn add_scope<St>(mut self, scope: St) -> ReplyInsertCall<'a, C>
27466 where
27467 St: AsRef<str>,
27468 {
27469 self._scopes.insert(String::from(scope.as_ref()));
27470 self
27471 }
27472 /// Identifies the authorization scope(s) for the method you are building.
27473 ///
27474 /// See [`Self::add_scope()`] for details.
27475 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyInsertCall<'a, C>
27476 where
27477 I: IntoIterator<Item = St>,
27478 St: AsRef<str>,
27479 {
27480 self._scopes
27481 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27482 self
27483 }
27484
27485 /// Removes all scopes, and no default scope will be used either.
27486 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27487 /// for details).
27488 pub fn clear_scopes(mut self) -> ReplyInsertCall<'a, C> {
27489 self._scopes.clear();
27490 self
27491 }
27492}
27493
27494/// Lists all of the replies to a comment.
27495///
27496/// A builder for the *list* method supported by a *reply* resource.
27497/// It is not used directly, but through a [`ReplyMethods`] instance.
27498///
27499/// # Example
27500///
27501/// Instantiate a resource method builder
27502///
27503/// ```test_harness,no_run
27504/// # extern crate hyper;
27505/// # extern crate hyper_rustls;
27506/// # extern crate google_drive2 as drive2;
27507/// # async fn dox() {
27508/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27509///
27510/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27511/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27512/// # .with_native_roots()
27513/// # .unwrap()
27514/// # .https_only()
27515/// # .enable_http2()
27516/// # .build();
27517///
27518/// # let executor = hyper_util::rt::TokioExecutor::new();
27519/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27520/// # secret,
27521/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27522/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27523/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27524/// # ),
27525/// # ).build().await.unwrap();
27526///
27527/// # let client = hyper_util::client::legacy::Client::builder(
27528/// # hyper_util::rt::TokioExecutor::new()
27529/// # )
27530/// # .build(
27531/// # hyper_rustls::HttpsConnectorBuilder::new()
27532/// # .with_native_roots()
27533/// # .unwrap()
27534/// # .https_or_http()
27535/// # .enable_http2()
27536/// # .build()
27537/// # );
27538/// # let mut hub = DriveHub::new(client, auth);
27539/// // You can configure optional parameters by calling the respective setters at will, and
27540/// // execute the final call using `doit()`.
27541/// // Values shown here are possibly random and not representative !
27542/// let result = hub.replies().list("fileId", "commentId")
27543/// .page_token("magna")
27544/// .max_results(-88)
27545/// .include_deleted(false)
27546/// .doit().await;
27547/// # }
27548/// ```
27549pub struct ReplyListCall<'a, C>
27550where
27551 C: 'a,
27552{
27553 hub: &'a DriveHub<C>,
27554 _file_id: String,
27555 _comment_id: String,
27556 _page_token: Option<String>,
27557 _max_results: Option<i32>,
27558 _include_deleted: Option<bool>,
27559 _delegate: Option<&'a mut dyn common::Delegate>,
27560 _additional_params: HashMap<String, String>,
27561 _scopes: BTreeSet<String>,
27562}
27563
27564impl<'a, C> common::CallBuilder for ReplyListCall<'a, C> {}
27565
27566impl<'a, C> ReplyListCall<'a, C>
27567where
27568 C: common::Connector,
27569{
27570 /// Perform the operation you have build so far.
27571 pub async fn doit(mut self) -> common::Result<(common::Response, CommentReplyList)> {
27572 use std::borrow::Cow;
27573 use std::io::{Read, Seek};
27574
27575 use common::{url::Params, ToParts};
27576 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27577
27578 let mut dd = common::DefaultDelegate;
27579 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27580 dlg.begin(common::MethodInfo {
27581 id: "drive.replies.list",
27582 http_method: hyper::Method::GET,
27583 });
27584
27585 for &field in [
27586 "alt",
27587 "fileId",
27588 "commentId",
27589 "pageToken",
27590 "maxResults",
27591 "includeDeleted",
27592 ]
27593 .iter()
27594 {
27595 if self._additional_params.contains_key(field) {
27596 dlg.finished(false);
27597 return Err(common::Error::FieldClash(field));
27598 }
27599 }
27600
27601 let mut params = Params::with_capacity(7 + self._additional_params.len());
27602 params.push("fileId", self._file_id);
27603 params.push("commentId", self._comment_id);
27604 if let Some(value) = self._page_token.as_ref() {
27605 params.push("pageToken", value);
27606 }
27607 if let Some(value) = self._max_results.as_ref() {
27608 params.push("maxResults", value.to_string());
27609 }
27610 if let Some(value) = self._include_deleted.as_ref() {
27611 params.push("includeDeleted", value.to_string());
27612 }
27613
27614 params.extend(self._additional_params.iter());
27615
27616 params.push("alt", "json");
27617 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies";
27618 if self._scopes.is_empty() {
27619 self._scopes
27620 .insert(Scope::MeetReadonly.as_ref().to_string());
27621 }
27622
27623 #[allow(clippy::single_element_loop)]
27624 for &(find_this, param_name) in
27625 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
27626 {
27627 url = params.uri_replacement(url, param_name, find_this, false);
27628 }
27629 {
27630 let to_remove = ["commentId", "fileId"];
27631 params.remove_params(&to_remove);
27632 }
27633
27634 let url = params.parse_with_url(&url);
27635
27636 loop {
27637 let token = match self
27638 .hub
27639 .auth
27640 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27641 .await
27642 {
27643 Ok(token) => token,
27644 Err(e) => match dlg.token(e) {
27645 Ok(token) => token,
27646 Err(e) => {
27647 dlg.finished(false);
27648 return Err(common::Error::MissingToken(e));
27649 }
27650 },
27651 };
27652 let mut req_result = {
27653 let client = &self.hub.client;
27654 dlg.pre_request();
27655 let mut req_builder = hyper::Request::builder()
27656 .method(hyper::Method::GET)
27657 .uri(url.as_str())
27658 .header(USER_AGENT, self.hub._user_agent.clone());
27659
27660 if let Some(token) = token.as_ref() {
27661 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27662 }
27663
27664 let request = req_builder
27665 .header(CONTENT_LENGTH, 0_u64)
27666 .body(common::to_body::<String>(None));
27667
27668 client.request(request.unwrap()).await
27669 };
27670
27671 match req_result {
27672 Err(err) => {
27673 if let common::Retry::After(d) = dlg.http_error(&err) {
27674 sleep(d).await;
27675 continue;
27676 }
27677 dlg.finished(false);
27678 return Err(common::Error::HttpError(err));
27679 }
27680 Ok(res) => {
27681 let (mut parts, body) = res.into_parts();
27682 let mut body = common::Body::new(body);
27683 if !parts.status.is_success() {
27684 let bytes = common::to_bytes(body).await.unwrap_or_default();
27685 let error = serde_json::from_str(&common::to_string(&bytes));
27686 let response = common::to_response(parts, bytes.into());
27687
27688 if let common::Retry::After(d) =
27689 dlg.http_failure(&response, error.as_ref().ok())
27690 {
27691 sleep(d).await;
27692 continue;
27693 }
27694
27695 dlg.finished(false);
27696
27697 return Err(match error {
27698 Ok(value) => common::Error::BadRequest(value),
27699 _ => common::Error::Failure(response),
27700 });
27701 }
27702 let response = {
27703 let bytes = common::to_bytes(body).await.unwrap_or_default();
27704 let encoded = common::to_string(&bytes);
27705 match serde_json::from_str(&encoded) {
27706 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27707 Err(error) => {
27708 dlg.response_json_decode_error(&encoded, &error);
27709 return Err(common::Error::JsonDecodeError(
27710 encoded.to_string(),
27711 error,
27712 ));
27713 }
27714 }
27715 };
27716
27717 dlg.finished(true);
27718 return Ok(response);
27719 }
27720 }
27721 }
27722 }
27723
27724 /// The ID of the file.
27725 ///
27726 /// Sets the *file id* path property to the given value.
27727 ///
27728 /// Even though the property as already been set when instantiating this call,
27729 /// we provide this method for API completeness.
27730 pub fn file_id(mut self, new_value: &str) -> ReplyListCall<'a, C> {
27731 self._file_id = new_value.to_string();
27732 self
27733 }
27734 /// The ID of the comment.
27735 ///
27736 /// Sets the *comment id* path property to the given value.
27737 ///
27738 /// Even though the property as already been set when instantiating this call,
27739 /// we provide this method for API completeness.
27740 pub fn comment_id(mut self, new_value: &str) -> ReplyListCall<'a, C> {
27741 self._comment_id = new_value.to_string();
27742 self
27743 }
27744 /// 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.
27745 ///
27746 /// Sets the *page token* query property to the given value.
27747 pub fn page_token(mut self, new_value: &str) -> ReplyListCall<'a, C> {
27748 self._page_token = Some(new_value.to_string());
27749 self
27750 }
27751 /// The maximum number of replies to include in the response, used for paging.
27752 ///
27753 /// Sets the *max results* query property to the given value.
27754 pub fn max_results(mut self, new_value: i32) -> ReplyListCall<'a, C> {
27755 self._max_results = Some(new_value);
27756 self
27757 }
27758 /// If set, all replies, including deleted replies (with content stripped) will be returned.
27759 ///
27760 /// Sets the *include deleted* query property to the given value.
27761 pub fn include_deleted(mut self, new_value: bool) -> ReplyListCall<'a, C> {
27762 self._include_deleted = Some(new_value);
27763 self
27764 }
27765 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27766 /// while executing the actual API request.
27767 ///
27768 /// ````text
27769 /// It should be used to handle progress information, and to implement a certain level of resilience.
27770 /// ````
27771 ///
27772 /// Sets the *delegate* property to the given value.
27773 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyListCall<'a, C> {
27774 self._delegate = Some(new_value);
27775 self
27776 }
27777
27778 /// Set any additional parameter of the query string used in the request.
27779 /// It should be used to set parameters which are not yet available through their own
27780 /// setters.
27781 ///
27782 /// Please note that this method must not be used to set any of the known parameters
27783 /// which have their own setter method. If done anyway, the request will fail.
27784 ///
27785 /// # Additional Parameters
27786 ///
27787 /// * *$.xgafv* (query-string) - V1 error format.
27788 /// * *access_token* (query-string) - OAuth access token.
27789 /// * *alt* (query-string) - Data format for response.
27790 /// * *callback* (query-string) - JSONP
27791 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27792 /// * *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.
27793 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27794 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27795 /// * *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.
27796 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27797 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27798 pub fn param<T>(mut self, name: T, value: T) -> ReplyListCall<'a, C>
27799 where
27800 T: AsRef<str>,
27801 {
27802 self._additional_params
27803 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27804 self
27805 }
27806
27807 /// Identifies the authorization scope for the method you are building.
27808 ///
27809 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27810 /// [`Scope::MeetReadonly`].
27811 ///
27812 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27813 /// tokens for more than one scope.
27814 ///
27815 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27816 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27817 /// sufficient, a read-write scope will do as well.
27818 pub fn add_scope<St>(mut self, scope: St) -> ReplyListCall<'a, C>
27819 where
27820 St: AsRef<str>,
27821 {
27822 self._scopes.insert(String::from(scope.as_ref()));
27823 self
27824 }
27825 /// Identifies the authorization scope(s) for the method you are building.
27826 ///
27827 /// See [`Self::add_scope()`] for details.
27828 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyListCall<'a, C>
27829 where
27830 I: IntoIterator<Item = St>,
27831 St: AsRef<str>,
27832 {
27833 self._scopes
27834 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27835 self
27836 }
27837
27838 /// Removes all scopes, and no default scope will be used either.
27839 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27840 /// for details).
27841 pub fn clear_scopes(mut self) -> ReplyListCall<'a, C> {
27842 self._scopes.clear();
27843 self
27844 }
27845}
27846
27847/// Updates an existing reply.
27848///
27849/// A builder for the *patch* method supported by a *reply* resource.
27850/// It is not used directly, but through a [`ReplyMethods`] instance.
27851///
27852/// # Example
27853///
27854/// Instantiate a resource method builder
27855///
27856/// ```test_harness,no_run
27857/// # extern crate hyper;
27858/// # extern crate hyper_rustls;
27859/// # extern crate google_drive2 as drive2;
27860/// use drive2::api::CommentReply;
27861/// # async fn dox() {
27862/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27863///
27864/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27865/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27866/// # .with_native_roots()
27867/// # .unwrap()
27868/// # .https_only()
27869/// # .enable_http2()
27870/// # .build();
27871///
27872/// # let executor = hyper_util::rt::TokioExecutor::new();
27873/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27874/// # secret,
27875/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27876/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27877/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27878/// # ),
27879/// # ).build().await.unwrap();
27880///
27881/// # let client = hyper_util::client::legacy::Client::builder(
27882/// # hyper_util::rt::TokioExecutor::new()
27883/// # )
27884/// # .build(
27885/// # hyper_rustls::HttpsConnectorBuilder::new()
27886/// # .with_native_roots()
27887/// # .unwrap()
27888/// # .https_or_http()
27889/// # .enable_http2()
27890/// # .build()
27891/// # );
27892/// # let mut hub = DriveHub::new(client, auth);
27893/// // As the method needs a request, you would usually fill it with the desired information
27894/// // into the respective structure. Some of the parts shown here might not be applicable !
27895/// // Values shown here are possibly random and not representative !
27896/// let mut req = CommentReply::default();
27897///
27898/// // You can configure optional parameters by calling the respective setters at will, and
27899/// // execute the final call using `doit()`.
27900/// // Values shown here are possibly random and not representative !
27901/// let result = hub.replies().patch(req, "fileId", "commentId", "replyId")
27902/// .doit().await;
27903/// # }
27904/// ```
27905pub struct ReplyPatchCall<'a, C>
27906where
27907 C: 'a,
27908{
27909 hub: &'a DriveHub<C>,
27910 _request: CommentReply,
27911 _file_id: String,
27912 _comment_id: String,
27913 _reply_id: String,
27914 _delegate: Option<&'a mut dyn common::Delegate>,
27915 _additional_params: HashMap<String, String>,
27916 _scopes: BTreeSet<String>,
27917}
27918
27919impl<'a, C> common::CallBuilder for ReplyPatchCall<'a, C> {}
27920
27921impl<'a, C> ReplyPatchCall<'a, C>
27922where
27923 C: common::Connector,
27924{
27925 /// Perform the operation you have build so far.
27926 pub async fn doit(mut self) -> common::Result<(common::Response, CommentReply)> {
27927 use std::borrow::Cow;
27928 use std::io::{Read, Seek};
27929
27930 use common::{url::Params, ToParts};
27931 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27932
27933 let mut dd = common::DefaultDelegate;
27934 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27935 dlg.begin(common::MethodInfo {
27936 id: "drive.replies.patch",
27937 http_method: hyper::Method::PATCH,
27938 });
27939
27940 for &field in ["alt", "fileId", "commentId", "replyId"].iter() {
27941 if self._additional_params.contains_key(field) {
27942 dlg.finished(false);
27943 return Err(common::Error::FieldClash(field));
27944 }
27945 }
27946
27947 let mut params = Params::with_capacity(6 + self._additional_params.len());
27948 params.push("fileId", self._file_id);
27949 params.push("commentId", self._comment_id);
27950 params.push("replyId", self._reply_id);
27951
27952 params.extend(self._additional_params.iter());
27953
27954 params.push("alt", "json");
27955 let mut url =
27956 self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}";
27957 if self._scopes.is_empty() {
27958 self._scopes.insert(Scope::Full.as_ref().to_string());
27959 }
27960
27961 #[allow(clippy::single_element_loop)]
27962 for &(find_this, param_name) in [
27963 ("{fileId}", "fileId"),
27964 ("{commentId}", "commentId"),
27965 ("{replyId}", "replyId"),
27966 ]
27967 .iter()
27968 {
27969 url = params.uri_replacement(url, param_name, find_this, false);
27970 }
27971 {
27972 let to_remove = ["replyId", "commentId", "fileId"];
27973 params.remove_params(&to_remove);
27974 }
27975
27976 let url = params.parse_with_url(&url);
27977
27978 let mut json_mime_type = mime::APPLICATION_JSON;
27979 let mut request_value_reader = {
27980 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27981 common::remove_json_null_values(&mut value);
27982 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27983 serde_json::to_writer(&mut dst, &value).unwrap();
27984 dst
27985 };
27986 let request_size = request_value_reader
27987 .seek(std::io::SeekFrom::End(0))
27988 .unwrap();
27989 request_value_reader
27990 .seek(std::io::SeekFrom::Start(0))
27991 .unwrap();
27992
27993 loop {
27994 let token = match self
27995 .hub
27996 .auth
27997 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27998 .await
27999 {
28000 Ok(token) => token,
28001 Err(e) => match dlg.token(e) {
28002 Ok(token) => token,
28003 Err(e) => {
28004 dlg.finished(false);
28005 return Err(common::Error::MissingToken(e));
28006 }
28007 },
28008 };
28009 request_value_reader
28010 .seek(std::io::SeekFrom::Start(0))
28011 .unwrap();
28012 let mut req_result = {
28013 let client = &self.hub.client;
28014 dlg.pre_request();
28015 let mut req_builder = hyper::Request::builder()
28016 .method(hyper::Method::PATCH)
28017 .uri(url.as_str())
28018 .header(USER_AGENT, self.hub._user_agent.clone());
28019
28020 if let Some(token) = token.as_ref() {
28021 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28022 }
28023
28024 let request = req_builder
28025 .header(CONTENT_TYPE, json_mime_type.to_string())
28026 .header(CONTENT_LENGTH, request_size as u64)
28027 .body(common::to_body(
28028 request_value_reader.get_ref().clone().into(),
28029 ));
28030
28031 client.request(request.unwrap()).await
28032 };
28033
28034 match req_result {
28035 Err(err) => {
28036 if let common::Retry::After(d) = dlg.http_error(&err) {
28037 sleep(d).await;
28038 continue;
28039 }
28040 dlg.finished(false);
28041 return Err(common::Error::HttpError(err));
28042 }
28043 Ok(res) => {
28044 let (mut parts, body) = res.into_parts();
28045 let mut body = common::Body::new(body);
28046 if !parts.status.is_success() {
28047 let bytes = common::to_bytes(body).await.unwrap_or_default();
28048 let error = serde_json::from_str(&common::to_string(&bytes));
28049 let response = common::to_response(parts, bytes.into());
28050
28051 if let common::Retry::After(d) =
28052 dlg.http_failure(&response, error.as_ref().ok())
28053 {
28054 sleep(d).await;
28055 continue;
28056 }
28057
28058 dlg.finished(false);
28059
28060 return Err(match error {
28061 Ok(value) => common::Error::BadRequest(value),
28062 _ => common::Error::Failure(response),
28063 });
28064 }
28065 let response = {
28066 let bytes = common::to_bytes(body).await.unwrap_or_default();
28067 let encoded = common::to_string(&bytes);
28068 match serde_json::from_str(&encoded) {
28069 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28070 Err(error) => {
28071 dlg.response_json_decode_error(&encoded, &error);
28072 return Err(common::Error::JsonDecodeError(
28073 encoded.to_string(),
28074 error,
28075 ));
28076 }
28077 }
28078 };
28079
28080 dlg.finished(true);
28081 return Ok(response);
28082 }
28083 }
28084 }
28085 }
28086
28087 ///
28088 /// Sets the *request* property to the given value.
28089 ///
28090 /// Even though the property as already been set when instantiating this call,
28091 /// we provide this method for API completeness.
28092 pub fn request(mut self, new_value: CommentReply) -> ReplyPatchCall<'a, C> {
28093 self._request = new_value;
28094 self
28095 }
28096 /// The ID of the file.
28097 ///
28098 /// Sets the *file id* path property to the given value.
28099 ///
28100 /// Even though the property as already been set when instantiating this call,
28101 /// we provide this method for API completeness.
28102 pub fn file_id(mut self, new_value: &str) -> ReplyPatchCall<'a, C> {
28103 self._file_id = new_value.to_string();
28104 self
28105 }
28106 /// The ID of the comment.
28107 ///
28108 /// Sets the *comment id* path property to the given value.
28109 ///
28110 /// Even though the property as already been set when instantiating this call,
28111 /// we provide this method for API completeness.
28112 pub fn comment_id(mut self, new_value: &str) -> ReplyPatchCall<'a, C> {
28113 self._comment_id = new_value.to_string();
28114 self
28115 }
28116 /// The ID of the reply.
28117 ///
28118 /// Sets the *reply id* path property to the given value.
28119 ///
28120 /// Even though the property as already been set when instantiating this call,
28121 /// we provide this method for API completeness.
28122 pub fn reply_id(mut self, new_value: &str) -> ReplyPatchCall<'a, C> {
28123 self._reply_id = new_value.to_string();
28124 self
28125 }
28126 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28127 /// while executing the actual API request.
28128 ///
28129 /// ````text
28130 /// It should be used to handle progress information, and to implement a certain level of resilience.
28131 /// ````
28132 ///
28133 /// Sets the *delegate* property to the given value.
28134 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyPatchCall<'a, C> {
28135 self._delegate = Some(new_value);
28136 self
28137 }
28138
28139 /// Set any additional parameter of the query string used in the request.
28140 /// It should be used to set parameters which are not yet available through their own
28141 /// setters.
28142 ///
28143 /// Please note that this method must not be used to set any of the known parameters
28144 /// which have their own setter method. If done anyway, the request will fail.
28145 ///
28146 /// # Additional Parameters
28147 ///
28148 /// * *$.xgafv* (query-string) - V1 error format.
28149 /// * *access_token* (query-string) - OAuth access token.
28150 /// * *alt* (query-string) - Data format for response.
28151 /// * *callback* (query-string) - JSONP
28152 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28153 /// * *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.
28154 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28155 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28156 /// * *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.
28157 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28158 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28159 pub fn param<T>(mut self, name: T, value: T) -> ReplyPatchCall<'a, C>
28160 where
28161 T: AsRef<str>,
28162 {
28163 self._additional_params
28164 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28165 self
28166 }
28167
28168 /// Identifies the authorization scope for the method you are building.
28169 ///
28170 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28171 /// [`Scope::Full`].
28172 ///
28173 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28174 /// tokens for more than one scope.
28175 ///
28176 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28177 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28178 /// sufficient, a read-write scope will do as well.
28179 pub fn add_scope<St>(mut self, scope: St) -> ReplyPatchCall<'a, C>
28180 where
28181 St: AsRef<str>,
28182 {
28183 self._scopes.insert(String::from(scope.as_ref()));
28184 self
28185 }
28186 /// Identifies the authorization scope(s) for the method you are building.
28187 ///
28188 /// See [`Self::add_scope()`] for details.
28189 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyPatchCall<'a, C>
28190 where
28191 I: IntoIterator<Item = St>,
28192 St: AsRef<str>,
28193 {
28194 self._scopes
28195 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28196 self
28197 }
28198
28199 /// Removes all scopes, and no default scope will be used either.
28200 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28201 /// for details).
28202 pub fn clear_scopes(mut self) -> ReplyPatchCall<'a, C> {
28203 self._scopes.clear();
28204 self
28205 }
28206}
28207
28208/// Updates an existing reply.
28209///
28210/// A builder for the *update* method supported by a *reply* resource.
28211/// It is not used directly, but through a [`ReplyMethods`] instance.
28212///
28213/// # Example
28214///
28215/// Instantiate a resource method builder
28216///
28217/// ```test_harness,no_run
28218/// # extern crate hyper;
28219/// # extern crate hyper_rustls;
28220/// # extern crate google_drive2 as drive2;
28221/// use drive2::api::CommentReply;
28222/// # async fn dox() {
28223/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28224///
28225/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28226/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28227/// # .with_native_roots()
28228/// # .unwrap()
28229/// # .https_only()
28230/// # .enable_http2()
28231/// # .build();
28232///
28233/// # let executor = hyper_util::rt::TokioExecutor::new();
28234/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28235/// # secret,
28236/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28237/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28238/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28239/// # ),
28240/// # ).build().await.unwrap();
28241///
28242/// # let client = hyper_util::client::legacy::Client::builder(
28243/// # hyper_util::rt::TokioExecutor::new()
28244/// # )
28245/// # .build(
28246/// # hyper_rustls::HttpsConnectorBuilder::new()
28247/// # .with_native_roots()
28248/// # .unwrap()
28249/// # .https_or_http()
28250/// # .enable_http2()
28251/// # .build()
28252/// # );
28253/// # let mut hub = DriveHub::new(client, auth);
28254/// // As the method needs a request, you would usually fill it with the desired information
28255/// // into the respective structure. Some of the parts shown here might not be applicable !
28256/// // Values shown here are possibly random and not representative !
28257/// let mut req = CommentReply::default();
28258///
28259/// // You can configure optional parameters by calling the respective setters at will, and
28260/// // execute the final call using `doit()`.
28261/// // Values shown here are possibly random and not representative !
28262/// let result = hub.replies().update(req, "fileId", "commentId", "replyId")
28263/// .doit().await;
28264/// # }
28265/// ```
28266pub struct ReplyUpdateCall<'a, C>
28267where
28268 C: 'a,
28269{
28270 hub: &'a DriveHub<C>,
28271 _request: CommentReply,
28272 _file_id: String,
28273 _comment_id: String,
28274 _reply_id: String,
28275 _delegate: Option<&'a mut dyn common::Delegate>,
28276 _additional_params: HashMap<String, String>,
28277 _scopes: BTreeSet<String>,
28278}
28279
28280impl<'a, C> common::CallBuilder for ReplyUpdateCall<'a, C> {}
28281
28282impl<'a, C> ReplyUpdateCall<'a, C>
28283where
28284 C: common::Connector,
28285{
28286 /// Perform the operation you have build so far.
28287 pub async fn doit(mut self) -> common::Result<(common::Response, CommentReply)> {
28288 use std::borrow::Cow;
28289 use std::io::{Read, Seek};
28290
28291 use common::{url::Params, ToParts};
28292 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28293
28294 let mut dd = common::DefaultDelegate;
28295 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28296 dlg.begin(common::MethodInfo {
28297 id: "drive.replies.update",
28298 http_method: hyper::Method::PUT,
28299 });
28300
28301 for &field in ["alt", "fileId", "commentId", "replyId"].iter() {
28302 if self._additional_params.contains_key(field) {
28303 dlg.finished(false);
28304 return Err(common::Error::FieldClash(field));
28305 }
28306 }
28307
28308 let mut params = Params::with_capacity(6 + self._additional_params.len());
28309 params.push("fileId", self._file_id);
28310 params.push("commentId", self._comment_id);
28311 params.push("replyId", self._reply_id);
28312
28313 params.extend(self._additional_params.iter());
28314
28315 params.push("alt", "json");
28316 let mut url =
28317 self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}";
28318 if self._scopes.is_empty() {
28319 self._scopes.insert(Scope::Full.as_ref().to_string());
28320 }
28321
28322 #[allow(clippy::single_element_loop)]
28323 for &(find_this, param_name) in [
28324 ("{fileId}", "fileId"),
28325 ("{commentId}", "commentId"),
28326 ("{replyId}", "replyId"),
28327 ]
28328 .iter()
28329 {
28330 url = params.uri_replacement(url, param_name, find_this, false);
28331 }
28332 {
28333 let to_remove = ["replyId", "commentId", "fileId"];
28334 params.remove_params(&to_remove);
28335 }
28336
28337 let url = params.parse_with_url(&url);
28338
28339 let mut json_mime_type = mime::APPLICATION_JSON;
28340 let mut request_value_reader = {
28341 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28342 common::remove_json_null_values(&mut value);
28343 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28344 serde_json::to_writer(&mut dst, &value).unwrap();
28345 dst
28346 };
28347 let request_size = request_value_reader
28348 .seek(std::io::SeekFrom::End(0))
28349 .unwrap();
28350 request_value_reader
28351 .seek(std::io::SeekFrom::Start(0))
28352 .unwrap();
28353
28354 loop {
28355 let token = match self
28356 .hub
28357 .auth
28358 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28359 .await
28360 {
28361 Ok(token) => token,
28362 Err(e) => match dlg.token(e) {
28363 Ok(token) => token,
28364 Err(e) => {
28365 dlg.finished(false);
28366 return Err(common::Error::MissingToken(e));
28367 }
28368 },
28369 };
28370 request_value_reader
28371 .seek(std::io::SeekFrom::Start(0))
28372 .unwrap();
28373 let mut req_result = {
28374 let client = &self.hub.client;
28375 dlg.pre_request();
28376 let mut req_builder = hyper::Request::builder()
28377 .method(hyper::Method::PUT)
28378 .uri(url.as_str())
28379 .header(USER_AGENT, self.hub._user_agent.clone());
28380
28381 if let Some(token) = token.as_ref() {
28382 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28383 }
28384
28385 let request = req_builder
28386 .header(CONTENT_TYPE, json_mime_type.to_string())
28387 .header(CONTENT_LENGTH, request_size as u64)
28388 .body(common::to_body(
28389 request_value_reader.get_ref().clone().into(),
28390 ));
28391
28392 client.request(request.unwrap()).await
28393 };
28394
28395 match req_result {
28396 Err(err) => {
28397 if let common::Retry::After(d) = dlg.http_error(&err) {
28398 sleep(d).await;
28399 continue;
28400 }
28401 dlg.finished(false);
28402 return Err(common::Error::HttpError(err));
28403 }
28404 Ok(res) => {
28405 let (mut parts, body) = res.into_parts();
28406 let mut body = common::Body::new(body);
28407 if !parts.status.is_success() {
28408 let bytes = common::to_bytes(body).await.unwrap_or_default();
28409 let error = serde_json::from_str(&common::to_string(&bytes));
28410 let response = common::to_response(parts, bytes.into());
28411
28412 if let common::Retry::After(d) =
28413 dlg.http_failure(&response, error.as_ref().ok())
28414 {
28415 sleep(d).await;
28416 continue;
28417 }
28418
28419 dlg.finished(false);
28420
28421 return Err(match error {
28422 Ok(value) => common::Error::BadRequest(value),
28423 _ => common::Error::Failure(response),
28424 });
28425 }
28426 let response = {
28427 let bytes = common::to_bytes(body).await.unwrap_or_default();
28428 let encoded = common::to_string(&bytes);
28429 match serde_json::from_str(&encoded) {
28430 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28431 Err(error) => {
28432 dlg.response_json_decode_error(&encoded, &error);
28433 return Err(common::Error::JsonDecodeError(
28434 encoded.to_string(),
28435 error,
28436 ));
28437 }
28438 }
28439 };
28440
28441 dlg.finished(true);
28442 return Ok(response);
28443 }
28444 }
28445 }
28446 }
28447
28448 ///
28449 /// Sets the *request* property to the given value.
28450 ///
28451 /// Even though the property as already been set when instantiating this call,
28452 /// we provide this method for API completeness.
28453 pub fn request(mut self, new_value: CommentReply) -> ReplyUpdateCall<'a, C> {
28454 self._request = new_value;
28455 self
28456 }
28457 /// The ID of the file.
28458 ///
28459 /// Sets the *file id* path property to the given value.
28460 ///
28461 /// Even though the property as already been set when instantiating this call,
28462 /// we provide this method for API completeness.
28463 pub fn file_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, C> {
28464 self._file_id = new_value.to_string();
28465 self
28466 }
28467 /// The ID of the comment.
28468 ///
28469 /// Sets the *comment id* path property to the given value.
28470 ///
28471 /// Even though the property as already been set when instantiating this call,
28472 /// we provide this method for API completeness.
28473 pub fn comment_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, C> {
28474 self._comment_id = new_value.to_string();
28475 self
28476 }
28477 /// The ID of the reply.
28478 ///
28479 /// Sets the *reply id* path property to the given value.
28480 ///
28481 /// Even though the property as already been set when instantiating this call,
28482 /// we provide this method for API completeness.
28483 pub fn reply_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, C> {
28484 self._reply_id = new_value.to_string();
28485 self
28486 }
28487 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28488 /// while executing the actual API request.
28489 ///
28490 /// ````text
28491 /// It should be used to handle progress information, and to implement a certain level of resilience.
28492 /// ````
28493 ///
28494 /// Sets the *delegate* property to the given value.
28495 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyUpdateCall<'a, C> {
28496 self._delegate = Some(new_value);
28497 self
28498 }
28499
28500 /// Set any additional parameter of the query string used in the request.
28501 /// It should be used to set parameters which are not yet available through their own
28502 /// setters.
28503 ///
28504 /// Please note that this method must not be used to set any of the known parameters
28505 /// which have their own setter method. If done anyway, the request will fail.
28506 ///
28507 /// # Additional Parameters
28508 ///
28509 /// * *$.xgafv* (query-string) - V1 error format.
28510 /// * *access_token* (query-string) - OAuth access token.
28511 /// * *alt* (query-string) - Data format for response.
28512 /// * *callback* (query-string) - JSONP
28513 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28514 /// * *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.
28515 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28516 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28517 /// * *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.
28518 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28519 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28520 pub fn param<T>(mut self, name: T, value: T) -> ReplyUpdateCall<'a, C>
28521 where
28522 T: AsRef<str>,
28523 {
28524 self._additional_params
28525 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28526 self
28527 }
28528
28529 /// Identifies the authorization scope for the method you are building.
28530 ///
28531 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28532 /// [`Scope::Full`].
28533 ///
28534 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28535 /// tokens for more than one scope.
28536 ///
28537 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28538 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28539 /// sufficient, a read-write scope will do as well.
28540 pub fn add_scope<St>(mut self, scope: St) -> ReplyUpdateCall<'a, C>
28541 where
28542 St: AsRef<str>,
28543 {
28544 self._scopes.insert(String::from(scope.as_ref()));
28545 self
28546 }
28547 /// Identifies the authorization scope(s) for the method you are building.
28548 ///
28549 /// See [`Self::add_scope()`] for details.
28550 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyUpdateCall<'a, C>
28551 where
28552 I: IntoIterator<Item = St>,
28553 St: AsRef<str>,
28554 {
28555 self._scopes
28556 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28557 self
28558 }
28559
28560 /// Removes all scopes, and no default scope will be used either.
28561 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28562 /// for details).
28563 pub fn clear_scopes(mut self) -> ReplyUpdateCall<'a, C> {
28564 self._scopes.clear();
28565 self
28566 }
28567}
28568
28569/// 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.
28570///
28571/// A builder for the *delete* method supported by a *revision* resource.
28572/// It is not used directly, but through a [`RevisionMethods`] instance.
28573///
28574/// # Example
28575///
28576/// Instantiate a resource method builder
28577///
28578/// ```test_harness,no_run
28579/// # extern crate hyper;
28580/// # extern crate hyper_rustls;
28581/// # extern crate google_drive2 as drive2;
28582/// # async fn dox() {
28583/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28584///
28585/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28586/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28587/// # .with_native_roots()
28588/// # .unwrap()
28589/// # .https_only()
28590/// # .enable_http2()
28591/// # .build();
28592///
28593/// # let executor = hyper_util::rt::TokioExecutor::new();
28594/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28595/// # secret,
28596/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28597/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28598/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28599/// # ),
28600/// # ).build().await.unwrap();
28601///
28602/// # let client = hyper_util::client::legacy::Client::builder(
28603/// # hyper_util::rt::TokioExecutor::new()
28604/// # )
28605/// # .build(
28606/// # hyper_rustls::HttpsConnectorBuilder::new()
28607/// # .with_native_roots()
28608/// # .unwrap()
28609/// # .https_or_http()
28610/// # .enable_http2()
28611/// # .build()
28612/// # );
28613/// # let mut hub = DriveHub::new(client, auth);
28614/// // You can configure optional parameters by calling the respective setters at will, and
28615/// // execute the final call using `doit()`.
28616/// // Values shown here are possibly random and not representative !
28617/// let result = hub.revisions().delete("fileId", "revisionId")
28618/// .doit().await;
28619/// # }
28620/// ```
28621pub struct RevisionDeleteCall<'a, C>
28622where
28623 C: 'a,
28624{
28625 hub: &'a DriveHub<C>,
28626 _file_id: String,
28627 _revision_id: String,
28628 _delegate: Option<&'a mut dyn common::Delegate>,
28629 _additional_params: HashMap<String, String>,
28630 _scopes: BTreeSet<String>,
28631}
28632
28633impl<'a, C> common::CallBuilder for RevisionDeleteCall<'a, C> {}
28634
28635impl<'a, C> RevisionDeleteCall<'a, C>
28636where
28637 C: common::Connector,
28638{
28639 /// Perform the operation you have build so far.
28640 pub async fn doit(mut self) -> common::Result<common::Response> {
28641 use std::borrow::Cow;
28642 use std::io::{Read, Seek};
28643
28644 use common::{url::Params, ToParts};
28645 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28646
28647 let mut dd = common::DefaultDelegate;
28648 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28649 dlg.begin(common::MethodInfo {
28650 id: "drive.revisions.delete",
28651 http_method: hyper::Method::DELETE,
28652 });
28653
28654 for &field in ["fileId", "revisionId"].iter() {
28655 if self._additional_params.contains_key(field) {
28656 dlg.finished(false);
28657 return Err(common::Error::FieldClash(field));
28658 }
28659 }
28660
28661 let mut params = Params::with_capacity(3 + self._additional_params.len());
28662 params.push("fileId", self._file_id);
28663 params.push("revisionId", self._revision_id);
28664
28665 params.extend(self._additional_params.iter());
28666
28667 let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}";
28668 if self._scopes.is_empty() {
28669 self._scopes.insert(Scope::Full.as_ref().to_string());
28670 }
28671
28672 #[allow(clippy::single_element_loop)]
28673 for &(find_this, param_name) in
28674 [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter()
28675 {
28676 url = params.uri_replacement(url, param_name, find_this, false);
28677 }
28678 {
28679 let to_remove = ["revisionId", "fileId"];
28680 params.remove_params(&to_remove);
28681 }
28682
28683 let url = params.parse_with_url(&url);
28684
28685 loop {
28686 let token = match self
28687 .hub
28688 .auth
28689 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28690 .await
28691 {
28692 Ok(token) => token,
28693 Err(e) => match dlg.token(e) {
28694 Ok(token) => token,
28695 Err(e) => {
28696 dlg.finished(false);
28697 return Err(common::Error::MissingToken(e));
28698 }
28699 },
28700 };
28701 let mut req_result = {
28702 let client = &self.hub.client;
28703 dlg.pre_request();
28704 let mut req_builder = hyper::Request::builder()
28705 .method(hyper::Method::DELETE)
28706 .uri(url.as_str())
28707 .header(USER_AGENT, self.hub._user_agent.clone());
28708
28709 if let Some(token) = token.as_ref() {
28710 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28711 }
28712
28713 let request = req_builder
28714 .header(CONTENT_LENGTH, 0_u64)
28715 .body(common::to_body::<String>(None));
28716
28717 client.request(request.unwrap()).await
28718 };
28719
28720 match req_result {
28721 Err(err) => {
28722 if let common::Retry::After(d) = dlg.http_error(&err) {
28723 sleep(d).await;
28724 continue;
28725 }
28726 dlg.finished(false);
28727 return Err(common::Error::HttpError(err));
28728 }
28729 Ok(res) => {
28730 let (mut parts, body) = res.into_parts();
28731 let mut body = common::Body::new(body);
28732 if !parts.status.is_success() {
28733 let bytes = common::to_bytes(body).await.unwrap_or_default();
28734 let error = serde_json::from_str(&common::to_string(&bytes));
28735 let response = common::to_response(parts, bytes.into());
28736
28737 if let common::Retry::After(d) =
28738 dlg.http_failure(&response, error.as_ref().ok())
28739 {
28740 sleep(d).await;
28741 continue;
28742 }
28743
28744 dlg.finished(false);
28745
28746 return Err(match error {
28747 Ok(value) => common::Error::BadRequest(value),
28748 _ => common::Error::Failure(response),
28749 });
28750 }
28751 let response = common::Response::from_parts(parts, body);
28752
28753 dlg.finished(true);
28754 return Ok(response);
28755 }
28756 }
28757 }
28758 }
28759
28760 /// The ID of the file.
28761 ///
28762 /// Sets the *file id* path property to the given value.
28763 ///
28764 /// Even though the property as already been set when instantiating this call,
28765 /// we provide this method for API completeness.
28766 pub fn file_id(mut self, new_value: &str) -> RevisionDeleteCall<'a, C> {
28767 self._file_id = new_value.to_string();
28768 self
28769 }
28770 /// The ID of the revision.
28771 ///
28772 /// Sets the *revision id* path property to the given value.
28773 ///
28774 /// Even though the property as already been set when instantiating this call,
28775 /// we provide this method for API completeness.
28776 pub fn revision_id(mut self, new_value: &str) -> RevisionDeleteCall<'a, C> {
28777 self._revision_id = new_value.to_string();
28778 self
28779 }
28780 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28781 /// while executing the actual API request.
28782 ///
28783 /// ````text
28784 /// It should be used to handle progress information, and to implement a certain level of resilience.
28785 /// ````
28786 ///
28787 /// Sets the *delegate* property to the given value.
28788 pub fn delegate(
28789 mut self,
28790 new_value: &'a mut dyn common::Delegate,
28791 ) -> RevisionDeleteCall<'a, C> {
28792 self._delegate = Some(new_value);
28793 self
28794 }
28795
28796 /// Set any additional parameter of the query string used in the request.
28797 /// It should be used to set parameters which are not yet available through their own
28798 /// setters.
28799 ///
28800 /// Please note that this method must not be used to set any of the known parameters
28801 /// which have their own setter method. If done anyway, the request will fail.
28802 ///
28803 /// # Additional Parameters
28804 ///
28805 /// * *$.xgafv* (query-string) - V1 error format.
28806 /// * *access_token* (query-string) - OAuth access token.
28807 /// * *alt* (query-string) - Data format for response.
28808 /// * *callback* (query-string) - JSONP
28809 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28810 /// * *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.
28811 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28812 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28813 /// * *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.
28814 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28815 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28816 pub fn param<T>(mut self, name: T, value: T) -> RevisionDeleteCall<'a, C>
28817 where
28818 T: AsRef<str>,
28819 {
28820 self._additional_params
28821 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28822 self
28823 }
28824
28825 /// Identifies the authorization scope for the method you are building.
28826 ///
28827 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28828 /// [`Scope::Full`].
28829 ///
28830 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28831 /// tokens for more than one scope.
28832 ///
28833 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28834 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28835 /// sufficient, a read-write scope will do as well.
28836 pub fn add_scope<St>(mut self, scope: St) -> RevisionDeleteCall<'a, C>
28837 where
28838 St: AsRef<str>,
28839 {
28840 self._scopes.insert(String::from(scope.as_ref()));
28841 self
28842 }
28843 /// Identifies the authorization scope(s) for the method you are building.
28844 ///
28845 /// See [`Self::add_scope()`] for details.
28846 pub fn add_scopes<I, St>(mut self, scopes: I) -> RevisionDeleteCall<'a, C>
28847 where
28848 I: IntoIterator<Item = St>,
28849 St: AsRef<str>,
28850 {
28851 self._scopes
28852 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28853 self
28854 }
28855
28856 /// Removes all scopes, and no default scope will be used either.
28857 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28858 /// for details).
28859 pub fn clear_scopes(mut self) -> RevisionDeleteCall<'a, C> {
28860 self._scopes.clear();
28861 self
28862 }
28863}
28864
28865/// Gets a specific revision.
28866///
28867/// A builder for the *get* method supported by a *revision* resource.
28868/// It is not used directly, but through a [`RevisionMethods`] instance.
28869///
28870/// # Example
28871///
28872/// Instantiate a resource method builder
28873///
28874/// ```test_harness,no_run
28875/// # extern crate hyper;
28876/// # extern crate hyper_rustls;
28877/// # extern crate google_drive2 as drive2;
28878/// # async fn dox() {
28879/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28880///
28881/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28882/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28883/// # .with_native_roots()
28884/// # .unwrap()
28885/// # .https_only()
28886/// # .enable_http2()
28887/// # .build();
28888///
28889/// # let executor = hyper_util::rt::TokioExecutor::new();
28890/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28891/// # secret,
28892/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28893/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28894/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28895/// # ),
28896/// # ).build().await.unwrap();
28897///
28898/// # let client = hyper_util::client::legacy::Client::builder(
28899/// # hyper_util::rt::TokioExecutor::new()
28900/// # )
28901/// # .build(
28902/// # hyper_rustls::HttpsConnectorBuilder::new()
28903/// # .with_native_roots()
28904/// # .unwrap()
28905/// # .https_or_http()
28906/// # .enable_http2()
28907/// # .build()
28908/// # );
28909/// # let mut hub = DriveHub::new(client, auth);
28910/// // You can configure optional parameters by calling the respective setters at will, and
28911/// // execute the final call using `doit()`.
28912/// // Values shown here are possibly random and not representative !
28913/// let result = hub.revisions().get("fileId", "revisionId")
28914/// .doit().await;
28915/// # }
28916/// ```
28917pub struct RevisionGetCall<'a, C>
28918where
28919 C: 'a,
28920{
28921 hub: &'a DriveHub<C>,
28922 _file_id: String,
28923 _revision_id: String,
28924 _delegate: Option<&'a mut dyn common::Delegate>,
28925 _additional_params: HashMap<String, String>,
28926 _scopes: BTreeSet<String>,
28927}
28928
28929impl<'a, C> common::CallBuilder for RevisionGetCall<'a, C> {}
28930
28931impl<'a, C> RevisionGetCall<'a, C>
28932where
28933 C: common::Connector,
28934{
28935 /// Perform the operation you have build so far.
28936 pub async fn doit(mut self) -> common::Result<(common::Response, Revision)> {
28937 use std::borrow::Cow;
28938 use std::io::{Read, Seek};
28939
28940 use common::{url::Params, ToParts};
28941 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28942
28943 let mut dd = common::DefaultDelegate;
28944 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28945 dlg.begin(common::MethodInfo {
28946 id: "drive.revisions.get",
28947 http_method: hyper::Method::GET,
28948 });
28949
28950 for &field in ["alt", "fileId", "revisionId"].iter() {
28951 if self._additional_params.contains_key(field) {
28952 dlg.finished(false);
28953 return Err(common::Error::FieldClash(field));
28954 }
28955 }
28956
28957 let mut params = Params::with_capacity(4 + self._additional_params.len());
28958 params.push("fileId", self._file_id);
28959 params.push("revisionId", self._revision_id);
28960
28961 params.extend(self._additional_params.iter());
28962
28963 params.push("alt", "json");
28964 let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}";
28965 if self._scopes.is_empty() {
28966 self._scopes
28967 .insert(Scope::MeetReadonly.as_ref().to_string());
28968 }
28969
28970 #[allow(clippy::single_element_loop)]
28971 for &(find_this, param_name) in
28972 [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter()
28973 {
28974 url = params.uri_replacement(url, param_name, find_this, false);
28975 }
28976 {
28977 let to_remove = ["revisionId", "fileId"];
28978 params.remove_params(&to_remove);
28979 }
28980
28981 let url = params.parse_with_url(&url);
28982
28983 loop {
28984 let token = match self
28985 .hub
28986 .auth
28987 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28988 .await
28989 {
28990 Ok(token) => token,
28991 Err(e) => match dlg.token(e) {
28992 Ok(token) => token,
28993 Err(e) => {
28994 dlg.finished(false);
28995 return Err(common::Error::MissingToken(e));
28996 }
28997 },
28998 };
28999 let mut req_result = {
29000 let client = &self.hub.client;
29001 dlg.pre_request();
29002 let mut req_builder = hyper::Request::builder()
29003 .method(hyper::Method::GET)
29004 .uri(url.as_str())
29005 .header(USER_AGENT, self.hub._user_agent.clone());
29006
29007 if let Some(token) = token.as_ref() {
29008 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29009 }
29010
29011 let request = req_builder
29012 .header(CONTENT_LENGTH, 0_u64)
29013 .body(common::to_body::<String>(None));
29014
29015 client.request(request.unwrap()).await
29016 };
29017
29018 match req_result {
29019 Err(err) => {
29020 if let common::Retry::After(d) = dlg.http_error(&err) {
29021 sleep(d).await;
29022 continue;
29023 }
29024 dlg.finished(false);
29025 return Err(common::Error::HttpError(err));
29026 }
29027 Ok(res) => {
29028 let (mut parts, body) = res.into_parts();
29029 let mut body = common::Body::new(body);
29030 if !parts.status.is_success() {
29031 let bytes = common::to_bytes(body).await.unwrap_or_default();
29032 let error = serde_json::from_str(&common::to_string(&bytes));
29033 let response = common::to_response(parts, bytes.into());
29034
29035 if let common::Retry::After(d) =
29036 dlg.http_failure(&response, error.as_ref().ok())
29037 {
29038 sleep(d).await;
29039 continue;
29040 }
29041
29042 dlg.finished(false);
29043
29044 return Err(match error {
29045 Ok(value) => common::Error::BadRequest(value),
29046 _ => common::Error::Failure(response),
29047 });
29048 }
29049 let response = {
29050 let bytes = common::to_bytes(body).await.unwrap_or_default();
29051 let encoded = common::to_string(&bytes);
29052 match serde_json::from_str(&encoded) {
29053 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29054 Err(error) => {
29055 dlg.response_json_decode_error(&encoded, &error);
29056 return Err(common::Error::JsonDecodeError(
29057 encoded.to_string(),
29058 error,
29059 ));
29060 }
29061 }
29062 };
29063
29064 dlg.finished(true);
29065 return Ok(response);
29066 }
29067 }
29068 }
29069 }
29070
29071 /// The ID of the file.
29072 ///
29073 /// Sets the *file id* path property to the given value.
29074 ///
29075 /// Even though the property as already been set when instantiating this call,
29076 /// we provide this method for API completeness.
29077 pub fn file_id(mut self, new_value: &str) -> RevisionGetCall<'a, C> {
29078 self._file_id = new_value.to_string();
29079 self
29080 }
29081 /// The ID of the revision.
29082 ///
29083 /// Sets the *revision id* path property to the given value.
29084 ///
29085 /// Even though the property as already been set when instantiating this call,
29086 /// we provide this method for API completeness.
29087 pub fn revision_id(mut self, new_value: &str) -> RevisionGetCall<'a, C> {
29088 self._revision_id = new_value.to_string();
29089 self
29090 }
29091 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29092 /// while executing the actual API request.
29093 ///
29094 /// ````text
29095 /// It should be used to handle progress information, and to implement a certain level of resilience.
29096 /// ````
29097 ///
29098 /// Sets the *delegate* property to the given value.
29099 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> RevisionGetCall<'a, C> {
29100 self._delegate = Some(new_value);
29101 self
29102 }
29103
29104 /// Set any additional parameter of the query string used in the request.
29105 /// It should be used to set parameters which are not yet available through their own
29106 /// setters.
29107 ///
29108 /// Please note that this method must not be used to set any of the known parameters
29109 /// which have their own setter method. If done anyway, the request will fail.
29110 ///
29111 /// # Additional Parameters
29112 ///
29113 /// * *$.xgafv* (query-string) - V1 error format.
29114 /// * *access_token* (query-string) - OAuth access token.
29115 /// * *alt* (query-string) - Data format for response.
29116 /// * *callback* (query-string) - JSONP
29117 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29118 /// * *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.
29119 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29120 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29121 /// * *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.
29122 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29123 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29124 pub fn param<T>(mut self, name: T, value: T) -> RevisionGetCall<'a, C>
29125 where
29126 T: AsRef<str>,
29127 {
29128 self._additional_params
29129 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29130 self
29131 }
29132
29133 /// Identifies the authorization scope for the method you are building.
29134 ///
29135 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29136 /// [`Scope::MeetReadonly`].
29137 ///
29138 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29139 /// tokens for more than one scope.
29140 ///
29141 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29142 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29143 /// sufficient, a read-write scope will do as well.
29144 pub fn add_scope<St>(mut self, scope: St) -> RevisionGetCall<'a, C>
29145 where
29146 St: AsRef<str>,
29147 {
29148 self._scopes.insert(String::from(scope.as_ref()));
29149 self
29150 }
29151 /// Identifies the authorization scope(s) for the method you are building.
29152 ///
29153 /// See [`Self::add_scope()`] for details.
29154 pub fn add_scopes<I, St>(mut self, scopes: I) -> RevisionGetCall<'a, C>
29155 where
29156 I: IntoIterator<Item = St>,
29157 St: AsRef<str>,
29158 {
29159 self._scopes
29160 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29161 self
29162 }
29163
29164 /// Removes all scopes, and no default scope will be used either.
29165 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29166 /// for details).
29167 pub fn clear_scopes(mut self) -> RevisionGetCall<'a, C> {
29168 self._scopes.clear();
29169 self
29170 }
29171}
29172
29173/// Lists a file's revisions. **Important:** The list of revisions returned by this method might be incomplete for files with a large revision history, including frequently edited Google Docs, Sheets, and Slides. Older revisions might be omitted from the response, meaning the first revision returned may not be the oldest existing revision. The revision history visible in the Workspace editor user interface might be more complete than the list returned by the API.
29174///
29175/// A builder for the *list* method supported by a *revision* resource.
29176/// It is not used directly, but through a [`RevisionMethods`] instance.
29177///
29178/// # Example
29179///
29180/// Instantiate a resource method builder
29181///
29182/// ```test_harness,no_run
29183/// # extern crate hyper;
29184/// # extern crate hyper_rustls;
29185/// # extern crate google_drive2 as drive2;
29186/// # async fn dox() {
29187/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29188///
29189/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29190/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29191/// # .with_native_roots()
29192/// # .unwrap()
29193/// # .https_only()
29194/// # .enable_http2()
29195/// # .build();
29196///
29197/// # let executor = hyper_util::rt::TokioExecutor::new();
29198/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29199/// # secret,
29200/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29201/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29202/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29203/// # ),
29204/// # ).build().await.unwrap();
29205///
29206/// # let client = hyper_util::client::legacy::Client::builder(
29207/// # hyper_util::rt::TokioExecutor::new()
29208/// # )
29209/// # .build(
29210/// # hyper_rustls::HttpsConnectorBuilder::new()
29211/// # .with_native_roots()
29212/// # .unwrap()
29213/// # .https_or_http()
29214/// # .enable_http2()
29215/// # .build()
29216/// # );
29217/// # let mut hub = DriveHub::new(client, auth);
29218/// // You can configure optional parameters by calling the respective setters at will, and
29219/// // execute the final call using `doit()`.
29220/// // Values shown here are possibly random and not representative !
29221/// let result = hub.revisions().list("fileId")
29222/// .page_token("dolor")
29223/// .max_results(-22)
29224/// .doit().await;
29225/// # }
29226/// ```
29227pub struct RevisionListCall<'a, C>
29228where
29229 C: 'a,
29230{
29231 hub: &'a DriveHub<C>,
29232 _file_id: String,
29233 _page_token: Option<String>,
29234 _max_results: Option<i32>,
29235 _delegate: Option<&'a mut dyn common::Delegate>,
29236 _additional_params: HashMap<String, String>,
29237 _scopes: BTreeSet<String>,
29238}
29239
29240impl<'a, C> common::CallBuilder for RevisionListCall<'a, C> {}
29241
29242impl<'a, C> RevisionListCall<'a, C>
29243where
29244 C: common::Connector,
29245{
29246 /// Perform the operation you have build so far.
29247 pub async fn doit(mut self) -> common::Result<(common::Response, RevisionList)> {
29248 use std::borrow::Cow;
29249 use std::io::{Read, Seek};
29250
29251 use common::{url::Params, ToParts};
29252 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29253
29254 let mut dd = common::DefaultDelegate;
29255 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29256 dlg.begin(common::MethodInfo {
29257 id: "drive.revisions.list",
29258 http_method: hyper::Method::GET,
29259 });
29260
29261 for &field in ["alt", "fileId", "pageToken", "maxResults"].iter() {
29262 if self._additional_params.contains_key(field) {
29263 dlg.finished(false);
29264 return Err(common::Error::FieldClash(field));
29265 }
29266 }
29267
29268 let mut params = Params::with_capacity(5 + self._additional_params.len());
29269 params.push("fileId", self._file_id);
29270 if let Some(value) = self._page_token.as_ref() {
29271 params.push("pageToken", value);
29272 }
29273 if let Some(value) = self._max_results.as_ref() {
29274 params.push("maxResults", value.to_string());
29275 }
29276
29277 params.extend(self._additional_params.iter());
29278
29279 params.push("alt", "json");
29280 let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions";
29281 if self._scopes.is_empty() {
29282 self._scopes
29283 .insert(Scope::MeetReadonly.as_ref().to_string());
29284 }
29285
29286 #[allow(clippy::single_element_loop)]
29287 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
29288 url = params.uri_replacement(url, param_name, find_this, false);
29289 }
29290 {
29291 let to_remove = ["fileId"];
29292 params.remove_params(&to_remove);
29293 }
29294
29295 let url = params.parse_with_url(&url);
29296
29297 loop {
29298 let token = match self
29299 .hub
29300 .auth
29301 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29302 .await
29303 {
29304 Ok(token) => token,
29305 Err(e) => match dlg.token(e) {
29306 Ok(token) => token,
29307 Err(e) => {
29308 dlg.finished(false);
29309 return Err(common::Error::MissingToken(e));
29310 }
29311 },
29312 };
29313 let mut req_result = {
29314 let client = &self.hub.client;
29315 dlg.pre_request();
29316 let mut req_builder = hyper::Request::builder()
29317 .method(hyper::Method::GET)
29318 .uri(url.as_str())
29319 .header(USER_AGENT, self.hub._user_agent.clone());
29320
29321 if let Some(token) = token.as_ref() {
29322 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29323 }
29324
29325 let request = req_builder
29326 .header(CONTENT_LENGTH, 0_u64)
29327 .body(common::to_body::<String>(None));
29328
29329 client.request(request.unwrap()).await
29330 };
29331
29332 match req_result {
29333 Err(err) => {
29334 if let common::Retry::After(d) = dlg.http_error(&err) {
29335 sleep(d).await;
29336 continue;
29337 }
29338 dlg.finished(false);
29339 return Err(common::Error::HttpError(err));
29340 }
29341 Ok(res) => {
29342 let (mut parts, body) = res.into_parts();
29343 let mut body = common::Body::new(body);
29344 if !parts.status.is_success() {
29345 let bytes = common::to_bytes(body).await.unwrap_or_default();
29346 let error = serde_json::from_str(&common::to_string(&bytes));
29347 let response = common::to_response(parts, bytes.into());
29348
29349 if let common::Retry::After(d) =
29350 dlg.http_failure(&response, error.as_ref().ok())
29351 {
29352 sleep(d).await;
29353 continue;
29354 }
29355
29356 dlg.finished(false);
29357
29358 return Err(match error {
29359 Ok(value) => common::Error::BadRequest(value),
29360 _ => common::Error::Failure(response),
29361 });
29362 }
29363 let response = {
29364 let bytes = common::to_bytes(body).await.unwrap_or_default();
29365 let encoded = common::to_string(&bytes);
29366 match serde_json::from_str(&encoded) {
29367 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29368 Err(error) => {
29369 dlg.response_json_decode_error(&encoded, &error);
29370 return Err(common::Error::JsonDecodeError(
29371 encoded.to_string(),
29372 error,
29373 ));
29374 }
29375 }
29376 };
29377
29378 dlg.finished(true);
29379 return Ok(response);
29380 }
29381 }
29382 }
29383 }
29384
29385 /// The ID of the file.
29386 ///
29387 /// Sets the *file id* path property to the given value.
29388 ///
29389 /// Even though the property as already been set when instantiating this call,
29390 /// we provide this method for API completeness.
29391 pub fn file_id(mut self, new_value: &str) -> RevisionListCall<'a, C> {
29392 self._file_id = new_value.to_string();
29393 self
29394 }
29395 /// Page token for revisions. To get the next page of results, set this parameter to the value of "nextPageToken" from the previous response.
29396 ///
29397 /// Sets the *page token* query property to the given value.
29398 pub fn page_token(mut self, new_value: &str) -> RevisionListCall<'a, C> {
29399 self._page_token = Some(new_value.to_string());
29400 self
29401 }
29402 /// Maximum number of revisions to return.
29403 ///
29404 /// Sets the *max results* query property to the given value.
29405 pub fn max_results(mut self, new_value: i32) -> RevisionListCall<'a, C> {
29406 self._max_results = Some(new_value);
29407 self
29408 }
29409 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29410 /// while executing the actual API request.
29411 ///
29412 /// ````text
29413 /// It should be used to handle progress information, and to implement a certain level of resilience.
29414 /// ````
29415 ///
29416 /// Sets the *delegate* property to the given value.
29417 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> RevisionListCall<'a, C> {
29418 self._delegate = Some(new_value);
29419 self
29420 }
29421
29422 /// Set any additional parameter of the query string used in the request.
29423 /// It should be used to set parameters which are not yet available through their own
29424 /// setters.
29425 ///
29426 /// Please note that this method must not be used to set any of the known parameters
29427 /// which have their own setter method. If done anyway, the request will fail.
29428 ///
29429 /// # Additional Parameters
29430 ///
29431 /// * *$.xgafv* (query-string) - V1 error format.
29432 /// * *access_token* (query-string) - OAuth access token.
29433 /// * *alt* (query-string) - Data format for response.
29434 /// * *callback* (query-string) - JSONP
29435 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29436 /// * *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.
29437 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29438 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29439 /// * *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.
29440 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29441 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29442 pub fn param<T>(mut self, name: T, value: T) -> RevisionListCall<'a, C>
29443 where
29444 T: AsRef<str>,
29445 {
29446 self._additional_params
29447 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29448 self
29449 }
29450
29451 /// Identifies the authorization scope for the method you are building.
29452 ///
29453 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29454 /// [`Scope::MeetReadonly`].
29455 ///
29456 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29457 /// tokens for more than one scope.
29458 ///
29459 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29460 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29461 /// sufficient, a read-write scope will do as well.
29462 pub fn add_scope<St>(mut self, scope: St) -> RevisionListCall<'a, C>
29463 where
29464 St: AsRef<str>,
29465 {
29466 self._scopes.insert(String::from(scope.as_ref()));
29467 self
29468 }
29469 /// Identifies the authorization scope(s) for the method you are building.
29470 ///
29471 /// See [`Self::add_scope()`] for details.
29472 pub fn add_scopes<I, St>(mut self, scopes: I) -> RevisionListCall<'a, C>
29473 where
29474 I: IntoIterator<Item = St>,
29475 St: AsRef<str>,
29476 {
29477 self._scopes
29478 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29479 self
29480 }
29481
29482 /// Removes all scopes, and no default scope will be used either.
29483 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29484 /// for details).
29485 pub fn clear_scopes(mut self) -> RevisionListCall<'a, C> {
29486 self._scopes.clear();
29487 self
29488 }
29489}
29490
29491/// Updates a revision.
29492///
29493/// A builder for the *patch* method supported by a *revision* resource.
29494/// It is not used directly, but through a [`RevisionMethods`] instance.
29495///
29496/// # Example
29497///
29498/// Instantiate a resource method builder
29499///
29500/// ```test_harness,no_run
29501/// # extern crate hyper;
29502/// # extern crate hyper_rustls;
29503/// # extern crate google_drive2 as drive2;
29504/// use drive2::api::Revision;
29505/// # async fn dox() {
29506/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29507///
29508/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29509/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29510/// # .with_native_roots()
29511/// # .unwrap()
29512/// # .https_only()
29513/// # .enable_http2()
29514/// # .build();
29515///
29516/// # let executor = hyper_util::rt::TokioExecutor::new();
29517/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29518/// # secret,
29519/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29520/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29521/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29522/// # ),
29523/// # ).build().await.unwrap();
29524///
29525/// # let client = hyper_util::client::legacy::Client::builder(
29526/// # hyper_util::rt::TokioExecutor::new()
29527/// # )
29528/// # .build(
29529/// # hyper_rustls::HttpsConnectorBuilder::new()
29530/// # .with_native_roots()
29531/// # .unwrap()
29532/// # .https_or_http()
29533/// # .enable_http2()
29534/// # .build()
29535/// # );
29536/// # let mut hub = DriveHub::new(client, auth);
29537/// // As the method needs a request, you would usually fill it with the desired information
29538/// // into the respective structure. Some of the parts shown here might not be applicable !
29539/// // Values shown here are possibly random and not representative !
29540/// let mut req = Revision::default();
29541///
29542/// // You can configure optional parameters by calling the respective setters at will, and
29543/// // execute the final call using `doit()`.
29544/// // Values shown here are possibly random and not representative !
29545/// let result = hub.revisions().patch(req, "fileId", "revisionId")
29546/// .doit().await;
29547/// # }
29548/// ```
29549pub struct RevisionPatchCall<'a, C>
29550where
29551 C: 'a,
29552{
29553 hub: &'a DriveHub<C>,
29554 _request: Revision,
29555 _file_id: String,
29556 _revision_id: String,
29557 _delegate: Option<&'a mut dyn common::Delegate>,
29558 _additional_params: HashMap<String, String>,
29559 _scopes: BTreeSet<String>,
29560}
29561
29562impl<'a, C> common::CallBuilder for RevisionPatchCall<'a, C> {}
29563
29564impl<'a, C> RevisionPatchCall<'a, C>
29565where
29566 C: common::Connector,
29567{
29568 /// Perform the operation you have build so far.
29569 pub async fn doit(mut self) -> common::Result<(common::Response, Revision)> {
29570 use std::borrow::Cow;
29571 use std::io::{Read, Seek};
29572
29573 use common::{url::Params, ToParts};
29574 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29575
29576 let mut dd = common::DefaultDelegate;
29577 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29578 dlg.begin(common::MethodInfo {
29579 id: "drive.revisions.patch",
29580 http_method: hyper::Method::PATCH,
29581 });
29582
29583 for &field in ["alt", "fileId", "revisionId"].iter() {
29584 if self._additional_params.contains_key(field) {
29585 dlg.finished(false);
29586 return Err(common::Error::FieldClash(field));
29587 }
29588 }
29589
29590 let mut params = Params::with_capacity(5 + self._additional_params.len());
29591 params.push("fileId", self._file_id);
29592 params.push("revisionId", self._revision_id);
29593
29594 params.extend(self._additional_params.iter());
29595
29596 params.push("alt", "json");
29597 let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}";
29598 if self._scopes.is_empty() {
29599 self._scopes.insert(Scope::Full.as_ref().to_string());
29600 }
29601
29602 #[allow(clippy::single_element_loop)]
29603 for &(find_this, param_name) in
29604 [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter()
29605 {
29606 url = params.uri_replacement(url, param_name, find_this, false);
29607 }
29608 {
29609 let to_remove = ["revisionId", "fileId"];
29610 params.remove_params(&to_remove);
29611 }
29612
29613 let url = params.parse_with_url(&url);
29614
29615 let mut json_mime_type = mime::APPLICATION_JSON;
29616 let mut request_value_reader = {
29617 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29618 common::remove_json_null_values(&mut value);
29619 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29620 serde_json::to_writer(&mut dst, &value).unwrap();
29621 dst
29622 };
29623 let request_size = request_value_reader
29624 .seek(std::io::SeekFrom::End(0))
29625 .unwrap();
29626 request_value_reader
29627 .seek(std::io::SeekFrom::Start(0))
29628 .unwrap();
29629
29630 loop {
29631 let token = match self
29632 .hub
29633 .auth
29634 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29635 .await
29636 {
29637 Ok(token) => token,
29638 Err(e) => match dlg.token(e) {
29639 Ok(token) => token,
29640 Err(e) => {
29641 dlg.finished(false);
29642 return Err(common::Error::MissingToken(e));
29643 }
29644 },
29645 };
29646 request_value_reader
29647 .seek(std::io::SeekFrom::Start(0))
29648 .unwrap();
29649 let mut req_result = {
29650 let client = &self.hub.client;
29651 dlg.pre_request();
29652 let mut req_builder = hyper::Request::builder()
29653 .method(hyper::Method::PATCH)
29654 .uri(url.as_str())
29655 .header(USER_AGENT, self.hub._user_agent.clone());
29656
29657 if let Some(token) = token.as_ref() {
29658 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29659 }
29660
29661 let request = req_builder
29662 .header(CONTENT_TYPE, json_mime_type.to_string())
29663 .header(CONTENT_LENGTH, request_size as u64)
29664 .body(common::to_body(
29665 request_value_reader.get_ref().clone().into(),
29666 ));
29667
29668 client.request(request.unwrap()).await
29669 };
29670
29671 match req_result {
29672 Err(err) => {
29673 if let common::Retry::After(d) = dlg.http_error(&err) {
29674 sleep(d).await;
29675 continue;
29676 }
29677 dlg.finished(false);
29678 return Err(common::Error::HttpError(err));
29679 }
29680 Ok(res) => {
29681 let (mut parts, body) = res.into_parts();
29682 let mut body = common::Body::new(body);
29683 if !parts.status.is_success() {
29684 let bytes = common::to_bytes(body).await.unwrap_or_default();
29685 let error = serde_json::from_str(&common::to_string(&bytes));
29686 let response = common::to_response(parts, bytes.into());
29687
29688 if let common::Retry::After(d) =
29689 dlg.http_failure(&response, error.as_ref().ok())
29690 {
29691 sleep(d).await;
29692 continue;
29693 }
29694
29695 dlg.finished(false);
29696
29697 return Err(match error {
29698 Ok(value) => common::Error::BadRequest(value),
29699 _ => common::Error::Failure(response),
29700 });
29701 }
29702 let response = {
29703 let bytes = common::to_bytes(body).await.unwrap_or_default();
29704 let encoded = common::to_string(&bytes);
29705 match serde_json::from_str(&encoded) {
29706 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29707 Err(error) => {
29708 dlg.response_json_decode_error(&encoded, &error);
29709 return Err(common::Error::JsonDecodeError(
29710 encoded.to_string(),
29711 error,
29712 ));
29713 }
29714 }
29715 };
29716
29717 dlg.finished(true);
29718 return Ok(response);
29719 }
29720 }
29721 }
29722 }
29723
29724 ///
29725 /// Sets the *request* property to the given value.
29726 ///
29727 /// Even though the property as already been set when instantiating this call,
29728 /// we provide this method for API completeness.
29729 pub fn request(mut self, new_value: Revision) -> RevisionPatchCall<'a, C> {
29730 self._request = new_value;
29731 self
29732 }
29733 /// The ID for the file.
29734 ///
29735 /// Sets the *file id* path property to the given value.
29736 ///
29737 /// Even though the property as already been set when instantiating this call,
29738 /// we provide this method for API completeness.
29739 pub fn file_id(mut self, new_value: &str) -> RevisionPatchCall<'a, C> {
29740 self._file_id = new_value.to_string();
29741 self
29742 }
29743 /// The ID for the revision.
29744 ///
29745 /// Sets the *revision id* path property to the given value.
29746 ///
29747 /// Even though the property as already been set when instantiating this call,
29748 /// we provide this method for API completeness.
29749 pub fn revision_id(mut self, new_value: &str) -> RevisionPatchCall<'a, C> {
29750 self._revision_id = new_value.to_string();
29751 self
29752 }
29753 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29754 /// while executing the actual API request.
29755 ///
29756 /// ````text
29757 /// It should be used to handle progress information, and to implement a certain level of resilience.
29758 /// ````
29759 ///
29760 /// Sets the *delegate* property to the given value.
29761 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> RevisionPatchCall<'a, C> {
29762 self._delegate = Some(new_value);
29763 self
29764 }
29765
29766 /// Set any additional parameter of the query string used in the request.
29767 /// It should be used to set parameters which are not yet available through their own
29768 /// setters.
29769 ///
29770 /// Please note that this method must not be used to set any of the known parameters
29771 /// which have their own setter method. If done anyway, the request will fail.
29772 ///
29773 /// # Additional Parameters
29774 ///
29775 /// * *$.xgafv* (query-string) - V1 error format.
29776 /// * *access_token* (query-string) - OAuth access token.
29777 /// * *alt* (query-string) - Data format for response.
29778 /// * *callback* (query-string) - JSONP
29779 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29780 /// * *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.
29781 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29782 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29783 /// * *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.
29784 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29785 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29786 pub fn param<T>(mut self, name: T, value: T) -> RevisionPatchCall<'a, C>
29787 where
29788 T: AsRef<str>,
29789 {
29790 self._additional_params
29791 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29792 self
29793 }
29794
29795 /// Identifies the authorization scope for the method you are building.
29796 ///
29797 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29798 /// [`Scope::Full`].
29799 ///
29800 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29801 /// tokens for more than one scope.
29802 ///
29803 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29804 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29805 /// sufficient, a read-write scope will do as well.
29806 pub fn add_scope<St>(mut self, scope: St) -> RevisionPatchCall<'a, C>
29807 where
29808 St: AsRef<str>,
29809 {
29810 self._scopes.insert(String::from(scope.as_ref()));
29811 self
29812 }
29813 /// Identifies the authorization scope(s) for the method you are building.
29814 ///
29815 /// See [`Self::add_scope()`] for details.
29816 pub fn add_scopes<I, St>(mut self, scopes: I) -> RevisionPatchCall<'a, C>
29817 where
29818 I: IntoIterator<Item = St>,
29819 St: AsRef<str>,
29820 {
29821 self._scopes
29822 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29823 self
29824 }
29825
29826 /// Removes all scopes, and no default scope will be used either.
29827 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29828 /// for details).
29829 pub fn clear_scopes(mut self) -> RevisionPatchCall<'a, C> {
29830 self._scopes.clear();
29831 self
29832 }
29833}
29834
29835/// Updates a revision.
29836///
29837/// A builder for the *update* method supported by a *revision* resource.
29838/// It is not used directly, but through a [`RevisionMethods`] instance.
29839///
29840/// # Example
29841///
29842/// Instantiate a resource method builder
29843///
29844/// ```test_harness,no_run
29845/// # extern crate hyper;
29846/// # extern crate hyper_rustls;
29847/// # extern crate google_drive2 as drive2;
29848/// use drive2::api::Revision;
29849/// # async fn dox() {
29850/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29851///
29852/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29853/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29854/// # .with_native_roots()
29855/// # .unwrap()
29856/// # .https_only()
29857/// # .enable_http2()
29858/// # .build();
29859///
29860/// # let executor = hyper_util::rt::TokioExecutor::new();
29861/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29862/// # secret,
29863/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29864/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29865/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29866/// # ),
29867/// # ).build().await.unwrap();
29868///
29869/// # let client = hyper_util::client::legacy::Client::builder(
29870/// # hyper_util::rt::TokioExecutor::new()
29871/// # )
29872/// # .build(
29873/// # hyper_rustls::HttpsConnectorBuilder::new()
29874/// # .with_native_roots()
29875/// # .unwrap()
29876/// # .https_or_http()
29877/// # .enable_http2()
29878/// # .build()
29879/// # );
29880/// # let mut hub = DriveHub::new(client, auth);
29881/// // As the method needs a request, you would usually fill it with the desired information
29882/// // into the respective structure. Some of the parts shown here might not be applicable !
29883/// // Values shown here are possibly random and not representative !
29884/// let mut req = Revision::default();
29885///
29886/// // You can configure optional parameters by calling the respective setters at will, and
29887/// // execute the final call using `doit()`.
29888/// // Values shown here are possibly random and not representative !
29889/// let result = hub.revisions().update(req, "fileId", "revisionId")
29890/// .doit().await;
29891/// # }
29892/// ```
29893pub struct RevisionUpdateCall<'a, C>
29894where
29895 C: 'a,
29896{
29897 hub: &'a DriveHub<C>,
29898 _request: Revision,
29899 _file_id: String,
29900 _revision_id: String,
29901 _delegate: Option<&'a mut dyn common::Delegate>,
29902 _additional_params: HashMap<String, String>,
29903 _scopes: BTreeSet<String>,
29904}
29905
29906impl<'a, C> common::CallBuilder for RevisionUpdateCall<'a, C> {}
29907
29908impl<'a, C> RevisionUpdateCall<'a, C>
29909where
29910 C: common::Connector,
29911{
29912 /// Perform the operation you have build so far.
29913 pub async fn doit(mut self) -> common::Result<(common::Response, Revision)> {
29914 use std::borrow::Cow;
29915 use std::io::{Read, Seek};
29916
29917 use common::{url::Params, ToParts};
29918 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29919
29920 let mut dd = common::DefaultDelegate;
29921 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29922 dlg.begin(common::MethodInfo {
29923 id: "drive.revisions.update",
29924 http_method: hyper::Method::PUT,
29925 });
29926
29927 for &field in ["alt", "fileId", "revisionId"].iter() {
29928 if self._additional_params.contains_key(field) {
29929 dlg.finished(false);
29930 return Err(common::Error::FieldClash(field));
29931 }
29932 }
29933
29934 let mut params = Params::with_capacity(5 + self._additional_params.len());
29935 params.push("fileId", self._file_id);
29936 params.push("revisionId", self._revision_id);
29937
29938 params.extend(self._additional_params.iter());
29939
29940 params.push("alt", "json");
29941 let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}";
29942 if self._scopes.is_empty() {
29943 self._scopes.insert(Scope::Full.as_ref().to_string());
29944 }
29945
29946 #[allow(clippy::single_element_loop)]
29947 for &(find_this, param_name) in
29948 [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter()
29949 {
29950 url = params.uri_replacement(url, param_name, find_this, false);
29951 }
29952 {
29953 let to_remove = ["revisionId", "fileId"];
29954 params.remove_params(&to_remove);
29955 }
29956
29957 let url = params.parse_with_url(&url);
29958
29959 let mut json_mime_type = mime::APPLICATION_JSON;
29960 let mut request_value_reader = {
29961 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29962 common::remove_json_null_values(&mut value);
29963 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29964 serde_json::to_writer(&mut dst, &value).unwrap();
29965 dst
29966 };
29967 let request_size = request_value_reader
29968 .seek(std::io::SeekFrom::End(0))
29969 .unwrap();
29970 request_value_reader
29971 .seek(std::io::SeekFrom::Start(0))
29972 .unwrap();
29973
29974 loop {
29975 let token = match self
29976 .hub
29977 .auth
29978 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29979 .await
29980 {
29981 Ok(token) => token,
29982 Err(e) => match dlg.token(e) {
29983 Ok(token) => token,
29984 Err(e) => {
29985 dlg.finished(false);
29986 return Err(common::Error::MissingToken(e));
29987 }
29988 },
29989 };
29990 request_value_reader
29991 .seek(std::io::SeekFrom::Start(0))
29992 .unwrap();
29993 let mut req_result = {
29994 let client = &self.hub.client;
29995 dlg.pre_request();
29996 let mut req_builder = hyper::Request::builder()
29997 .method(hyper::Method::PUT)
29998 .uri(url.as_str())
29999 .header(USER_AGENT, self.hub._user_agent.clone());
30000
30001 if let Some(token) = token.as_ref() {
30002 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30003 }
30004
30005 let request = req_builder
30006 .header(CONTENT_TYPE, json_mime_type.to_string())
30007 .header(CONTENT_LENGTH, request_size as u64)
30008 .body(common::to_body(
30009 request_value_reader.get_ref().clone().into(),
30010 ));
30011
30012 client.request(request.unwrap()).await
30013 };
30014
30015 match req_result {
30016 Err(err) => {
30017 if let common::Retry::After(d) = dlg.http_error(&err) {
30018 sleep(d).await;
30019 continue;
30020 }
30021 dlg.finished(false);
30022 return Err(common::Error::HttpError(err));
30023 }
30024 Ok(res) => {
30025 let (mut parts, body) = res.into_parts();
30026 let mut body = common::Body::new(body);
30027 if !parts.status.is_success() {
30028 let bytes = common::to_bytes(body).await.unwrap_or_default();
30029 let error = serde_json::from_str(&common::to_string(&bytes));
30030 let response = common::to_response(parts, bytes.into());
30031
30032 if let common::Retry::After(d) =
30033 dlg.http_failure(&response, error.as_ref().ok())
30034 {
30035 sleep(d).await;
30036 continue;
30037 }
30038
30039 dlg.finished(false);
30040
30041 return Err(match error {
30042 Ok(value) => common::Error::BadRequest(value),
30043 _ => common::Error::Failure(response),
30044 });
30045 }
30046 let response = {
30047 let bytes = common::to_bytes(body).await.unwrap_or_default();
30048 let encoded = common::to_string(&bytes);
30049 match serde_json::from_str(&encoded) {
30050 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30051 Err(error) => {
30052 dlg.response_json_decode_error(&encoded, &error);
30053 return Err(common::Error::JsonDecodeError(
30054 encoded.to_string(),
30055 error,
30056 ));
30057 }
30058 }
30059 };
30060
30061 dlg.finished(true);
30062 return Ok(response);
30063 }
30064 }
30065 }
30066 }
30067
30068 ///
30069 /// Sets the *request* property to the given value.
30070 ///
30071 /// Even though the property as already been set when instantiating this call,
30072 /// we provide this method for API completeness.
30073 pub fn request(mut self, new_value: Revision) -> RevisionUpdateCall<'a, C> {
30074 self._request = new_value;
30075 self
30076 }
30077 /// The ID for the file.
30078 ///
30079 /// Sets the *file id* path property to the given value.
30080 ///
30081 /// Even though the property as already been set when instantiating this call,
30082 /// we provide this method for API completeness.
30083 pub fn file_id(mut self, new_value: &str) -> RevisionUpdateCall<'a, C> {
30084 self._file_id = new_value.to_string();
30085 self
30086 }
30087 /// The ID for the revision.
30088 ///
30089 /// Sets the *revision id* path property to the given value.
30090 ///
30091 /// Even though the property as already been set when instantiating this call,
30092 /// we provide this method for API completeness.
30093 pub fn revision_id(mut self, new_value: &str) -> RevisionUpdateCall<'a, C> {
30094 self._revision_id = new_value.to_string();
30095 self
30096 }
30097 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30098 /// while executing the actual API request.
30099 ///
30100 /// ````text
30101 /// It should be used to handle progress information, and to implement a certain level of resilience.
30102 /// ````
30103 ///
30104 /// Sets the *delegate* property to the given value.
30105 pub fn delegate(
30106 mut self,
30107 new_value: &'a mut dyn common::Delegate,
30108 ) -> RevisionUpdateCall<'a, C> {
30109 self._delegate = Some(new_value);
30110 self
30111 }
30112
30113 /// Set any additional parameter of the query string used in the request.
30114 /// It should be used to set parameters which are not yet available through their own
30115 /// setters.
30116 ///
30117 /// Please note that this method must not be used to set any of the known parameters
30118 /// which have their own setter method. If done anyway, the request will fail.
30119 ///
30120 /// # Additional Parameters
30121 ///
30122 /// * *$.xgafv* (query-string) - V1 error format.
30123 /// * *access_token* (query-string) - OAuth access token.
30124 /// * *alt* (query-string) - Data format for response.
30125 /// * *callback* (query-string) - JSONP
30126 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30127 /// * *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.
30128 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30129 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30130 /// * *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.
30131 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30132 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30133 pub fn param<T>(mut self, name: T, value: T) -> RevisionUpdateCall<'a, C>
30134 where
30135 T: AsRef<str>,
30136 {
30137 self._additional_params
30138 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30139 self
30140 }
30141
30142 /// Identifies the authorization scope for the method you are building.
30143 ///
30144 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30145 /// [`Scope::Full`].
30146 ///
30147 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30148 /// tokens for more than one scope.
30149 ///
30150 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30151 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30152 /// sufficient, a read-write scope will do as well.
30153 pub fn add_scope<St>(mut self, scope: St) -> RevisionUpdateCall<'a, C>
30154 where
30155 St: AsRef<str>,
30156 {
30157 self._scopes.insert(String::from(scope.as_ref()));
30158 self
30159 }
30160 /// Identifies the authorization scope(s) for the method you are building.
30161 ///
30162 /// See [`Self::add_scope()`] for details.
30163 pub fn add_scopes<I, St>(mut self, scopes: I) -> RevisionUpdateCall<'a, C>
30164 where
30165 I: IntoIterator<Item = St>,
30166 St: AsRef<str>,
30167 {
30168 self._scopes
30169 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30170 self
30171 }
30172
30173 /// Removes all scopes, and no default scope will be used either.
30174 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30175 /// for details).
30176 pub fn clear_scopes(mut self) -> RevisionUpdateCall<'a, C> {
30177 self._scopes.clear();
30178 self
30179 }
30180}
30181
30182/// Deprecated: Use `drives.delete` instead.
30183///
30184/// A builder for the *delete* method supported by a *teamdrive* resource.
30185/// It is not used directly, but through a [`TeamdriveMethods`] instance.
30186///
30187/// # Example
30188///
30189/// Instantiate a resource method builder
30190///
30191/// ```test_harness,no_run
30192/// # extern crate hyper;
30193/// # extern crate hyper_rustls;
30194/// # extern crate google_drive2 as drive2;
30195/// # async fn dox() {
30196/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30197///
30198/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30199/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30200/// # .with_native_roots()
30201/// # .unwrap()
30202/// # .https_only()
30203/// # .enable_http2()
30204/// # .build();
30205///
30206/// # let executor = hyper_util::rt::TokioExecutor::new();
30207/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30208/// # secret,
30209/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30210/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30211/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30212/// # ),
30213/// # ).build().await.unwrap();
30214///
30215/// # let client = hyper_util::client::legacy::Client::builder(
30216/// # hyper_util::rt::TokioExecutor::new()
30217/// # )
30218/// # .build(
30219/// # hyper_rustls::HttpsConnectorBuilder::new()
30220/// # .with_native_roots()
30221/// # .unwrap()
30222/// # .https_or_http()
30223/// # .enable_http2()
30224/// # .build()
30225/// # );
30226/// # let mut hub = DriveHub::new(client, auth);
30227/// // You can configure optional parameters by calling the respective setters at will, and
30228/// // execute the final call using `doit()`.
30229/// // Values shown here are possibly random and not representative !
30230/// let result = hub.teamdrives().delete("teamDriveId")
30231/// .doit().await;
30232/// # }
30233/// ```
30234pub struct TeamdriveDeleteCall<'a, C>
30235where
30236 C: 'a,
30237{
30238 hub: &'a DriveHub<C>,
30239 _team_drive_id: String,
30240 _delegate: Option<&'a mut dyn common::Delegate>,
30241 _additional_params: HashMap<String, String>,
30242 _scopes: BTreeSet<String>,
30243}
30244
30245impl<'a, C> common::CallBuilder for TeamdriveDeleteCall<'a, C> {}
30246
30247impl<'a, C> TeamdriveDeleteCall<'a, C>
30248where
30249 C: common::Connector,
30250{
30251 /// Perform the operation you have build so far.
30252 pub async fn doit(mut self) -> common::Result<common::Response> {
30253 use std::borrow::Cow;
30254 use std::io::{Read, Seek};
30255
30256 use common::{url::Params, ToParts};
30257 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30258
30259 let mut dd = common::DefaultDelegate;
30260 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30261 dlg.begin(common::MethodInfo {
30262 id: "drive.teamdrives.delete",
30263 http_method: hyper::Method::DELETE,
30264 });
30265
30266 for &field in ["teamDriveId"].iter() {
30267 if self._additional_params.contains_key(field) {
30268 dlg.finished(false);
30269 return Err(common::Error::FieldClash(field));
30270 }
30271 }
30272
30273 let mut params = Params::with_capacity(2 + self._additional_params.len());
30274 params.push("teamDriveId", self._team_drive_id);
30275
30276 params.extend(self._additional_params.iter());
30277
30278 let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}";
30279 if self._scopes.is_empty() {
30280 self._scopes.insert(Scope::Full.as_ref().to_string());
30281 }
30282
30283 #[allow(clippy::single_element_loop)]
30284 for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() {
30285 url = params.uri_replacement(url, param_name, find_this, false);
30286 }
30287 {
30288 let to_remove = ["teamDriveId"];
30289 params.remove_params(&to_remove);
30290 }
30291
30292 let url = params.parse_with_url(&url);
30293
30294 loop {
30295 let token = match self
30296 .hub
30297 .auth
30298 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30299 .await
30300 {
30301 Ok(token) => token,
30302 Err(e) => match dlg.token(e) {
30303 Ok(token) => token,
30304 Err(e) => {
30305 dlg.finished(false);
30306 return Err(common::Error::MissingToken(e));
30307 }
30308 },
30309 };
30310 let mut req_result = {
30311 let client = &self.hub.client;
30312 dlg.pre_request();
30313 let mut req_builder = hyper::Request::builder()
30314 .method(hyper::Method::DELETE)
30315 .uri(url.as_str())
30316 .header(USER_AGENT, self.hub._user_agent.clone());
30317
30318 if let Some(token) = token.as_ref() {
30319 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30320 }
30321
30322 let request = req_builder
30323 .header(CONTENT_LENGTH, 0_u64)
30324 .body(common::to_body::<String>(None));
30325
30326 client.request(request.unwrap()).await
30327 };
30328
30329 match req_result {
30330 Err(err) => {
30331 if let common::Retry::After(d) = dlg.http_error(&err) {
30332 sleep(d).await;
30333 continue;
30334 }
30335 dlg.finished(false);
30336 return Err(common::Error::HttpError(err));
30337 }
30338 Ok(res) => {
30339 let (mut parts, body) = res.into_parts();
30340 let mut body = common::Body::new(body);
30341 if !parts.status.is_success() {
30342 let bytes = common::to_bytes(body).await.unwrap_or_default();
30343 let error = serde_json::from_str(&common::to_string(&bytes));
30344 let response = common::to_response(parts, bytes.into());
30345
30346 if let common::Retry::After(d) =
30347 dlg.http_failure(&response, error.as_ref().ok())
30348 {
30349 sleep(d).await;
30350 continue;
30351 }
30352
30353 dlg.finished(false);
30354
30355 return Err(match error {
30356 Ok(value) => common::Error::BadRequest(value),
30357 _ => common::Error::Failure(response),
30358 });
30359 }
30360 let response = common::Response::from_parts(parts, body);
30361
30362 dlg.finished(true);
30363 return Ok(response);
30364 }
30365 }
30366 }
30367 }
30368
30369 /// The ID of the Team Drive
30370 ///
30371 /// Sets the *team drive id* path property to the given value.
30372 ///
30373 /// Even though the property as already been set when instantiating this call,
30374 /// we provide this method for API completeness.
30375 pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveDeleteCall<'a, C> {
30376 self._team_drive_id = new_value.to_string();
30377 self
30378 }
30379 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30380 /// while executing the actual API request.
30381 ///
30382 /// ````text
30383 /// It should be used to handle progress information, and to implement a certain level of resilience.
30384 /// ````
30385 ///
30386 /// Sets the *delegate* property to the given value.
30387 pub fn delegate(
30388 mut self,
30389 new_value: &'a mut dyn common::Delegate,
30390 ) -> TeamdriveDeleteCall<'a, C> {
30391 self._delegate = Some(new_value);
30392 self
30393 }
30394
30395 /// Set any additional parameter of the query string used in the request.
30396 /// It should be used to set parameters which are not yet available through their own
30397 /// setters.
30398 ///
30399 /// Please note that this method must not be used to set any of the known parameters
30400 /// which have their own setter method. If done anyway, the request will fail.
30401 ///
30402 /// # Additional Parameters
30403 ///
30404 /// * *$.xgafv* (query-string) - V1 error format.
30405 /// * *access_token* (query-string) - OAuth access token.
30406 /// * *alt* (query-string) - Data format for response.
30407 /// * *callback* (query-string) - JSONP
30408 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30409 /// * *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.
30410 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30411 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30412 /// * *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.
30413 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30414 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30415 pub fn param<T>(mut self, name: T, value: T) -> TeamdriveDeleteCall<'a, C>
30416 where
30417 T: AsRef<str>,
30418 {
30419 self._additional_params
30420 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30421 self
30422 }
30423
30424 /// Identifies the authorization scope for the method you are building.
30425 ///
30426 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30427 /// [`Scope::Full`].
30428 ///
30429 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30430 /// tokens for more than one scope.
30431 ///
30432 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30433 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30434 /// sufficient, a read-write scope will do as well.
30435 pub fn add_scope<St>(mut self, scope: St) -> TeamdriveDeleteCall<'a, C>
30436 where
30437 St: AsRef<str>,
30438 {
30439 self._scopes.insert(String::from(scope.as_ref()));
30440 self
30441 }
30442 /// Identifies the authorization scope(s) for the method you are building.
30443 ///
30444 /// See [`Self::add_scope()`] for details.
30445 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamdriveDeleteCall<'a, C>
30446 where
30447 I: IntoIterator<Item = St>,
30448 St: AsRef<str>,
30449 {
30450 self._scopes
30451 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30452 self
30453 }
30454
30455 /// Removes all scopes, and no default scope will be used either.
30456 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30457 /// for details).
30458 pub fn clear_scopes(mut self) -> TeamdriveDeleteCall<'a, C> {
30459 self._scopes.clear();
30460 self
30461 }
30462}
30463
30464/// Deprecated: Use `drives.get` instead.
30465///
30466/// A builder for the *get* method supported by a *teamdrive* resource.
30467/// It is not used directly, but through a [`TeamdriveMethods`] instance.
30468///
30469/// # Example
30470///
30471/// Instantiate a resource method builder
30472///
30473/// ```test_harness,no_run
30474/// # extern crate hyper;
30475/// # extern crate hyper_rustls;
30476/// # extern crate google_drive2 as drive2;
30477/// # async fn dox() {
30478/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30479///
30480/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30481/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30482/// # .with_native_roots()
30483/// # .unwrap()
30484/// # .https_only()
30485/// # .enable_http2()
30486/// # .build();
30487///
30488/// # let executor = hyper_util::rt::TokioExecutor::new();
30489/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30490/// # secret,
30491/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30492/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30493/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30494/// # ),
30495/// # ).build().await.unwrap();
30496///
30497/// # let client = hyper_util::client::legacy::Client::builder(
30498/// # hyper_util::rt::TokioExecutor::new()
30499/// # )
30500/// # .build(
30501/// # hyper_rustls::HttpsConnectorBuilder::new()
30502/// # .with_native_roots()
30503/// # .unwrap()
30504/// # .https_or_http()
30505/// # .enable_http2()
30506/// # .build()
30507/// # );
30508/// # let mut hub = DriveHub::new(client, auth);
30509/// // You can configure optional parameters by calling the respective setters at will, and
30510/// // execute the final call using `doit()`.
30511/// // Values shown here are possibly random and not representative !
30512/// let result = hub.teamdrives().get("teamDriveId")
30513/// .use_domain_admin_access(false)
30514/// .doit().await;
30515/// # }
30516/// ```
30517pub struct TeamdriveGetCall<'a, C>
30518where
30519 C: 'a,
30520{
30521 hub: &'a DriveHub<C>,
30522 _team_drive_id: String,
30523 _use_domain_admin_access: Option<bool>,
30524 _delegate: Option<&'a mut dyn common::Delegate>,
30525 _additional_params: HashMap<String, String>,
30526 _scopes: BTreeSet<String>,
30527}
30528
30529impl<'a, C> common::CallBuilder for TeamdriveGetCall<'a, C> {}
30530
30531impl<'a, C> TeamdriveGetCall<'a, C>
30532where
30533 C: common::Connector,
30534{
30535 /// Perform the operation you have build so far.
30536 pub async fn doit(mut self) -> common::Result<(common::Response, TeamDrive)> {
30537 use std::borrow::Cow;
30538 use std::io::{Read, Seek};
30539
30540 use common::{url::Params, ToParts};
30541 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30542
30543 let mut dd = common::DefaultDelegate;
30544 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30545 dlg.begin(common::MethodInfo {
30546 id: "drive.teamdrives.get",
30547 http_method: hyper::Method::GET,
30548 });
30549
30550 for &field in ["alt", "teamDriveId", "useDomainAdminAccess"].iter() {
30551 if self._additional_params.contains_key(field) {
30552 dlg.finished(false);
30553 return Err(common::Error::FieldClash(field));
30554 }
30555 }
30556
30557 let mut params = Params::with_capacity(4 + self._additional_params.len());
30558 params.push("teamDriveId", self._team_drive_id);
30559 if let Some(value) = self._use_domain_admin_access.as_ref() {
30560 params.push("useDomainAdminAccess", value.to_string());
30561 }
30562
30563 params.extend(self._additional_params.iter());
30564
30565 params.push("alt", "json");
30566 let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}";
30567 if self._scopes.is_empty() {
30568 self._scopes.insert(Scope::Readonly.as_ref().to_string());
30569 }
30570
30571 #[allow(clippy::single_element_loop)]
30572 for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() {
30573 url = params.uri_replacement(url, param_name, find_this, false);
30574 }
30575 {
30576 let to_remove = ["teamDriveId"];
30577 params.remove_params(&to_remove);
30578 }
30579
30580 let url = params.parse_with_url(&url);
30581
30582 loop {
30583 let token = match self
30584 .hub
30585 .auth
30586 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30587 .await
30588 {
30589 Ok(token) => token,
30590 Err(e) => match dlg.token(e) {
30591 Ok(token) => token,
30592 Err(e) => {
30593 dlg.finished(false);
30594 return Err(common::Error::MissingToken(e));
30595 }
30596 },
30597 };
30598 let mut req_result = {
30599 let client = &self.hub.client;
30600 dlg.pre_request();
30601 let mut req_builder = hyper::Request::builder()
30602 .method(hyper::Method::GET)
30603 .uri(url.as_str())
30604 .header(USER_AGENT, self.hub._user_agent.clone());
30605
30606 if let Some(token) = token.as_ref() {
30607 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30608 }
30609
30610 let request = req_builder
30611 .header(CONTENT_LENGTH, 0_u64)
30612 .body(common::to_body::<String>(None));
30613
30614 client.request(request.unwrap()).await
30615 };
30616
30617 match req_result {
30618 Err(err) => {
30619 if let common::Retry::After(d) = dlg.http_error(&err) {
30620 sleep(d).await;
30621 continue;
30622 }
30623 dlg.finished(false);
30624 return Err(common::Error::HttpError(err));
30625 }
30626 Ok(res) => {
30627 let (mut parts, body) = res.into_parts();
30628 let mut body = common::Body::new(body);
30629 if !parts.status.is_success() {
30630 let bytes = common::to_bytes(body).await.unwrap_or_default();
30631 let error = serde_json::from_str(&common::to_string(&bytes));
30632 let response = common::to_response(parts, bytes.into());
30633
30634 if let common::Retry::After(d) =
30635 dlg.http_failure(&response, error.as_ref().ok())
30636 {
30637 sleep(d).await;
30638 continue;
30639 }
30640
30641 dlg.finished(false);
30642
30643 return Err(match error {
30644 Ok(value) => common::Error::BadRequest(value),
30645 _ => common::Error::Failure(response),
30646 });
30647 }
30648 let response = {
30649 let bytes = common::to_bytes(body).await.unwrap_or_default();
30650 let encoded = common::to_string(&bytes);
30651 match serde_json::from_str(&encoded) {
30652 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30653 Err(error) => {
30654 dlg.response_json_decode_error(&encoded, &error);
30655 return Err(common::Error::JsonDecodeError(
30656 encoded.to_string(),
30657 error,
30658 ));
30659 }
30660 }
30661 };
30662
30663 dlg.finished(true);
30664 return Ok(response);
30665 }
30666 }
30667 }
30668 }
30669
30670 /// The ID of the Team Drive
30671 ///
30672 /// Sets the *team drive id* path property to the given value.
30673 ///
30674 /// Even though the property as already been set when instantiating this call,
30675 /// we provide this method for API completeness.
30676 pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveGetCall<'a, C> {
30677 self._team_drive_id = new_value.to_string();
30678 self
30679 }
30680 /// 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.
30681 ///
30682 /// Sets the *use domain admin access* query property to the given value.
30683 pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveGetCall<'a, C> {
30684 self._use_domain_admin_access = Some(new_value);
30685 self
30686 }
30687 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30688 /// while executing the actual API request.
30689 ///
30690 /// ````text
30691 /// It should be used to handle progress information, and to implement a certain level of resilience.
30692 /// ````
30693 ///
30694 /// Sets the *delegate* property to the given value.
30695 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TeamdriveGetCall<'a, C> {
30696 self._delegate = Some(new_value);
30697 self
30698 }
30699
30700 /// Set any additional parameter of the query string used in the request.
30701 /// It should be used to set parameters which are not yet available through their own
30702 /// setters.
30703 ///
30704 /// Please note that this method must not be used to set any of the known parameters
30705 /// which have their own setter method. If done anyway, the request will fail.
30706 ///
30707 /// # Additional Parameters
30708 ///
30709 /// * *$.xgafv* (query-string) - V1 error format.
30710 /// * *access_token* (query-string) - OAuth access token.
30711 /// * *alt* (query-string) - Data format for response.
30712 /// * *callback* (query-string) - JSONP
30713 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30714 /// * *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.
30715 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30716 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30717 /// * *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.
30718 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30719 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30720 pub fn param<T>(mut self, name: T, value: T) -> TeamdriveGetCall<'a, C>
30721 where
30722 T: AsRef<str>,
30723 {
30724 self._additional_params
30725 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30726 self
30727 }
30728
30729 /// Identifies the authorization scope for the method you are building.
30730 ///
30731 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30732 /// [`Scope::Readonly`].
30733 ///
30734 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30735 /// tokens for more than one scope.
30736 ///
30737 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30738 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30739 /// sufficient, a read-write scope will do as well.
30740 pub fn add_scope<St>(mut self, scope: St) -> TeamdriveGetCall<'a, C>
30741 where
30742 St: AsRef<str>,
30743 {
30744 self._scopes.insert(String::from(scope.as_ref()));
30745 self
30746 }
30747 /// Identifies the authorization scope(s) for the method you are building.
30748 ///
30749 /// See [`Self::add_scope()`] for details.
30750 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamdriveGetCall<'a, C>
30751 where
30752 I: IntoIterator<Item = St>,
30753 St: AsRef<str>,
30754 {
30755 self._scopes
30756 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30757 self
30758 }
30759
30760 /// Removes all scopes, and no default scope will be used either.
30761 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30762 /// for details).
30763 pub fn clear_scopes(mut self) -> TeamdriveGetCall<'a, C> {
30764 self._scopes.clear();
30765 self
30766 }
30767}
30768
30769/// Deprecated: Use `drives.insert` instead.
30770///
30771/// A builder for the *insert* method supported by a *teamdrive* resource.
30772/// It is not used directly, but through a [`TeamdriveMethods`] instance.
30773///
30774/// # Example
30775///
30776/// Instantiate a resource method builder
30777///
30778/// ```test_harness,no_run
30779/// # extern crate hyper;
30780/// # extern crate hyper_rustls;
30781/// # extern crate google_drive2 as drive2;
30782/// use drive2::api::TeamDrive;
30783/// # async fn dox() {
30784/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30785///
30786/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30787/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30788/// # .with_native_roots()
30789/// # .unwrap()
30790/// # .https_only()
30791/// # .enable_http2()
30792/// # .build();
30793///
30794/// # let executor = hyper_util::rt::TokioExecutor::new();
30795/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30796/// # secret,
30797/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30798/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30799/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30800/// # ),
30801/// # ).build().await.unwrap();
30802///
30803/// # let client = hyper_util::client::legacy::Client::builder(
30804/// # hyper_util::rt::TokioExecutor::new()
30805/// # )
30806/// # .build(
30807/// # hyper_rustls::HttpsConnectorBuilder::new()
30808/// # .with_native_roots()
30809/// # .unwrap()
30810/// # .https_or_http()
30811/// # .enable_http2()
30812/// # .build()
30813/// # );
30814/// # let mut hub = DriveHub::new(client, auth);
30815/// // As the method needs a request, you would usually fill it with the desired information
30816/// // into the respective structure. Some of the parts shown here might not be applicable !
30817/// // Values shown here are possibly random and not representative !
30818/// let mut req = TeamDrive::default();
30819///
30820/// // You can configure optional parameters by calling the respective setters at will, and
30821/// // execute the final call using `doit()`.
30822/// // Values shown here are possibly random and not representative !
30823/// let result = hub.teamdrives().insert(req, "requestId")
30824/// .doit().await;
30825/// # }
30826/// ```
30827pub struct TeamdriveInsertCall<'a, C>
30828where
30829 C: 'a,
30830{
30831 hub: &'a DriveHub<C>,
30832 _request: TeamDrive,
30833 _request_id: String,
30834 _delegate: Option<&'a mut dyn common::Delegate>,
30835 _additional_params: HashMap<String, String>,
30836 _scopes: BTreeSet<String>,
30837}
30838
30839impl<'a, C> common::CallBuilder for TeamdriveInsertCall<'a, C> {}
30840
30841impl<'a, C> TeamdriveInsertCall<'a, C>
30842where
30843 C: common::Connector,
30844{
30845 /// Perform the operation you have build so far.
30846 pub async fn doit(mut self) -> common::Result<(common::Response, TeamDrive)> {
30847 use std::borrow::Cow;
30848 use std::io::{Read, Seek};
30849
30850 use common::{url::Params, ToParts};
30851 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30852
30853 let mut dd = common::DefaultDelegate;
30854 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30855 dlg.begin(common::MethodInfo {
30856 id: "drive.teamdrives.insert",
30857 http_method: hyper::Method::POST,
30858 });
30859
30860 for &field in ["alt", "requestId"].iter() {
30861 if self._additional_params.contains_key(field) {
30862 dlg.finished(false);
30863 return Err(common::Error::FieldClash(field));
30864 }
30865 }
30866
30867 let mut params = Params::with_capacity(4 + self._additional_params.len());
30868 params.push("requestId", self._request_id);
30869
30870 params.extend(self._additional_params.iter());
30871
30872 params.push("alt", "json");
30873 let mut url = self.hub._base_url.clone() + "teamdrives";
30874 if self._scopes.is_empty() {
30875 self._scopes.insert(Scope::Full.as_ref().to_string());
30876 }
30877
30878 let url = params.parse_with_url(&url);
30879
30880 let mut json_mime_type = mime::APPLICATION_JSON;
30881 let mut request_value_reader = {
30882 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30883 common::remove_json_null_values(&mut value);
30884 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30885 serde_json::to_writer(&mut dst, &value).unwrap();
30886 dst
30887 };
30888 let request_size = request_value_reader
30889 .seek(std::io::SeekFrom::End(0))
30890 .unwrap();
30891 request_value_reader
30892 .seek(std::io::SeekFrom::Start(0))
30893 .unwrap();
30894
30895 loop {
30896 let token = match self
30897 .hub
30898 .auth
30899 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30900 .await
30901 {
30902 Ok(token) => token,
30903 Err(e) => match dlg.token(e) {
30904 Ok(token) => token,
30905 Err(e) => {
30906 dlg.finished(false);
30907 return Err(common::Error::MissingToken(e));
30908 }
30909 },
30910 };
30911 request_value_reader
30912 .seek(std::io::SeekFrom::Start(0))
30913 .unwrap();
30914 let mut req_result = {
30915 let client = &self.hub.client;
30916 dlg.pre_request();
30917 let mut req_builder = hyper::Request::builder()
30918 .method(hyper::Method::POST)
30919 .uri(url.as_str())
30920 .header(USER_AGENT, self.hub._user_agent.clone());
30921
30922 if let Some(token) = token.as_ref() {
30923 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30924 }
30925
30926 let request = req_builder
30927 .header(CONTENT_TYPE, json_mime_type.to_string())
30928 .header(CONTENT_LENGTH, request_size as u64)
30929 .body(common::to_body(
30930 request_value_reader.get_ref().clone().into(),
30931 ));
30932
30933 client.request(request.unwrap()).await
30934 };
30935
30936 match req_result {
30937 Err(err) => {
30938 if let common::Retry::After(d) = dlg.http_error(&err) {
30939 sleep(d).await;
30940 continue;
30941 }
30942 dlg.finished(false);
30943 return Err(common::Error::HttpError(err));
30944 }
30945 Ok(res) => {
30946 let (mut parts, body) = res.into_parts();
30947 let mut body = common::Body::new(body);
30948 if !parts.status.is_success() {
30949 let bytes = common::to_bytes(body).await.unwrap_or_default();
30950 let error = serde_json::from_str(&common::to_string(&bytes));
30951 let response = common::to_response(parts, bytes.into());
30952
30953 if let common::Retry::After(d) =
30954 dlg.http_failure(&response, error.as_ref().ok())
30955 {
30956 sleep(d).await;
30957 continue;
30958 }
30959
30960 dlg.finished(false);
30961
30962 return Err(match error {
30963 Ok(value) => common::Error::BadRequest(value),
30964 _ => common::Error::Failure(response),
30965 });
30966 }
30967 let response = {
30968 let bytes = common::to_bytes(body).await.unwrap_or_default();
30969 let encoded = common::to_string(&bytes);
30970 match serde_json::from_str(&encoded) {
30971 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30972 Err(error) => {
30973 dlg.response_json_decode_error(&encoded, &error);
30974 return Err(common::Error::JsonDecodeError(
30975 encoded.to_string(),
30976 error,
30977 ));
30978 }
30979 }
30980 };
30981
30982 dlg.finished(true);
30983 return Ok(response);
30984 }
30985 }
30986 }
30987 }
30988
30989 ///
30990 /// Sets the *request* property to the given value.
30991 ///
30992 /// Even though the property as already been set when instantiating this call,
30993 /// we provide this method for API completeness.
30994 pub fn request(mut self, new_value: TeamDrive) -> TeamdriveInsertCall<'a, C> {
30995 self._request = new_value;
30996 self
30997 }
30998 /// 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.
30999 ///
31000 /// Sets the *request id* query property to the given value.
31001 ///
31002 /// Even though the property as already been set when instantiating this call,
31003 /// we provide this method for API completeness.
31004 pub fn request_id(mut self, new_value: &str) -> TeamdriveInsertCall<'a, C> {
31005 self._request_id = new_value.to_string();
31006 self
31007 }
31008 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31009 /// while executing the actual API request.
31010 ///
31011 /// ````text
31012 /// It should be used to handle progress information, and to implement a certain level of resilience.
31013 /// ````
31014 ///
31015 /// Sets the *delegate* property to the given value.
31016 pub fn delegate(
31017 mut self,
31018 new_value: &'a mut dyn common::Delegate,
31019 ) -> TeamdriveInsertCall<'a, C> {
31020 self._delegate = Some(new_value);
31021 self
31022 }
31023
31024 /// Set any additional parameter of the query string used in the request.
31025 /// It should be used to set parameters which are not yet available through their own
31026 /// setters.
31027 ///
31028 /// Please note that this method must not be used to set any of the known parameters
31029 /// which have their own setter method. If done anyway, the request will fail.
31030 ///
31031 /// # Additional Parameters
31032 ///
31033 /// * *$.xgafv* (query-string) - V1 error format.
31034 /// * *access_token* (query-string) - OAuth access token.
31035 /// * *alt* (query-string) - Data format for response.
31036 /// * *callback* (query-string) - JSONP
31037 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31038 /// * *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.
31039 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31040 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31041 /// * *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.
31042 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31043 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31044 pub fn param<T>(mut self, name: T, value: T) -> TeamdriveInsertCall<'a, C>
31045 where
31046 T: AsRef<str>,
31047 {
31048 self._additional_params
31049 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31050 self
31051 }
31052
31053 /// Identifies the authorization scope for the method you are building.
31054 ///
31055 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31056 /// [`Scope::Full`].
31057 ///
31058 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31059 /// tokens for more than one scope.
31060 ///
31061 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31062 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31063 /// sufficient, a read-write scope will do as well.
31064 pub fn add_scope<St>(mut self, scope: St) -> TeamdriveInsertCall<'a, C>
31065 where
31066 St: AsRef<str>,
31067 {
31068 self._scopes.insert(String::from(scope.as_ref()));
31069 self
31070 }
31071 /// Identifies the authorization scope(s) for the method you are building.
31072 ///
31073 /// See [`Self::add_scope()`] for details.
31074 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamdriveInsertCall<'a, C>
31075 where
31076 I: IntoIterator<Item = St>,
31077 St: AsRef<str>,
31078 {
31079 self._scopes
31080 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31081 self
31082 }
31083
31084 /// Removes all scopes, and no default scope will be used either.
31085 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31086 /// for details).
31087 pub fn clear_scopes(mut self) -> TeamdriveInsertCall<'a, C> {
31088 self._scopes.clear();
31089 self
31090 }
31091}
31092
31093/// Deprecated: Use `drives.list` instead.
31094///
31095/// A builder for the *list* method supported by a *teamdrive* resource.
31096/// It is not used directly, but through a [`TeamdriveMethods`] instance.
31097///
31098/// # Example
31099///
31100/// Instantiate a resource method builder
31101///
31102/// ```test_harness,no_run
31103/// # extern crate hyper;
31104/// # extern crate hyper_rustls;
31105/// # extern crate google_drive2 as drive2;
31106/// # async fn dox() {
31107/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31108///
31109/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31110/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31111/// # .with_native_roots()
31112/// # .unwrap()
31113/// # .https_only()
31114/// # .enable_http2()
31115/// # .build();
31116///
31117/// # let executor = hyper_util::rt::TokioExecutor::new();
31118/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31119/// # secret,
31120/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31121/// # yup_oauth2::client::CustomHyperClientBuilder::from(
31122/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
31123/// # ),
31124/// # ).build().await.unwrap();
31125///
31126/// # let client = hyper_util::client::legacy::Client::builder(
31127/// # hyper_util::rt::TokioExecutor::new()
31128/// # )
31129/// # .build(
31130/// # hyper_rustls::HttpsConnectorBuilder::new()
31131/// # .with_native_roots()
31132/// # .unwrap()
31133/// # .https_or_http()
31134/// # .enable_http2()
31135/// # .build()
31136/// # );
31137/// # let mut hub = DriveHub::new(client, auth);
31138/// // You can configure optional parameters by calling the respective setters at will, and
31139/// // execute the final call using `doit()`.
31140/// // Values shown here are possibly random and not representative !
31141/// let result = hub.teamdrives().list()
31142/// .use_domain_admin_access(true)
31143/// .q("eirmod")
31144/// .page_token("dolores")
31145/// .max_results(-82)
31146/// .doit().await;
31147/// # }
31148/// ```
31149pub struct TeamdriveListCall<'a, C>
31150where
31151 C: 'a,
31152{
31153 hub: &'a DriveHub<C>,
31154 _use_domain_admin_access: Option<bool>,
31155 _q: Option<String>,
31156 _page_token: Option<String>,
31157 _max_results: Option<i32>,
31158 _delegate: Option<&'a mut dyn common::Delegate>,
31159 _additional_params: HashMap<String, String>,
31160 _scopes: BTreeSet<String>,
31161}
31162
31163impl<'a, C> common::CallBuilder for TeamdriveListCall<'a, C> {}
31164
31165impl<'a, C> TeamdriveListCall<'a, C>
31166where
31167 C: common::Connector,
31168{
31169 /// Perform the operation you have build so far.
31170 pub async fn doit(mut self) -> common::Result<(common::Response, TeamDriveList)> {
31171 use std::borrow::Cow;
31172 use std::io::{Read, Seek};
31173
31174 use common::{url::Params, ToParts};
31175 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31176
31177 let mut dd = common::DefaultDelegate;
31178 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31179 dlg.begin(common::MethodInfo {
31180 id: "drive.teamdrives.list",
31181 http_method: hyper::Method::GET,
31182 });
31183
31184 for &field in [
31185 "alt",
31186 "useDomainAdminAccess",
31187 "q",
31188 "pageToken",
31189 "maxResults",
31190 ]
31191 .iter()
31192 {
31193 if self._additional_params.contains_key(field) {
31194 dlg.finished(false);
31195 return Err(common::Error::FieldClash(field));
31196 }
31197 }
31198
31199 let mut params = Params::with_capacity(6 + self._additional_params.len());
31200 if let Some(value) = self._use_domain_admin_access.as_ref() {
31201 params.push("useDomainAdminAccess", value.to_string());
31202 }
31203 if let Some(value) = self._q.as_ref() {
31204 params.push("q", value);
31205 }
31206 if let Some(value) = self._page_token.as_ref() {
31207 params.push("pageToken", value);
31208 }
31209 if let Some(value) = self._max_results.as_ref() {
31210 params.push("maxResults", value.to_string());
31211 }
31212
31213 params.extend(self._additional_params.iter());
31214
31215 params.push("alt", "json");
31216 let mut url = self.hub._base_url.clone() + "teamdrives";
31217 if self._scopes.is_empty() {
31218 self._scopes.insert(Scope::Readonly.as_ref().to_string());
31219 }
31220
31221 let url = params.parse_with_url(&url);
31222
31223 loop {
31224 let token = match self
31225 .hub
31226 .auth
31227 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31228 .await
31229 {
31230 Ok(token) => token,
31231 Err(e) => match dlg.token(e) {
31232 Ok(token) => token,
31233 Err(e) => {
31234 dlg.finished(false);
31235 return Err(common::Error::MissingToken(e));
31236 }
31237 },
31238 };
31239 let mut req_result = {
31240 let client = &self.hub.client;
31241 dlg.pre_request();
31242 let mut req_builder = hyper::Request::builder()
31243 .method(hyper::Method::GET)
31244 .uri(url.as_str())
31245 .header(USER_AGENT, self.hub._user_agent.clone());
31246
31247 if let Some(token) = token.as_ref() {
31248 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31249 }
31250
31251 let request = req_builder
31252 .header(CONTENT_LENGTH, 0_u64)
31253 .body(common::to_body::<String>(None));
31254
31255 client.request(request.unwrap()).await
31256 };
31257
31258 match req_result {
31259 Err(err) => {
31260 if let common::Retry::After(d) = dlg.http_error(&err) {
31261 sleep(d).await;
31262 continue;
31263 }
31264 dlg.finished(false);
31265 return Err(common::Error::HttpError(err));
31266 }
31267 Ok(res) => {
31268 let (mut parts, body) = res.into_parts();
31269 let mut body = common::Body::new(body);
31270 if !parts.status.is_success() {
31271 let bytes = common::to_bytes(body).await.unwrap_or_default();
31272 let error = serde_json::from_str(&common::to_string(&bytes));
31273 let response = common::to_response(parts, bytes.into());
31274
31275 if let common::Retry::After(d) =
31276 dlg.http_failure(&response, error.as_ref().ok())
31277 {
31278 sleep(d).await;
31279 continue;
31280 }
31281
31282 dlg.finished(false);
31283
31284 return Err(match error {
31285 Ok(value) => common::Error::BadRequest(value),
31286 _ => common::Error::Failure(response),
31287 });
31288 }
31289 let response = {
31290 let bytes = common::to_bytes(body).await.unwrap_or_default();
31291 let encoded = common::to_string(&bytes);
31292 match serde_json::from_str(&encoded) {
31293 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31294 Err(error) => {
31295 dlg.response_json_decode_error(&encoded, &error);
31296 return Err(common::Error::JsonDecodeError(
31297 encoded.to_string(),
31298 error,
31299 ));
31300 }
31301 }
31302 };
31303
31304 dlg.finished(true);
31305 return Ok(response);
31306 }
31307 }
31308 }
31309 }
31310
31311 /// 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.
31312 ///
31313 /// Sets the *use domain admin access* query property to the given value.
31314 pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveListCall<'a, C> {
31315 self._use_domain_admin_access = Some(new_value);
31316 self
31317 }
31318 /// Query string for searching Team Drives.
31319 ///
31320 /// Sets the *q* query property to the given value.
31321 pub fn q(mut self, new_value: &str) -> TeamdriveListCall<'a, C> {
31322 self._q = Some(new_value.to_string());
31323 self
31324 }
31325 /// Page token for Team Drives.
31326 ///
31327 /// Sets the *page token* query property to the given value.
31328 pub fn page_token(mut self, new_value: &str) -> TeamdriveListCall<'a, C> {
31329 self._page_token = Some(new_value.to_string());
31330 self
31331 }
31332 /// Maximum number of Team Drives to return.
31333 ///
31334 /// Sets the *max results* query property to the given value.
31335 pub fn max_results(mut self, new_value: i32) -> TeamdriveListCall<'a, C> {
31336 self._max_results = Some(new_value);
31337 self
31338 }
31339 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31340 /// while executing the actual API request.
31341 ///
31342 /// ````text
31343 /// It should be used to handle progress information, and to implement a certain level of resilience.
31344 /// ````
31345 ///
31346 /// Sets the *delegate* property to the given value.
31347 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TeamdriveListCall<'a, C> {
31348 self._delegate = Some(new_value);
31349 self
31350 }
31351
31352 /// Set any additional parameter of the query string used in the request.
31353 /// It should be used to set parameters which are not yet available through their own
31354 /// setters.
31355 ///
31356 /// Please note that this method must not be used to set any of the known parameters
31357 /// which have their own setter method. If done anyway, the request will fail.
31358 ///
31359 /// # Additional Parameters
31360 ///
31361 /// * *$.xgafv* (query-string) - V1 error format.
31362 /// * *access_token* (query-string) - OAuth access token.
31363 /// * *alt* (query-string) - Data format for response.
31364 /// * *callback* (query-string) - JSONP
31365 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31366 /// * *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.
31367 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31368 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31369 /// * *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.
31370 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31371 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31372 pub fn param<T>(mut self, name: T, value: T) -> TeamdriveListCall<'a, C>
31373 where
31374 T: AsRef<str>,
31375 {
31376 self._additional_params
31377 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31378 self
31379 }
31380
31381 /// Identifies the authorization scope for the method you are building.
31382 ///
31383 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31384 /// [`Scope::Readonly`].
31385 ///
31386 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31387 /// tokens for more than one scope.
31388 ///
31389 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31390 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31391 /// sufficient, a read-write scope will do as well.
31392 pub fn add_scope<St>(mut self, scope: St) -> TeamdriveListCall<'a, C>
31393 where
31394 St: AsRef<str>,
31395 {
31396 self._scopes.insert(String::from(scope.as_ref()));
31397 self
31398 }
31399 /// Identifies the authorization scope(s) for the method you are building.
31400 ///
31401 /// See [`Self::add_scope()`] for details.
31402 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamdriveListCall<'a, C>
31403 where
31404 I: IntoIterator<Item = St>,
31405 St: AsRef<str>,
31406 {
31407 self._scopes
31408 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31409 self
31410 }
31411
31412 /// Removes all scopes, and no default scope will be used either.
31413 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31414 /// for details).
31415 pub fn clear_scopes(mut self) -> TeamdriveListCall<'a, C> {
31416 self._scopes.clear();
31417 self
31418 }
31419}
31420
31421/// Deprecated: Use `drives.update` instead.
31422///
31423/// A builder for the *update* method supported by a *teamdrive* resource.
31424/// It is not used directly, but through a [`TeamdriveMethods`] instance.
31425///
31426/// # Example
31427///
31428/// Instantiate a resource method builder
31429///
31430/// ```test_harness,no_run
31431/// # extern crate hyper;
31432/// # extern crate hyper_rustls;
31433/// # extern crate google_drive2 as drive2;
31434/// use drive2::api::TeamDrive;
31435/// # async fn dox() {
31436/// # use drive2::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31437///
31438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31439/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31440/// # .with_native_roots()
31441/// # .unwrap()
31442/// # .https_only()
31443/// # .enable_http2()
31444/// # .build();
31445///
31446/// # let executor = hyper_util::rt::TokioExecutor::new();
31447/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31448/// # secret,
31449/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31450/// # yup_oauth2::client::CustomHyperClientBuilder::from(
31451/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
31452/// # ),
31453/// # ).build().await.unwrap();
31454///
31455/// # let client = hyper_util::client::legacy::Client::builder(
31456/// # hyper_util::rt::TokioExecutor::new()
31457/// # )
31458/// # .build(
31459/// # hyper_rustls::HttpsConnectorBuilder::new()
31460/// # .with_native_roots()
31461/// # .unwrap()
31462/// # .https_or_http()
31463/// # .enable_http2()
31464/// # .build()
31465/// # );
31466/// # let mut hub = DriveHub::new(client, auth);
31467/// // As the method needs a request, you would usually fill it with the desired information
31468/// // into the respective structure. Some of the parts shown here might not be applicable !
31469/// // Values shown here are possibly random and not representative !
31470/// let mut req = TeamDrive::default();
31471///
31472/// // You can configure optional parameters by calling the respective setters at will, and
31473/// // execute the final call using `doit()`.
31474/// // Values shown here are possibly random and not representative !
31475/// let result = hub.teamdrives().update(req, "teamDriveId")
31476/// .use_domain_admin_access(false)
31477/// .doit().await;
31478/// # }
31479/// ```
31480pub struct TeamdriveUpdateCall<'a, C>
31481where
31482 C: 'a,
31483{
31484 hub: &'a DriveHub<C>,
31485 _request: TeamDrive,
31486 _team_drive_id: String,
31487 _use_domain_admin_access: Option<bool>,
31488 _delegate: Option<&'a mut dyn common::Delegate>,
31489 _additional_params: HashMap<String, String>,
31490 _scopes: BTreeSet<String>,
31491}
31492
31493impl<'a, C> common::CallBuilder for TeamdriveUpdateCall<'a, C> {}
31494
31495impl<'a, C> TeamdriveUpdateCall<'a, C>
31496where
31497 C: common::Connector,
31498{
31499 /// Perform the operation you have build so far.
31500 pub async fn doit(mut self) -> common::Result<(common::Response, TeamDrive)> {
31501 use std::borrow::Cow;
31502 use std::io::{Read, Seek};
31503
31504 use common::{url::Params, ToParts};
31505 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31506
31507 let mut dd = common::DefaultDelegate;
31508 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31509 dlg.begin(common::MethodInfo {
31510 id: "drive.teamdrives.update",
31511 http_method: hyper::Method::PUT,
31512 });
31513
31514 for &field in ["alt", "teamDriveId", "useDomainAdminAccess"].iter() {
31515 if self._additional_params.contains_key(field) {
31516 dlg.finished(false);
31517 return Err(common::Error::FieldClash(field));
31518 }
31519 }
31520
31521 let mut params = Params::with_capacity(5 + self._additional_params.len());
31522 params.push("teamDriveId", self._team_drive_id);
31523 if let Some(value) = self._use_domain_admin_access.as_ref() {
31524 params.push("useDomainAdminAccess", value.to_string());
31525 }
31526
31527 params.extend(self._additional_params.iter());
31528
31529 params.push("alt", "json");
31530 let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}";
31531 if self._scopes.is_empty() {
31532 self._scopes.insert(Scope::Full.as_ref().to_string());
31533 }
31534
31535 #[allow(clippy::single_element_loop)]
31536 for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() {
31537 url = params.uri_replacement(url, param_name, find_this, false);
31538 }
31539 {
31540 let to_remove = ["teamDriveId"];
31541 params.remove_params(&to_remove);
31542 }
31543
31544 let url = params.parse_with_url(&url);
31545
31546 let mut json_mime_type = mime::APPLICATION_JSON;
31547 let mut request_value_reader = {
31548 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31549 common::remove_json_null_values(&mut value);
31550 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31551 serde_json::to_writer(&mut dst, &value).unwrap();
31552 dst
31553 };
31554 let request_size = request_value_reader
31555 .seek(std::io::SeekFrom::End(0))
31556 .unwrap();
31557 request_value_reader
31558 .seek(std::io::SeekFrom::Start(0))
31559 .unwrap();
31560
31561 loop {
31562 let token = match self
31563 .hub
31564 .auth
31565 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31566 .await
31567 {
31568 Ok(token) => token,
31569 Err(e) => match dlg.token(e) {
31570 Ok(token) => token,
31571 Err(e) => {
31572 dlg.finished(false);
31573 return Err(common::Error::MissingToken(e));
31574 }
31575 },
31576 };
31577 request_value_reader
31578 .seek(std::io::SeekFrom::Start(0))
31579 .unwrap();
31580 let mut req_result = {
31581 let client = &self.hub.client;
31582 dlg.pre_request();
31583 let mut req_builder = hyper::Request::builder()
31584 .method(hyper::Method::PUT)
31585 .uri(url.as_str())
31586 .header(USER_AGENT, self.hub._user_agent.clone());
31587
31588 if let Some(token) = token.as_ref() {
31589 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31590 }
31591
31592 let request = req_builder
31593 .header(CONTENT_TYPE, json_mime_type.to_string())
31594 .header(CONTENT_LENGTH, request_size as u64)
31595 .body(common::to_body(
31596 request_value_reader.get_ref().clone().into(),
31597 ));
31598
31599 client.request(request.unwrap()).await
31600 };
31601
31602 match req_result {
31603 Err(err) => {
31604 if let common::Retry::After(d) = dlg.http_error(&err) {
31605 sleep(d).await;
31606 continue;
31607 }
31608 dlg.finished(false);
31609 return Err(common::Error::HttpError(err));
31610 }
31611 Ok(res) => {
31612 let (mut parts, body) = res.into_parts();
31613 let mut body = common::Body::new(body);
31614 if !parts.status.is_success() {
31615 let bytes = common::to_bytes(body).await.unwrap_or_default();
31616 let error = serde_json::from_str(&common::to_string(&bytes));
31617 let response = common::to_response(parts, bytes.into());
31618
31619 if let common::Retry::After(d) =
31620 dlg.http_failure(&response, error.as_ref().ok())
31621 {
31622 sleep(d).await;
31623 continue;
31624 }
31625
31626 dlg.finished(false);
31627
31628 return Err(match error {
31629 Ok(value) => common::Error::BadRequest(value),
31630 _ => common::Error::Failure(response),
31631 });
31632 }
31633 let response = {
31634 let bytes = common::to_bytes(body).await.unwrap_or_default();
31635 let encoded = common::to_string(&bytes);
31636 match serde_json::from_str(&encoded) {
31637 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31638 Err(error) => {
31639 dlg.response_json_decode_error(&encoded, &error);
31640 return Err(common::Error::JsonDecodeError(
31641 encoded.to_string(),
31642 error,
31643 ));
31644 }
31645 }
31646 };
31647
31648 dlg.finished(true);
31649 return Ok(response);
31650 }
31651 }
31652 }
31653 }
31654
31655 ///
31656 /// Sets the *request* property to the given value.
31657 ///
31658 /// Even though the property as already been set when instantiating this call,
31659 /// we provide this method for API completeness.
31660 pub fn request(mut self, new_value: TeamDrive) -> TeamdriveUpdateCall<'a, C> {
31661 self._request = new_value;
31662 self
31663 }
31664 /// The ID of the Team Drive
31665 ///
31666 /// Sets the *team drive id* path property to the given value.
31667 ///
31668 /// Even though the property as already been set when instantiating this call,
31669 /// we provide this method for API completeness.
31670 pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveUpdateCall<'a, C> {
31671 self._team_drive_id = new_value.to_string();
31672 self
31673 }
31674 /// 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.
31675 ///
31676 /// Sets the *use domain admin access* query property to the given value.
31677 pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveUpdateCall<'a, C> {
31678 self._use_domain_admin_access = Some(new_value);
31679 self
31680 }
31681 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31682 /// while executing the actual API request.
31683 ///
31684 /// ````text
31685 /// It should be used to handle progress information, and to implement a certain level of resilience.
31686 /// ````
31687 ///
31688 /// Sets the *delegate* property to the given value.
31689 pub fn delegate(
31690 mut self,
31691 new_value: &'a mut dyn common::Delegate,
31692 ) -> TeamdriveUpdateCall<'a, C> {
31693 self._delegate = Some(new_value);
31694 self
31695 }
31696
31697 /// Set any additional parameter of the query string used in the request.
31698 /// It should be used to set parameters which are not yet available through their own
31699 /// setters.
31700 ///
31701 /// Please note that this method must not be used to set any of the known parameters
31702 /// which have their own setter method. If done anyway, the request will fail.
31703 ///
31704 /// # Additional Parameters
31705 ///
31706 /// * *$.xgafv* (query-string) - V1 error format.
31707 /// * *access_token* (query-string) - OAuth access token.
31708 /// * *alt* (query-string) - Data format for response.
31709 /// * *callback* (query-string) - JSONP
31710 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31711 /// * *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.
31712 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31713 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31714 /// * *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.
31715 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31716 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31717 pub fn param<T>(mut self, name: T, value: T) -> TeamdriveUpdateCall<'a, C>
31718 where
31719 T: AsRef<str>,
31720 {
31721 self._additional_params
31722 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31723 self
31724 }
31725
31726 /// Identifies the authorization scope for the method you are building.
31727 ///
31728 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31729 /// [`Scope::Full`].
31730 ///
31731 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31732 /// tokens for more than one scope.
31733 ///
31734 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31735 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31736 /// sufficient, a read-write scope will do as well.
31737 pub fn add_scope<St>(mut self, scope: St) -> TeamdriveUpdateCall<'a, C>
31738 where
31739 St: AsRef<str>,
31740 {
31741 self._scopes.insert(String::from(scope.as_ref()));
31742 self
31743 }
31744 /// Identifies the authorization scope(s) for the method you are building.
31745 ///
31746 /// See [`Self::add_scope()`] for details.
31747 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamdriveUpdateCall<'a, C>
31748 where
31749 I: IntoIterator<Item = St>,
31750 St: AsRef<str>,
31751 {
31752 self._scopes
31753 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31754 self
31755 }
31756
31757 /// Removes all scopes, and no default scope will be used either.
31758 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31759 /// for details).
31760 pub fn clear_scopes(mut self) -> TeamdriveUpdateCall<'a, C> {
31761 self._scopes.clear();
31762 self
31763 }
31764}