google_drive3/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_drive3 as drive3;
85/// use drive3::{Result, Error};
86/// # async fn dox() {
87/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
88///
89/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
90/// // `client_secret`, among other things.
91/// let secret: yup_oauth2::ApplicationSecret = Default::default();
92/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
93/// // unless you replace `None` with the desired Flow.
94/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
95/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
96/// // retrieve them from storage.
97/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
98/// .with_native_roots()
99/// .unwrap()
100/// .https_only()
101/// .enable_http2()
102/// .build();
103///
104/// let executor = hyper_util::rt::TokioExecutor::new();
105/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
106/// secret,
107/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
108/// yup_oauth2::client::CustomHyperClientBuilder::from(
109/// hyper_util::client::legacy::Client::builder(executor).build(connector),
110/// ),
111/// ).build().await.unwrap();
112///
113/// let client = hyper_util::client::legacy::Client::builder(
114/// hyper_util::rt::TokioExecutor::new()
115/// )
116/// .build(
117/// hyper_rustls::HttpsConnectorBuilder::new()
118/// .with_native_roots()
119/// .unwrap()
120/// .https_or_http()
121/// .enable_http2()
122/// .build()
123/// );
124/// let mut hub = DriveHub::new(client, auth);
125/// // You can configure optional parameters by calling the respective setters at will, and
126/// // execute the final call using `doit()`.
127/// // Values shown here are possibly random and not representative !
128/// let result = hub.files().list()
129/// .team_drive_id("eos")
130/// .supports_team_drives(false)
131/// .supports_all_drives(true)
132/// .spaces("duo")
133/// .q("sed")
134/// .page_token("no")
135/// .page_size(-15)
136/// .order_by("kasd")
137/// .include_team_drive_items(true)
138/// .include_permissions_for_view("et")
139/// .include_labels("et")
140/// .include_items_from_all_drives(false)
141/// .drive_id("erat")
142/// .corpus("sed")
143/// .corpora("duo")
144/// .doit().await;
145///
146/// match result {
147/// Err(e) => match e {
148/// // The Error enum provides details about what exactly happened.
149/// // You can also just use its `Debug`, `Display` or `Error` traits
150/// Error::HttpError(_)
151/// |Error::Io(_)
152/// |Error::MissingAPIKey
153/// |Error::MissingToken(_)
154/// |Error::Cancelled
155/// |Error::UploadSizeLimitExceeded(_, _)
156/// |Error::Failure(_)
157/// |Error::BadRequest(_)
158/// |Error::FieldClash(_)
159/// |Error::JsonDecodeError(_, _) => println!("{}", e),
160/// },
161/// Ok(res) => println!("Success: {:?}", res),
162/// }
163/// # }
164/// ```
165#[derive(Clone)]
166pub struct DriveHub<C> {
167 pub client: common::Client<C>,
168 pub auth: Box<dyn common::GetToken>,
169 _user_agent: String,
170 _base_url: String,
171 _root_url: String,
172}
173
174impl<C> common::Hub for DriveHub<C> {}
175
176impl<'a, C> DriveHub<C> {
177 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> DriveHub<C> {
178 DriveHub {
179 client,
180 auth: Box::new(auth),
181 _user_agent: "google-api-rust-client/7.0.0".to_string(),
182 _base_url: "https://www.googleapis.com/drive/v3/".to_string(),
183 _root_url: "https://www.googleapis.com/".to_string(),
184 }
185 }
186
187 pub fn about(&'a self) -> AboutMethods<'a, C> {
188 AboutMethods { hub: self }
189 }
190 pub fn accessproposals(&'a self) -> AccessproposalMethods<'a, C> {
191 AccessproposalMethods { hub: self }
192 }
193 pub fn approvals(&'a self) -> ApprovalMethods<'a, C> {
194 ApprovalMethods { hub: self }
195 }
196 pub fn apps(&'a self) -> AppMethods<'a, C> {
197 AppMethods { hub: self }
198 }
199 pub fn changes(&'a self) -> ChangeMethods<'a, C> {
200 ChangeMethods { hub: self }
201 }
202 pub fn channels(&'a self) -> ChannelMethods<'a, C> {
203 ChannelMethods { hub: self }
204 }
205 pub fn comments(&'a self) -> CommentMethods<'a, C> {
206 CommentMethods { hub: self }
207 }
208 pub fn drives(&'a self) -> DriveMethods<'a, C> {
209 DriveMethods { hub: self }
210 }
211 pub fn files(&'a self) -> FileMethods<'a, C> {
212 FileMethods { hub: self }
213 }
214 pub fn operations(&'a self) -> OperationMethods<'a, C> {
215 OperationMethods { hub: self }
216 }
217 pub fn permissions(&'a self) -> PermissionMethods<'a, C> {
218 PermissionMethods { hub: self }
219 }
220 pub fn replies(&'a self) -> ReplyMethods<'a, C> {
221 ReplyMethods { hub: self }
222 }
223 pub fn revisions(&'a self) -> RevisionMethods<'a, C> {
224 RevisionMethods { hub: self }
225 }
226 pub fn teamdrives(&'a self) -> TeamdriveMethods<'a, C> {
227 TeamdriveMethods { hub: self }
228 }
229
230 /// Set the user-agent header field to use in all requests to the server.
231 /// It defaults to `google-api-rust-client/7.0.0`.
232 ///
233 /// Returns the previously set user-agent.
234 pub fn user_agent(&mut self, agent_name: String) -> String {
235 std::mem::replace(&mut self._user_agent, agent_name)
236 }
237
238 /// Set the base url to use in all requests to the server.
239 /// It defaults to `https://www.googleapis.com/drive/v3/`.
240 ///
241 /// Returns the previously set base url.
242 pub fn base_url(&mut self, new_base_url: String) -> String {
243 std::mem::replace(&mut self._base_url, new_base_url)
244 }
245
246 /// Set the root url to use in all requests to the server.
247 /// It defaults to `https://www.googleapis.com/`.
248 ///
249 /// Returns the previously set root url.
250 pub fn root_url(&mut self, new_root_url: String) -> String {
251 std::mem::replace(&mut self._root_url, new_root_url)
252 }
253}
254
255// ############
256// SCHEMAS ###
257// ##########
258/// Information about the user, the user’s Drive, and system capabilities.
259///
260/// # Activities
261///
262/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
263/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
264///
265/// * [get about](AboutGetCall) (response)
266#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
267#[serde_with::serde_as]
268#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
269pub struct About {
270 /// Whether the user has installed the requesting app.
271 #[serde(rename = "appInstalled")]
272 pub app_installed: Option<bool>,
273 /// Whether the user can create shared drives.
274 #[serde(rename = "canCreateDrives")]
275 pub can_create_drives: Option<bool>,
276 /// Deprecated: Use `canCreateDrives` instead.
277 #[serde(rename = "canCreateTeamDrives")]
278 pub can_create_team_drives: Option<bool>,
279 /// A list of themes that are supported for shared drives.
280 #[serde(rename = "driveThemes")]
281 pub drive_themes: Option<Vec<AboutDriveThemes>>,
282 /// A map of source MIME type to possible targets for all supported exports.
283 #[serde(rename = "exportFormats")]
284 pub export_formats: Option<HashMap<String, Vec<String>>>,
285 /// The currently supported folder colors as RGB hex strings.
286 #[serde(rename = "folderColorPalette")]
287 pub folder_color_palette: Option<Vec<String>>,
288 /// A map of source MIME type to possible targets for all supported imports.
289 #[serde(rename = "importFormats")]
290 pub import_formats: Option<HashMap<String, Vec<String>>>,
291 /// Identifies what kind of resource this is. Value: the fixed string `"drive#about"`.
292 pub kind: Option<String>,
293 /// A map of maximum import sizes by MIME type, in bytes.
294 #[serde(rename = "maxImportSizes")]
295 #[serde_as(as = "Option<HashMap<_, serde_with::DisplayFromStr>>")]
296 pub max_import_sizes: Option<HashMap<String, i64>>,
297 /// The maximum upload size in bytes.
298 #[serde(rename = "maxUploadSize")]
299 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
300 pub max_upload_size: Option<i64>,
301 /// The user's storage quota limits and usage. For users that are part of an organization with pooled storage, information about the limit and usage across all services is for the organization, rather than the individual user. All fields are measured in bytes.
302 #[serde(rename = "storageQuota")]
303 pub storage_quota: Option<AboutStorageQuota>,
304 /// Deprecated: Use `driveThemes` instead.
305 #[serde(rename = "teamDriveThemes")]
306 pub team_drive_themes: Option<Vec<AboutTeamDriveThemes>>,
307 /// The authenticated user.
308 pub user: Option<User>,
309}
310
311impl common::ResponseResult for About {}
312
313/// Manage outstanding access proposals on a file.
314///
315/// # Activities
316///
317/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
318/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
319///
320/// * [get accessproposals](AccessproposalGetCall) (response)
321#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
322#[serde_with::serde_as]
323#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
324pub struct AccessProposal {
325 /// The creation time.
326 #[serde(rename = "createTime")]
327 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
328 /// The file ID that the proposal for access is on.
329 #[serde(rename = "fileId")]
330 pub file_id: Option<String>,
331 /// The ID of the access proposal.
332 #[serde(rename = "proposalId")]
333 pub proposal_id: Option<String>,
334 /// The email address of the user that will receive permissions, if accepted.
335 #[serde(rename = "recipientEmailAddress")]
336 pub recipient_email_address: Option<String>,
337 /// The message that the requester added to the proposal.
338 #[serde(rename = "requestMessage")]
339 pub request_message: Option<String>,
340 /// The email address of the requesting user.
341 #[serde(rename = "requesterEmailAddress")]
342 pub requester_email_address: Option<String>,
343 /// A wrapper for the role and view of an access proposal. For more information, see [Roles and permissions](https://developers.google.com/workspace/drive/api/guides/ref-roles).
344 #[serde(rename = "rolesAndViews")]
345 pub roles_and_views: Option<Vec<AccessProposalRoleAndView>>,
346}
347
348impl common::Resource for AccessProposal {}
349impl common::ResponseResult for AccessProposal {}
350
351/// A wrapper for the role and view of an access proposal. For more information, see [Roles and permissions](https://developers.google.com/workspace/drive/api/guides/ref-roles).
352///
353/// This type is not used in any activity, and only used as *part* of another schema.
354///
355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
356#[serde_with::serde_as]
357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
358pub struct AccessProposalRoleAndView {
359 /// The role that was proposed by the requester. The supported values are: * `writer` * `commenter` * `reader`
360 pub role: Option<String>,
361 /// Indicates the view for this access proposal. Only populated for proposals that belong to a view. Only `published` is supported.
362 pub view: Option<String>,
363}
364
365impl common::Part for AccessProposalRoleAndView {}
366
367/// The `apps` resource provides a list of 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.
368///
369/// # Activities
370///
371/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
372/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
373///
374/// * [get apps](AppGetCall) (response)
375/// * [list apps](AppListCall) (none)
376#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
377#[serde_with::serde_as]
378#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
379pub struct App {
380 /// Whether the app is authorized to access data on the user's Drive.
381 pub authorized: Option<bool>,
382 /// The template URL to create a file with this app in a given folder. The template contains the {folderId} to be replaced by the folder ID house the new file.
383 #[serde(rename = "createInFolderTemplate")]
384 pub create_in_folder_template: Option<String>,
385 /// The URL to create a file with this app.
386 #[serde(rename = "createUrl")]
387 pub create_url: Option<String>,
388 /// Whether the app has Drive-wide scope. An app with Drive-wide scope can access all files in the user's Drive.
389 #[serde(rename = "hasDriveWideScope")]
390 pub has_drive_wide_scope: Option<bool>,
391 /// The various icons for the app.
392 pub icons: Option<Vec<AppIcons>>,
393 /// The ID of the app.
394 pub id: Option<String>,
395 /// Whether the app is installed.
396 pub installed: Option<bool>,
397 /// Output only. Identifies what kind of resource this is. Value: the fixed string "drive#app".
398 pub kind: Option<String>,
399 /// A long description of the app.
400 #[serde(rename = "longDescription")]
401 pub long_description: Option<String>,
402 /// The name of the app.
403 pub name: Option<String>,
404 /// The type of object this app creates such as a Chart. If empty, the app name should be used instead.
405 #[serde(rename = "objectType")]
406 pub object_type: Option<String>,
407 /// The template URL for opening files with this app. The template contains {ids} or {exportIds} to be replaced by the actual file IDs. For more information, see Open Files for the full documentation.
408 #[serde(rename = "openUrlTemplate")]
409 pub open_url_template: Option<String>,
410 /// The list of primary file extensions.
411 #[serde(rename = "primaryFileExtensions")]
412 pub primary_file_extensions: Option<Vec<String>>,
413 /// The list of primary MIME types.
414 #[serde(rename = "primaryMimeTypes")]
415 pub primary_mime_types: Option<Vec<String>>,
416 /// The ID of the product listing for this app.
417 #[serde(rename = "productId")]
418 pub product_id: Option<String>,
419 /// A link to the product listing for this app.
420 #[serde(rename = "productUrl")]
421 pub product_url: Option<String>,
422 /// The list of secondary file extensions.
423 #[serde(rename = "secondaryFileExtensions")]
424 pub secondary_file_extensions: Option<Vec<String>>,
425 /// The list of secondary MIME types.
426 #[serde(rename = "secondaryMimeTypes")]
427 pub secondary_mime_types: Option<Vec<String>>,
428 /// A short description of the app.
429 #[serde(rename = "shortDescription")]
430 pub short_description: Option<String>,
431 /// Whether this app supports creating objects.
432 #[serde(rename = "supportsCreate")]
433 pub supports_create: Option<bool>,
434 /// Whether this app supports importing from Google Docs.
435 #[serde(rename = "supportsImport")]
436 pub supports_import: Option<bool>,
437 /// Whether this app supports opening more than one file.
438 #[serde(rename = "supportsMultiOpen")]
439 pub supports_multi_open: Option<bool>,
440 /// Whether this app supports creating files when offline.
441 #[serde(rename = "supportsOfflineCreate")]
442 pub supports_offline_create: Option<bool>,
443 /// Whether the app is selected as the default handler for the types it supports.
444 #[serde(rename = "useByDefault")]
445 pub use_by_default: Option<bool>,
446}
447
448impl common::Resource for App {}
449impl common::ResponseResult for App {}
450
451/// There is no detailed description.
452///
453/// This type is not used in any activity, and only used as *part* of another schema.
454///
455#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
456#[serde_with::serde_as]
457#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
458pub struct AppIcons {
459 /// Category of the icon. Allowed values are: * `application` - The icon for the application. * `document` - The icon for a file associated with the app. * `documentShared` - The icon for a shared file associated with the app.
460 pub category: Option<String>,
461 /// URL for the icon.
462 #[serde(rename = "iconUrl")]
463 pub icon_url: Option<String>,
464 /// Size of the icon. Represented as the maximum of the width and height.
465 pub size: Option<i32>,
466}
467
468impl common::Part for AppIcons {}
469
470/// A list of third-party applications which the user has installed or given access to Google Drive.
471///
472/// # Activities
473///
474/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
475/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
476///
477/// * [list apps](AppListCall) (response)
478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
479#[serde_with::serde_as]
480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
481pub struct AppList {
482 /// The list of app IDs that the user has specified to use by default. The list is in reverse-priority order (lowest to highest).
483 #[serde(rename = "defaultAppIds")]
484 pub default_app_ids: Option<Vec<String>>,
485 /// The list of apps.
486 pub items: Option<Vec<App>>,
487 /// Output only. Identifies what kind of resource this is. Value: the fixed string "drive#appList".
488 pub kind: Option<String>,
489 /// A link back to this list.
490 #[serde(rename = "selfLink")]
491 pub self_link: Option<String>,
492}
493
494impl common::ResponseResult for AppList {}
495
496/// Metadata for an approval. An approval is a review/approve process for a Drive item.
497///
498/// # Activities
499///
500/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
501/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
502///
503/// * [get approvals](ApprovalGetCall) (response)
504/// * [list approvals](ApprovalListCall) (none)
505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
506#[serde_with::serde_as]
507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
508pub struct Approval {
509 /// The Approval ID.
510 #[serde(rename = "approvalId")]
511 pub approval_id: Option<String>,
512 /// Output only. The time time the approval was completed.
513 #[serde(rename = "completeTime")]
514 pub complete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
515 /// Output only. The time the approval was created.
516 #[serde(rename = "createTime")]
517 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
518 /// The time that the approval is due.
519 #[serde(rename = "dueTime")]
520 pub due_time: Option<chrono::DateTime<chrono::offset::Utc>>,
521 /// The user that requested the Approval.
522 pub initiator: Option<User>,
523 /// This is always drive#approval.
524 pub kind: Option<String>,
525 /// Output only. The most recent time the approval was modified.
526 #[serde(rename = "modifyTime")]
527 pub modify_time: Option<chrono::DateTime<chrono::offset::Utc>>,
528 /// The responses made on the Approval by reviewers.
529 #[serde(rename = "reviewerResponses")]
530 pub reviewer_responses: Option<Vec<ReviewerResponse>>,
531 /// Output only. The status of the approval at the time this resource was requested.
532 pub status: Option<String>,
533 /// Target file id of the approval.
534 #[serde(rename = "targetFileId")]
535 pub target_file_id: Option<String>,
536}
537
538impl common::Resource for Approval {}
539impl common::ResponseResult for Approval {}
540
541/// The response of an Approvals list request.
542///
543/// # Activities
544///
545/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
546/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
547///
548/// * [list approvals](ApprovalListCall) (response)
549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
550#[serde_with::serde_as]
551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
552pub struct ApprovalList {
553 /// The list of Approvals. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
554 pub items: Option<Vec<Approval>>,
555 /// This is always drive#approvalList
556 pub kind: Option<String>,
557 /// The page token for the next page of Approvals. This will be absent if the end of the Approvals 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.
558 #[serde(rename = "nextPageToken")]
559 pub next_page_token: Option<String>,
560}
561
562impl common::ResponseResult for ApprovalList {}
563
564/// A change to a file or shared drive.
565///
566/// # Activities
567///
568/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
569/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
570///
571/// * [get start page token changes](ChangeGetStartPageTokenCall) (none)
572/// * [list changes](ChangeListCall) (none)
573/// * [watch changes](ChangeWatchCall) (none)
574#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
575#[serde_with::serde_as]
576#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
577pub struct Change {
578 /// The type of the change. Possible values are `file` and `drive`.
579 #[serde(rename = "changeType")]
580 pub change_type: Option<String>,
581 /// 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.
582 pub drive: Option<Drive>,
583 /// The ID of the shared drive associated with this change.
584 #[serde(rename = "driveId")]
585 pub drive_id: Option<String>,
586 /// The updated state of the file. Present if the type is file and the file has not been removed from this list of changes.
587 pub file: Option<File>,
588 /// The ID of the file which has changed.
589 #[serde(rename = "fileId")]
590 pub file_id: Option<String>,
591 /// Identifies what kind of resource this is. Value: the fixed string `"drive#change"`.
592 pub kind: Option<String>,
593 /// Whether the file or shared drive has been removed from this list of changes, for example by deletion or loss of access.
594 pub removed: Option<bool>,
595 /// Deprecated: Use `drive` instead.
596 #[serde(rename = "teamDrive")]
597 pub team_drive: Option<TeamDrive>,
598 /// Deprecated: Use `driveId` instead.
599 #[serde(rename = "teamDriveId")]
600 pub team_drive_id: Option<String>,
601 /// The time of this change (RFC 3339 date-time).
602 pub time: Option<chrono::DateTime<chrono::offset::Utc>>,
603 /// Deprecated: Use `changeType` instead.
604 #[serde(rename = "type")]
605 pub type_: Option<String>,
606}
607
608impl common::Resource for Change {}
609
610/// A list of changes for a user.
611///
612/// # Activities
613///
614/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
615/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
616///
617/// * [list changes](ChangeListCall) (response)
618#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
619#[serde_with::serde_as]
620#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
621pub struct ChangeList {
622 /// The list of changes. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
623 pub changes: Option<Vec<Change>>,
624 /// Identifies what kind of resource this is. Value: the fixed string `"drive#changeList"`.
625 pub kind: Option<String>,
626 /// The starting page token for future changes. This will be present only if the end of the current changes list has been reached. The page token doesn't expire.
627 #[serde(rename = "newStartPageToken")]
628 pub new_start_page_token: Option<String>,
629 /// The page token for the next page of changes. This will be absent if the end of the changes list has been reached. The page token doesn't expire.
630 #[serde(rename = "nextPageToken")]
631 pub next_page_token: Option<String>,
632}
633
634impl common::ResponseResult for ChangeList {}
635
636/// A notification channel used to watch for resource changes.
637///
638/// # Activities
639///
640/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
641/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
642///
643/// * [watch changes](ChangeWatchCall) (request|response)
644/// * [stop channels](ChannelStopCall) (request)
645/// * [watch files](FileWatchCall) (request|response)
646#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
647#[serde_with::serde_as]
648#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
649pub struct Channel {
650 /// The address where notifications are delivered for this channel.
651 pub address: Option<String>,
652 /// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.
653 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
654 pub expiration: Option<i64>,
655 /// A UUID or similar unique string that identifies this channel.
656 pub id: Option<String>,
657 /// Identifies this as a notification channel used to watch for changes to a resource, which is `api#channel`.
658 pub kind: Option<String>,
659 /// Additional parameters controlling delivery channel behavior. Optional.
660 pub params: Option<HashMap<String, String>>,
661 /// A Boolean value to indicate whether payload is wanted. Optional.
662 pub payload: Option<bool>,
663 /// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.
664 #[serde(rename = "resourceId")]
665 pub resource_id: Option<String>,
666 /// A version-specific identifier for the watched resource.
667 #[serde(rename = "resourceUri")]
668 pub resource_uri: Option<String>,
669 /// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.
670 pub token: Option<String>,
671 /// The type of delivery mechanism used for this channel. Valid values are "web_hook" or "webhook".
672 #[serde(rename = "type")]
673 pub type_: Option<String>,
674}
675
676impl common::RequestValue for Channel {}
677impl common::Resource for Channel {}
678impl common::ResponseResult for Channel {}
679
680/// A comment on a file. Some resource methods (such as `comments.update`) require a `commentId`. Use the `comments.list` method to retrieve the ID for a comment in a file.
681///
682/// # Activities
683///
684/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
685/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
686///
687/// * [create comments](CommentCreateCall) (request|response)
688/// * [delete comments](CommentDeleteCall) (none)
689/// * [get comments](CommentGetCall) (response)
690/// * [list comments](CommentListCall) (none)
691/// * [update comments](CommentUpdateCall) (request|response)
692#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
693#[serde_with::serde_as]
694#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
695pub struct Comment {
696 /// 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).
697 pub anchor: Option<String>,
698 /// Output only. The email address of the user assigned to this comment. If no user is assigned, the field is unset.
699 #[serde(rename = "assigneeEmailAddress")]
700 pub assignee_email_address: Option<String>,
701 /// Output only. The author of the comment. The author's email address and permission ID will not be populated.
702 pub author: Option<User>,
703 /// The plain text content of the comment. This field is used for setting the content, while `htmlContent` should be displayed.
704 pub content: Option<String>,
705 /// The time at which the comment was created (RFC 3339 date-time).
706 #[serde(rename = "createdTime")]
707 pub created_time: Option<chrono::DateTime<chrono::offset::Utc>>,
708 /// Output only. Whether the comment has been deleted. A deleted comment has no content.
709 pub deleted: Option<bool>,
710 /// Output only. The content of the comment with HTML formatting.
711 #[serde(rename = "htmlContent")]
712 pub html_content: Option<String>,
713 /// Output only. The ID of the comment.
714 pub id: Option<String>,
715 /// Output only. Identifies what kind of resource this is. Value: the fixed string `"drive#comment"`.
716 pub kind: Option<String>,
717 /// Output only. A list of email addresses for users mentioned in this comment. If no users are mentioned, the list is empty.
718 #[serde(rename = "mentionedEmailAddresses")]
719 pub mentioned_email_addresses: Option<Vec<String>>,
720 /// The last time the comment or any of its replies was modified (RFC 3339 date-time).
721 #[serde(rename = "modifiedTime")]
722 pub modified_time: Option<chrono::DateTime<chrono::offset::Utc>>,
723 /// The file content to which the comment refers, typically within the anchor region. For a text file, for example, this would be the text at the location of the comment.
724 #[serde(rename = "quotedFileContent")]
725 pub quoted_file_content: Option<CommentQuotedFileContent>,
726 /// Output only. The full list of replies to the comment in chronological order.
727 pub replies: Option<Vec<Reply>>,
728 /// Output only. Whether the comment has been resolved by one of its replies.
729 pub resolved: Option<bool>,
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.
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 comments: Option<Vec<Comment>>,
750 /// Identifies what kind of resource this is. Value: the fixed string `"drive#commentList"`.
751 pub kind: Option<String>,
752 /// 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. The page token is typically valid for several hours. However, if new items are added or removed, your expected results might differ.
753 #[serde(rename = "nextPageToken")]
754 pub next_page_token: Option<String>,
755}
756
757impl common::ResponseResult for CommentList {}
758
759/// A restriction for accessing the content of the file.
760///
761/// This type is not used in any activity, and only used as *part* of another schema.
762///
763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
764#[serde_with::serde_as]
765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
766pub struct ContentRestriction {
767 /// 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.
768 #[serde(rename = "ownerRestricted")]
769 pub owner_restricted: Option<bool>,
770 /// 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.
771 #[serde(rename = "readOnly")]
772 pub read_only: Option<bool>,
773 /// Reason for why the content of the file is restricted. This is only mutable on requests that also set `readOnly=true`.
774 pub reason: Option<String>,
775 /// Output only. The user who set the content restriction. Only populated if `readOnly=true`.
776 #[serde(rename = "restrictingUser")]
777 pub restricting_user: Option<User>,
778 /// The time at which the content restriction was set (formatted RFC 3339 timestamp). Only populated if readOnly is true.
779 #[serde(rename = "restrictionTime")]
780 pub restriction_time: Option<chrono::DateTime<chrono::offset::Utc>>,
781 /// 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.
782 #[serde(rename = "systemRestricted")]
783 pub system_restricted: Option<bool>,
784 /// Output only. The type of the content restriction. Currently the only possible value is `globalContentRestriction`.
785 #[serde(rename = "type")]
786 pub type_: Option<String>,
787}
788
789impl common::Part for ContentRestriction {}
790
791/// A restriction for copy and download of the file.
792///
793/// This type is not used in any activity, and only used as *part* of another schema.
794///
795#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
796#[serde_with::serde_as]
797#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
798pub struct DownloadRestriction {
799 /// Whether download and copy is restricted for readers.
800 #[serde(rename = "restrictedForReaders")]
801 pub restricted_for_readers: Option<bool>,
802 /// Whether download and copy is restricted for writers. If `true`, download is also restricted for readers.
803 #[serde(rename = "restrictedForWriters")]
804 pub restricted_for_writers: Option<bool>,
805}
806
807impl common::Part for DownloadRestriction {}
808
809/// Download restrictions applied to the file.
810///
811/// This type is not used in any activity, and only used as *part* of another schema.
812///
813#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
814#[serde_with::serde_as]
815#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
816pub struct DownloadRestrictionsMetadata {
817 /// Output only. The effective download restriction applied to this file. This considers all restriction settings and DLP rules.
818 #[serde(rename = "effectiveDownloadRestrictionWithContext")]
819 pub effective_download_restriction_with_context: Option<DownloadRestriction>,
820 /// The download restriction of the file applied directly by the owner or organizer. This doesn't take into account shared drive settings or DLP rules.
821 #[serde(rename = "itemDownloadRestriction")]
822 pub item_download_restriction: Option<DownloadRestriction>,
823}
824
825impl common::Part for DownloadRestrictionsMetadata {}
826
827/// 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.
828///
829/// # Activities
830///
831/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
832/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
833///
834/// * [create drives](DriveCreateCall) (request|response)
835/// * [delete drives](DriveDeleteCall) (none)
836/// * [get drives](DriveGetCall) (response)
837/// * [hide drives](DriveHideCall) (response)
838/// * [list drives](DriveListCall) (none)
839/// * [unhide drives](DriveUnhideCall) (response)
840/// * [update drives](DriveUpdateCall) (request|response)
841#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
842#[serde_with::serde_as]
843#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
844pub struct Drive {
845 /// 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.
846 #[serde(rename = "backgroundImageFile")]
847 pub background_image_file: Option<DriveBackgroundImageFile>,
848 /// Output only. A short-lived link to this shared drive's background image.
849 #[serde(rename = "backgroundImageLink")]
850 pub background_image_link: Option<String>,
851 /// Output only. Capabilities the current user has on this shared drive.
852 pub capabilities: Option<DriveCapabilities>,
853 /// 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`.
854 #[serde(rename = "colorRgb")]
855 pub color_rgb: Option<String>,
856 /// The time at which the shared drive was created (RFC 3339 date-time).
857 #[serde(rename = "createdTime")]
858 pub created_time: Option<chrono::DateTime<chrono::offset::Utc>>,
859 /// Whether the shared drive is hidden from default view.
860 pub hidden: Option<bool>,
861 /// Output only. The ID of this shared drive which is also the ID of the top level folder of this shared drive.
862 pub id: Option<String>,
863 /// Output only. Identifies what kind of resource this is. Value: the fixed string `"drive#drive"`.
864 pub kind: Option<String>,
865 /// The name of this shared drive.
866 pub name: Option<String>,
867 /// 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`.
868 #[serde(rename = "orgUnitId")]
869 pub org_unit_id: Option<String>,
870 /// A set of restrictions that apply to this shared drive or items inside this shared drive. Note that restrictions can't be set when creating a shared drive. To add a restriction, first create a shared drive and then use `drives.update` to add restrictions.
871 pub restrictions: Option<DriveRestrictions>,
872 /// The ID of the theme from which the background image and color will be set. The set of possible `driveThemes` can be retrieved from a `drive.about.get` response. When not specified on a `drive.drives.create` request, a random theme is chosen from which the background image and color are set. This is a write-only field; it can only be set on requests that don't set `colorRgb` or `backgroundImageFile`.
873 #[serde(rename = "themeId")]
874 pub theme_id: Option<String>,
875}
876
877impl common::RequestValue for Drive {}
878impl common::Resource for Drive {}
879impl common::ResponseResult for Drive {}
880
881/// A list of shared drives.
882///
883/// # Activities
884///
885/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
886/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
887///
888/// * [list drives](DriveListCall) (response)
889#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
890#[serde_with::serde_as]
891#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
892pub struct DriveList {
893 /// The list of shared drives. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
894 pub drives: Option<Vec<Drive>>,
895 /// Identifies what kind of resource this is. Value: the fixed string `"drive#driveList"`.
896 pub kind: Option<String>,
897 /// 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. The page token is typically valid for several hours. However, if new items are added or removed, your expected results might differ.
898 #[serde(rename = "nextPageToken")]
899 pub next_page_token: Option<String>,
900}
901
902impl common::ResponseResult for DriveList {}
903
904/// 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.
905///
906/// # Activities
907///
908/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
909/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
910///
911/// * [copy files](FileCopyCall) (request|response)
912/// * [create files](FileCreateCall) (request|response)
913/// * [delete files](FileDeleteCall) (none)
914/// * [download files](FileDownloadCall) (none)
915/// * [empty trash files](FileEmptyTrashCall) (none)
916/// * [export files](FileExportCall) (none)
917/// * [generate ids files](FileGenerateIdCall) (none)
918/// * [get files](FileGetCall) (response)
919/// * [list files](FileListCall) (none)
920/// * [list labels files](FileListLabelCall) (none)
921/// * [modify labels files](FileModifyLabelCall) (none)
922/// * [update files](FileUpdateCall) (request|response)
923/// * [watch files](FileWatchCall) (none)
924#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
925#[serde_with::serde_as]
926#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
927pub struct File {
928 /// A collection of arbitrary key-value pairs which are private to the requesting app.
929 /// Entries with null values are cleared in update and copy requests. These properties can only be retrieved using an authenticated request. An authenticated request uses an access token obtained with a OAuth 2 client ID. You cannot use an API key to retrieve private properties.
930 #[serde(rename = "appProperties")]
931 pub app_properties: Option<HashMap<String, String>>,
932 /// Output only. Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take. For more information, see [Understand file capabilities](https://developers.google.com/workspace/drive/api/guides/manage-sharing#capabilities).
933 pub capabilities: Option<FileCapabilities>,
934 /// Additional information about the content of the file. These fields are never populated in responses.
935 #[serde(rename = "contentHints")]
936 pub content_hints: Option<FileContentHints>,
937 /// Restrictions for accessing the content of the file. Only populated if such a restriction exists.
938 #[serde(rename = "contentRestrictions")]
939 pub content_restrictions: Option<Vec<ContentRestriction>>,
940 /// Whether the options to copy, print, or download this file should be disabled for readers and commenters.
941 #[serde(rename = "copyRequiresWriterPermission")]
942 pub copy_requires_writer_permission: Option<bool>,
943 /// The time at which the file was created (RFC 3339 date-time).
944 #[serde(rename = "createdTime")]
945 pub created_time: Option<chrono::DateTime<chrono::offset::Utc>>,
946 /// A short description of the file.
947 pub description: Option<String>,
948 /// Download restrictions applied on the file.
949 #[serde(rename = "downloadRestrictions")]
950 pub download_restrictions: Option<DownloadRestrictionsMetadata>,
951 /// Output only. ID of the shared drive the file resides in. Only populated for items in shared drives.
952 #[serde(rename = "driveId")]
953 pub drive_id: Option<String>,
954 /// Output only. Whether the file has been explicitly trashed, as opposed to recursively trashed from a parent folder.
955 #[serde(rename = "explicitlyTrashed")]
956 pub explicitly_trashed: Option<bool>,
957 /// Output only. Links for exporting Docs Editors files to specific formats.
958 #[serde(rename = "exportLinks")]
959 pub export_links: Option<HashMap<String, String>>,
960 /// Output only. The final component of `fullFileExtension`. This is only available for files with binary content in Google Drive.
961 #[serde(rename = "fileExtension")]
962 pub file_extension: Option<String>,
963 /// The color for a folder or a shortcut to a folder as an RGB hex string. The supported colors are published in the `folderColorPalette` field of the [`about`](https://developers.google.com/workspace/drive/api/reference/rest/v3/about) resource. If an unsupported color is specified, the closest color in the palette is used instead.
964 #[serde(rename = "folderColorRgb")]
965 pub folder_color_rgb: Option<String>,
966 /// Output only. The full file extension extracted from the `name` field. May contain multiple concatenated extensions, such as "tar.gz". This is only available for files with binary content in Google Drive. This is automatically updated when the `name` field changes, however it's not cleared if the new name doesn't contain a valid extension.
967 #[serde(rename = "fullFileExtension")]
968 pub full_file_extension: Option<String>,
969 /// Output only. Whether there are permissions directly on this file. This field is only populated for items in shared drives.
970 #[serde(rename = "hasAugmentedPermissions")]
971 pub has_augmented_permissions: Option<bool>,
972 /// Output only. Whether this file has a thumbnail. This doesn't indicate whether the requesting app has access to the thumbnail. To check access, look for the presence of the thumbnailLink field.
973 #[serde(rename = "hasThumbnail")]
974 pub has_thumbnail: Option<bool>,
975 /// Output only. The ID of the file's head revision. This is currently only available for files with binary content in Google Drive.
976 #[serde(rename = "headRevisionId")]
977 pub head_revision_id: Option<String>,
978 /// Output only. A static, unauthenticated link to the file's icon.
979 #[serde(rename = "iconLink")]
980 pub icon_link: Option<String>,
981 /// The ID of the file.
982 pub id: Option<String>,
983 /// Output only. Additional metadata about image media, if available.
984 #[serde(rename = "imageMediaMetadata")]
985 pub image_media_metadata: Option<FileImageMediaMetadata>,
986 /// Whether this file has inherited permissions disabled. Inherited permissions are enabled by default.
987 #[serde(rename = "inheritedPermissionsDisabled")]
988 pub inherited_permissions_disabled: Option<bool>,
989 /// Output only. Whether the file was created or opened by the requesting app.
990 #[serde(rename = "isAppAuthorized")]
991 pub is_app_authorized: Option<bool>,
992 /// Output only. Identifies what kind of resource this is. Value: the fixed string `"drive#file"`.
993 pub kind: Option<String>,
994 /// Output only. An overview of the labels on the file.
995 #[serde(rename = "labelInfo")]
996 pub label_info: Option<FileLabelInfo>,
997 /// Output only. The last user to modify the file. This field is only populated when the last modification was performed by a signed-in user.
998 #[serde(rename = "lastModifyingUser")]
999 pub last_modifying_user: Option<User>,
1000 /// Contains details about the link URLs that clients are using to refer to this item.
1001 #[serde(rename = "linkShareMetadata")]
1002 pub link_share_metadata: Option<FileLinkShareMetadata>,
1003 /// Output only. The MD5 checksum for the content of the file. This is only applicable to files with binary content in Google Drive.
1004 #[serde(rename = "md5Checksum")]
1005 pub md5_checksum: Option<String>,
1006 /// The MIME type of the file. Google Drive attempts to automatically detect an appropriate value from uploaded content, if no value is provided. The value cannot be changed unless a new revision is uploaded. If a file is created with a Google Doc MIME type, the uploaded content is imported, if possible. The supported import formats are published in the [`about`](https://developers.google.com/workspace/drive/api/reference/rest/v3/about) resource.
1007 #[serde(rename = "mimeType")]
1008 pub mime_type: Option<String>,
1009 /// Output only. Whether the file has been modified by this user.
1010 #[serde(rename = "modifiedByMe")]
1011 pub modified_by_me: Option<bool>,
1012 /// The last time the file was modified by the user (RFC 3339 date-time).
1013 #[serde(rename = "modifiedByMeTime")]
1014 pub modified_by_me_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1015 /// he last time the file was modified by anyone (RFC 3339 date-time). Note that setting modifiedTime will also update modifiedByMeTime for the user.
1016 #[serde(rename = "modifiedTime")]
1017 pub modified_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1018 /// The name of the file. This isn't necessarily unique within a folder. Note that for immutable items such as the top-level folders of shared drives, the My Drive root folder, and the Application Data folder, the name is constant.
1019 pub name: Option<String>,
1020 /// The original filename of the uploaded content if available, or else the original value of the `name` field. This is only available for files with binary content in Google Drive.
1021 #[serde(rename = "originalFilename")]
1022 pub original_filename: Option<String>,
1023 /// Output only. Whether the user owns the file. Not populated for items in shared drives.
1024 #[serde(rename = "ownedByMe")]
1025 pub owned_by_me: Option<bool>,
1026 /// 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.
1027 pub owners: Option<Vec<User>>,
1028 /// 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 a create 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.
1029 pub parents: Option<Vec<String>>,
1030 /// Output only. List of permission IDs for users with access to this file.
1031 #[serde(rename = "permissionIds")]
1032 pub permission_ids: Option<Vec<String>>,
1033 /// Output only. The full list of permissions for the file. This is only available if the requesting user can share the file. Not populated for items in shared drives.
1034 pub permissions: Option<Vec<Permission>>,
1035 /// A collection of arbitrary key-value pairs which are visible to all apps.
1036 /// Entries with null values are cleared in update and copy requests.
1037 pub properties: Option<HashMap<String, String>>,
1038 /// Output only. The number of storage quota bytes used by the file. This includes the head revision as well as previous revisions with `keepForever` enabled.
1039 #[serde(rename = "quotaBytesUsed")]
1040 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1041 pub quota_bytes_used: Option<i64>,
1042 /// Output only. A key needed to access the item via a shared link.
1043 #[serde(rename = "resourceKey")]
1044 pub resource_key: Option<String>,
1045 /// 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's not populated for Docs Editors or shortcut files.
1046 #[serde(rename = "sha1Checksum")]
1047 pub sha1_checksum: Option<String>,
1048 /// 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's not populated for Docs Editors or shortcut files.
1049 #[serde(rename = "sha256Checksum")]
1050 pub sha256_checksum: Option<String>,
1051 /// Output only. Whether the file has been shared. Not populated for items in shared drives.
1052 pub shared: Option<bool>,
1053 /// The time at which the file was shared with the user, if applicable (RFC 3339 date-time).
1054 #[serde(rename = "sharedWithMeTime")]
1055 pub shared_with_me_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1056 /// Output only. The user who shared the file with the requesting user, if applicable.
1057 #[serde(rename = "sharingUser")]
1058 pub sharing_user: Option<User>,
1059 /// 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.create` requests.
1060 #[serde(rename = "shortcutDetails")]
1061 pub shortcut_details: Option<FileShortcutDetails>,
1062 /// Output only. Size in bytes of blobs and Google Workspace editor files. Won't be populated for files that have no size, like shortcuts and folders.
1063 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1064 pub size: Option<i64>,
1065 /// Output only. The list of spaces which contain the file. The currently supported values are `drive`, `appDataFolder`, and `photos`.
1066 pub spaces: Option<Vec<String>>,
1067 /// Whether the user has starred the file.
1068 pub starred: Option<bool>,
1069 /// Deprecated: Output only. Use `driveId` instead.
1070 #[serde(rename = "teamDriveId")]
1071 pub team_drive_id: Option<String>,
1072 /// 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) policies. 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.
1073 #[serde(rename = "thumbnailLink")]
1074 pub thumbnail_link: Option<String>,
1075 /// Output only. The thumbnail version for use in thumbnail cache invalidation.
1076 #[serde(rename = "thumbnailVersion")]
1077 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1078 pub thumbnail_version: Option<i64>,
1079 /// Whether the file has been trashed, either explicitly or from a trashed parent folder. Only the owner may trash a file, and other users cannot see files in the owner's trash.
1080 pub trashed: Option<bool>,
1081 /// The time that the item was trashed (RFC 3339 date-time). Only populated for items in shared drives.
1082 #[serde(rename = "trashedTime")]
1083 pub trashed_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1084 /// Output only. If the file has been explicitly trashed, the user who trashed it. Only populated for items in shared drives.
1085 #[serde(rename = "trashingUser")]
1086 pub trashing_user: Option<User>,
1087 /// 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 user.
1088 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1089 pub version: Option<i64>,
1090 /// Output only. Additional metadata about video media. This may not be available immediately upon upload.
1091 #[serde(rename = "videoMediaMetadata")]
1092 pub video_media_metadata: Option<FileVideoMediaMetadata>,
1093 /// Output only. Whether the file has been viewed by this user.
1094 #[serde(rename = "viewedByMe")]
1095 pub viewed_by_me: Option<bool>,
1096 /// The last time the file was viewed by the user (RFC 3339 date-time).
1097 #[serde(rename = "viewedByMeTime")]
1098 pub viewed_by_me_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1099 /// Deprecated: Use `copyRequiresWriterPermission` instead.
1100 #[serde(rename = "viewersCanCopyContent")]
1101 pub viewers_can_copy_content: Option<bool>,
1102 /// Output only. A link for downloading the content of the file in a browser. This is only available for files with binary content in Google Drive.
1103 #[serde(rename = "webContentLink")]
1104 pub web_content_link: Option<String>,
1105 /// Output only. A link for opening the file in a relevant Google editor or viewer in a browser.
1106 #[serde(rename = "webViewLink")]
1107 pub web_view_link: Option<String>,
1108 /// Whether users with only `writer` permission can modify the file's permissions. Not populated for items in shared drives.
1109 #[serde(rename = "writersCanShare")]
1110 pub writers_can_share: Option<bool>,
1111}
1112
1113impl common::RequestValue for File {}
1114impl common::Resource for File {}
1115impl common::ResponseResult for File {}
1116
1117/// A list of files.
1118///
1119/// # Activities
1120///
1121/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1122/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1123///
1124/// * [list files](FileListCall) (response)
1125#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1126#[serde_with::serde_as]
1127#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1128pub struct FileList {
1129 /// The list of files. If `nextPageToken` is populated, then this list may be incomplete and an additional page of results should be fetched.
1130 pub files: Option<Vec<File>>,
1131 /// Whether the search process was incomplete. If true, then some search results might be missing, since all documents were not searched. This can occur when searching multiple drives with the `allDrives` corpora, but all corpora couldn't be searched. When this happens, it's suggested that clients narrow their query by choosing a different corpus such as `user` or `drive`.
1132 #[serde(rename = "incompleteSearch")]
1133 pub incomplete_search: Option<bool>,
1134 /// Identifies what kind of resource this is. Value: the fixed string `"drive#fileList"`.
1135 pub kind: Option<String>,
1136 /// 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. The page token is typically valid for several hours. However, if new items are added or removed, your expected results might differ.
1137 #[serde(rename = "nextPageToken")]
1138 pub next_page_token: Option<String>,
1139}
1140
1141impl common::ResponseResult for FileList {}
1142
1143/// A list of generated file IDs which can be provided in create requests.
1144///
1145/// # Activities
1146///
1147/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1148/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1149///
1150/// * [generate ids files](FileGenerateIdCall) (response)
1151#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1152#[serde_with::serde_as]
1153#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1154pub struct GeneratedIds {
1155 /// The IDs generated for the requesting user in the specified space.
1156 pub ids: Option<Vec<String>>,
1157 /// Identifies what kind of resource this is. Value: the fixed string `"drive#generatedIds"`.
1158 pub kind: Option<String>,
1159 /// The type of file that can be created with these IDs.
1160 pub space: Option<String>,
1161}
1162
1163impl common::ResponseResult for GeneratedIds {}
1164
1165/// Representation of label and label fields.
1166///
1167/// This type is not used in any activity, and only used as *part* of another schema.
1168///
1169#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1170#[serde_with::serde_as]
1171#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1172pub struct Label {
1173 /// A map of the fields on the label, keyed by the field's ID.
1174 pub fields: Option<HashMap<String, LabelField>>,
1175 /// The ID of the label.
1176 pub id: Option<String>,
1177 /// This is always drive#label
1178 pub kind: Option<String>,
1179 /// The revision ID of the label.
1180 #[serde(rename = "revisionId")]
1181 pub revision_id: Option<String>,
1182}
1183
1184impl common::Part for Label {}
1185
1186/// Representation of field, which is a typed key-value pair.
1187///
1188/// This type is not used in any activity, and only used as *part* of another schema.
1189///
1190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1191#[serde_with::serde_as]
1192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1193pub struct LabelField {
1194 /// Only present if valueType is dateString. RFC 3339 formatted date: YYYY-MM-DD.
1195 #[serde(rename = "dateString")]
1196 pub date_string: Option<Vec<chrono::NaiveDate>>,
1197 /// The identifier of this label field.
1198 pub id: Option<String>,
1199 /// Only present if `valueType` is `integer`.
1200 #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
1201 pub integer: Option<Vec<i64>>,
1202 /// This is always drive#labelField.
1203 pub kind: Option<String>,
1204 /// Only present if `valueType` is `selection`
1205 pub selection: Option<Vec<String>>,
1206 /// Only present if `valueType` is `text`.
1207 pub text: Option<Vec<String>>,
1208 /// Only present if `valueType` is `user`.
1209 pub user: Option<Vec<User>>,
1210 /// The field type. While new values may be supported in the future, the following are currently allowed: * `dateString` * `integer` * `selection` * `text` * `user`
1211 #[serde(rename = "valueType")]
1212 pub value_type: Option<String>,
1213}
1214
1215impl common::Part for LabelField {}
1216
1217/// A modification to a label's field.
1218///
1219/// This type is not used in any activity, and only used as *part* of another schema.
1220///
1221#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1222#[serde_with::serde_as]
1223#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1224pub struct LabelFieldModification {
1225 /// The ID of the field to be modified.
1226 #[serde(rename = "fieldId")]
1227 pub field_id: Option<String>,
1228 /// This is always `"drive#labelFieldModification"`.
1229 pub kind: Option<String>,
1230 /// 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.
1231 #[serde(rename = "setDateValues")]
1232 pub set_date_values: Option<Vec<chrono::NaiveDate>>,
1233 /// Replaces the value of an `integer` field with these new values.
1234 #[serde(rename = "setIntegerValues")]
1235 #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
1236 pub set_integer_values: Option<Vec<i64>>,
1237 /// Replaces a `selection` field with these new values.
1238 #[serde(rename = "setSelectionValues")]
1239 pub set_selection_values: Option<Vec<String>>,
1240 /// Sets the value of a `text` field.
1241 #[serde(rename = "setTextValues")]
1242 pub set_text_values: Option<Vec<String>>,
1243 /// Replaces a `user` field with these new values. The values must be a valid email addresses.
1244 #[serde(rename = "setUserValues")]
1245 pub set_user_values: Option<Vec<String>>,
1246 /// Unsets the values for this field.
1247 #[serde(rename = "unsetValues")]
1248 pub unset_values: Option<bool>,
1249}
1250
1251impl common::Part for LabelFieldModification {}
1252
1253/// A list of labels applied to a file.
1254///
1255/// # Activities
1256///
1257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1259///
1260/// * [list labels files](FileListLabelCall) (response)
1261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1262#[serde_with::serde_as]
1263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1264pub struct LabelList {
1265 /// This is always `"drive#labelList"`.
1266 pub kind: Option<String>,
1267 /// The list of labels.
1268 pub labels: Option<Vec<Label>>,
1269 /// 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. The page token is typically valid for several hours. However, if new items are added or removed, your expected results might differ.
1270 #[serde(rename = "nextPageToken")]
1271 pub next_page_token: Option<String>,
1272}
1273
1274impl common::ResponseResult for LabelList {}
1275
1276/// 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.
1277///
1278/// This type is not used in any activity, and only used as *part* of another schema.
1279///
1280#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1281#[serde_with::serde_as]
1282#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1283pub struct LabelModification {
1284 /// The list of modifications to this label's fields.
1285 #[serde(rename = "fieldModifications")]
1286 pub field_modifications: Option<Vec<LabelFieldModification>>,
1287 /// This is always `"drive#labelModification"`.
1288 pub kind: Option<String>,
1289 /// The ID of the label to modify.
1290 #[serde(rename = "labelId")]
1291 pub label_id: Option<String>,
1292 /// If true, the label will be removed from the file.
1293 #[serde(rename = "removeLabel")]
1294 pub remove_label: Option<bool>,
1295}
1296
1297impl common::Part for LabelModification {}
1298
1299/// The response to an access proposal list request.
1300///
1301/// # Activities
1302///
1303/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1304/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1305///
1306/// * [list accessproposals](AccessproposalListCall) (response)
1307#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1308#[serde_with::serde_as]
1309#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1310pub struct ListAccessProposalsResponse {
1311 /// The list of access proposals. This field is only populated in Drive API v3.
1312 #[serde(rename = "accessProposals")]
1313 pub access_proposals: Option<Vec<AccessProposal>>,
1314 /// The continuation token for the next page of results. This will be absent if the end of the results 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.
1315 #[serde(rename = "nextPageToken")]
1316 pub next_page_token: Option<String>,
1317}
1318
1319impl common::ResponseResult for ListAccessProposalsResponse {}
1320
1321/// 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.
1322///
1323/// # Activities
1324///
1325/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1326/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1327///
1328/// * [modify labels files](FileModifyLabelCall) (request)
1329#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1330#[serde_with::serde_as]
1331#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1332pub struct ModifyLabelsRequest {
1333 /// This is always `"drive#modifyLabelsRequest"`.
1334 pub kind: Option<String>,
1335 /// The list of modifications to apply to the labels on the file.
1336 #[serde(rename = "labelModifications")]
1337 pub label_modifications: Option<Vec<LabelModification>>,
1338}
1339
1340impl common::RequestValue for ModifyLabelsRequest {}
1341
1342/// Response to a `ModifyLabels` request. This contains only those labels which were added or updated by the request.
1343///
1344/// # Activities
1345///
1346/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1347/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1348///
1349/// * [modify labels files](FileModifyLabelCall) (response)
1350#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1351#[serde_with::serde_as]
1352#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1353pub struct ModifyLabelsResponse {
1354 /// This is always `"drive#modifyLabelsResponse"`.
1355 pub kind: Option<String>,
1356 /// The list of labels which were added or updated by the request.
1357 #[serde(rename = "modifiedLabels")]
1358 pub modified_labels: Option<Vec<Label>>,
1359}
1360
1361impl common::ResponseResult for ModifyLabelsResponse {}
1362
1363/// This resource represents a long-running operation that is the result of a network API call.
1364///
1365/// # Activities
1366///
1367/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1368/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1369///
1370/// * [download files](FileDownloadCall) (response)
1371/// * [get operations](OperationGetCall) (response)
1372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1373#[serde_with::serde_as]
1374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1375pub struct Operation {
1376 /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
1377 pub done: Option<bool>,
1378 /// The error result of the operation in case of failure or cancellation.
1379 pub error: Option<Status>,
1380 /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
1381 pub metadata: Option<HashMap<String, serde_json::Value>>,
1382 /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
1383 pub name: Option<String>,
1384 /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
1385 pub response: Option<HashMap<String, serde_json::Value>>,
1386}
1387
1388impl common::Resource for Operation {}
1389impl common::ResponseResult for Operation {}
1390
1391/// A permission for a file. A permission grants a user, group, domain, or the world access to a file or a folder hierarchy. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing). By default, permission requests only return a subset of fields. Permission `kind`, `ID`, `type`, and `role` are always returned. To retrieve specific fields, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter). 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.
1392///
1393/// # Activities
1394///
1395/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1396/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1397///
1398/// * [create permissions](PermissionCreateCall) (request|response)
1399/// * [delete permissions](PermissionDeleteCall) (none)
1400/// * [get permissions](PermissionGetCall) (response)
1401/// * [list permissions](PermissionListCall) (none)
1402/// * [update permissions](PermissionUpdateCall) (request|response)
1403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1404#[serde_with::serde_as]
1405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1406pub struct Permission {
1407 /// Whether the permission allows the file to be discovered through search. This is only applicable for permissions of type `domain` or `anyone`.
1408 #[serde(rename = "allowFileDiscovery")]
1409 pub allow_file_discovery: Option<bool>,
1410 /// Output only. Whether the account associated with this permission has been deleted. This field only pertains to permissions of type `user` or `group`.
1411 pub deleted: Option<bool>,
1412 /// Output only. The "pretty" name of the value of the permission. The following is a list of examples for each type of permission: * `user` - User's full name, as defined for their Google Account, such as "Dana A." * `group` - Name of the Google Group, such as "The Company Administrators." * `domain` - String domain name, such as "cymbalgroup.com." * `anyone` - No `displayName` is present.
1413 #[serde(rename = "displayName")]
1414 pub display_name: Option<String>,
1415 /// The domain to which this permission refers.
1416 pub domain: Option<String>,
1417 /// The email address of the user or group to which this permission refers.
1418 #[serde(rename = "emailAddress")]
1419 pub email_address: Option<String>,
1420 /// The time at which this permission will expire (RFC 3339 date-time). Expiration times have the following restrictions: - They can only be set on user and group permissions - The time must be in the future - The time cannot be more than a year in the future
1421 #[serde(rename = "expirationTime")]
1422 pub expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1423 /// Output only. The ID of this permission. This is a unique identifier for the grantee, and is published in the [User resource](https://developers.google.com/workspace/drive/api/reference/rest/v3/User) as `permissionId`. IDs should be treated as opaque values.
1424 pub id: Option<String>,
1425 /// When `true`, only organizers, owners, and users with permissions added directly on the item can access it.
1426 #[serde(rename = "inheritedPermissionsDisabled")]
1427 pub inherited_permissions_disabled: Option<bool>,
1428 /// Output only. Identifies what kind of resource this is. Value: the fixed string `"drive#permission"`.
1429 pub kind: Option<String>,
1430 /// Whether the account associated with this permission is a pending owner. Only populated for permissions of type `user` for files that aren't in a shared drive.
1431 #[serde(rename = "pendingOwner")]
1432 pub pending_owner: Option<bool>,
1433 /// Output only. Details of whether the permissions on this item are inherited or are directly on this item.
1434 #[serde(rename = "permissionDetails")]
1435 pub permission_details: Option<Vec<PermissionPermissionDetails>>,
1436 /// Output only. A link to the user's profile photo, if available.
1437 #[serde(rename = "photoLink")]
1438 pub photo_link: Option<String>,
1439 /// The role granted by this permission. Supported values include: * `owner` * `organizer` * `fileOrganizer` * `writer` * `commenter` * `reader` For more information, see [Roles and permissions](https://developers.google.com/workspace/drive/api/guides/ref-roles).
1440 pub role: Option<String>,
1441 /// Output only. Deprecated: Output only. Use `permissionDetails` instead.
1442 #[serde(rename = "teamDrivePermissionDetails")]
1443 pub team_drive_permission_details: Option<Vec<PermissionTeamDrivePermissionDetails>>,
1444 /// The type of the grantee. Supported values include: * `user` * `group` * `domain` * `anyone` When creating a permission, if `type` is `user` or `group`, you must provide an `emailAddress` for the user or group. If `type` is `domain`, you must provide a `domain`. If `type` is `anyone`, no extra information is required.
1445 #[serde(rename = "type")]
1446 pub type_: Option<String>,
1447 /// Indicates the view for this permission. Only populated for permissions that belong to a view. The only supported values are `published` and `metadata`: * `published`: The permission's role is `publishedReader`. * `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. The `metadata` view is only supported on folders. For more information, see [Views](https://developers.google.com/workspace/drive/api/guides/ref-roles#views).
1448 pub view: Option<String>,
1449}
1450
1451impl common::RequestValue for Permission {}
1452impl common::Resource for Permission {}
1453impl common::ResponseResult for Permission {}
1454
1455/// A list of permissions for a file.
1456///
1457/// # Activities
1458///
1459/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1460/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1461///
1462/// * [list permissions](PermissionListCall) (response)
1463#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1464#[serde_with::serde_as]
1465#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1466pub struct PermissionList {
1467 /// Identifies what kind of resource this is. Value: the fixed string `"drive#permissionList"`.
1468 pub kind: Option<String>,
1469 /// 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. The page token is typically valid for several hours. However, if new items are added or removed, your expected results might differ.
1470 #[serde(rename = "nextPageToken")]
1471 pub next_page_token: Option<String>,
1472 /// The list of permissions. If `nextPageToken` is populated, then this list may be incomplete and an additional page of results should be fetched.
1473 pub permissions: Option<Vec<Permission>>,
1474}
1475
1476impl common::ResponseResult for PermissionList {}
1477
1478/// A reply to a comment on a file. Some resource methods (such as `replies.update`) require a `replyId`. Use the `replies.list` method to retrieve the ID for a reply.
1479///
1480/// # Activities
1481///
1482/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1483/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1484///
1485/// * [create replies](ReplyCreateCall) (request|response)
1486/// * [get replies](ReplyGetCall) (response)
1487/// * [update replies](ReplyUpdateCall) (request|response)
1488#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1489#[serde_with::serde_as]
1490#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1491pub struct Reply {
1492 /// The action the reply performed to the parent comment. The supported values are: * `resolve` * `reopen`
1493 pub action: Option<String>,
1494 /// Output only. The email address of the user assigned to this comment. If no user is assigned, the field is unset.
1495 #[serde(rename = "assigneeEmailAddress")]
1496 pub assignee_email_address: Option<String>,
1497 /// Output only. The author of the reply. The author's email address and permission ID won't be populated.
1498 pub author: Option<User>,
1499 /// The plain text content of the reply. This field is used for setting the content, while `htmlContent` should be displayed. This field is required by the `create` method if no `action` value is specified.
1500 pub content: Option<String>,
1501 /// The time at which the reply was created (RFC 3339 date-time).
1502 #[serde(rename = "createdTime")]
1503 pub created_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1504 /// Output only. Whether the reply has been deleted. A deleted reply has no content.
1505 pub deleted: Option<bool>,
1506 /// Output only. The content of the reply with HTML formatting.
1507 #[serde(rename = "htmlContent")]
1508 pub html_content: Option<String>,
1509 /// Output only. The ID of the reply.
1510 pub id: Option<String>,
1511 /// Output only. Identifies what kind of resource this is. Value: the fixed string `"drive#reply"`.
1512 pub kind: Option<String>,
1513 /// Output only. A list of email addresses for users mentioned in this comment. If no users are mentioned, the list is empty.
1514 #[serde(rename = "mentionedEmailAddresses")]
1515 pub mentioned_email_addresses: Option<Vec<String>>,
1516 /// The last time the reply was modified (RFC 3339 date-time).
1517 #[serde(rename = "modifiedTime")]
1518 pub modified_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1519}
1520
1521impl common::RequestValue for Reply {}
1522impl common::ResponseResult for Reply {}
1523
1524/// A list of replies to a comment on a file.
1525///
1526/// # Activities
1527///
1528/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1529/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1530///
1531/// * [list replies](ReplyListCall) (response)
1532#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1533#[serde_with::serde_as]
1534#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1535pub struct ReplyList {
1536 /// Identifies what kind of resource this is. Value: the fixed string `"drive#replyList"`.
1537 pub kind: Option<String>,
1538 /// 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. The page token is typically valid for several hours. However, if new items are added or removed, your expected results might differ.
1539 #[serde(rename = "nextPageToken")]
1540 pub next_page_token: Option<String>,
1541 /// The list of replies. If `nextPageToken` is populated, then this list may be incomplete and an additional page of results should be fetched.
1542 pub replies: Option<Vec<Reply>>,
1543}
1544
1545impl common::ResponseResult for ReplyList {}
1546
1547/// Request message for resolving an AccessProposal on a file.
1548///
1549/// # Activities
1550///
1551/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1552/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1553///
1554/// * [resolve accessproposals](AccessproposalResolveCall) (request)
1555#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1556#[serde_with::serde_as]
1557#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1558pub struct ResolveAccessProposalRequest {
1559 /// Required. The action to take on the access proposal.
1560 pub action: Option<String>,
1561 /// Optional. The roles that the approver has allowed, if any. For more information, see [Roles and permissions](https://developers.google.com/workspace/drive/api/guides/ref-roles). Note: This field is required for the `ACCEPT` action.
1562 pub role: Option<Vec<String>>,
1563 /// Optional. Whether to send an email to the requester when the access proposal is denied or accepted.
1564 #[serde(rename = "sendNotification")]
1565 pub send_notification: Option<bool>,
1566 /// Optional. Indicates the view for this access proposal. This should only be set when the proposal belongs to a view. Only `published` is supported.
1567 pub view: Option<String>,
1568}
1569
1570impl common::RequestValue for ResolveAccessProposalRequest {}
1571
1572/// A response on an Approval made by a specific Reviewer.
1573///
1574/// This type is not used in any activity, and only used as *part* of another schema.
1575///
1576#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1577#[serde_with::serde_as]
1578#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1579pub struct ReviewerResponse {
1580 /// This is always drive#reviewerResponse.
1581 pub kind: Option<String>,
1582 /// A Reviewer’s Response for the Approval.
1583 pub response: Option<String>,
1584 /// The user that is responsible for this response.
1585 pub reviewer: Option<User>,
1586}
1587
1588impl common::Part for ReviewerResponse {}
1589
1590/// The metadata for a revision to a file. Some resource methods (such as `revisions.update`) require a `revisionId`. Use the `revisions.list` method to retrieve the ID for a revision.
1591///
1592/// # Activities
1593///
1594/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1595/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1596///
1597/// * [delete revisions](RevisionDeleteCall) (none)
1598/// * [get revisions](RevisionGetCall) (response)
1599/// * [list revisions](RevisionListCall) (none)
1600/// * [update revisions](RevisionUpdateCall) (request|response)
1601#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1602#[serde_with::serde_as]
1603#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1604pub struct Revision {
1605 /// Output only. Links for exporting Docs Editors files to specific formats.
1606 #[serde(rename = "exportLinks")]
1607 pub export_links: Option<HashMap<String, String>>,
1608 /// Output only. The ID of the revision.
1609 pub id: Option<String>,
1610 /// Whether to keep this revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded. This can be set on a maximum of 200 revisions for a file. This field is only applicable to files with binary content in Drive.
1611 #[serde(rename = "keepForever")]
1612 pub keep_forever: Option<bool>,
1613 /// Output only. Identifies what kind of resource this is. Value: the fixed string `"drive#revision"`.
1614 pub kind: Option<String>,
1615 /// 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.
1616 #[serde(rename = "lastModifyingUser")]
1617 pub last_modifying_user: Option<User>,
1618 /// Output only. The MD5 checksum of the revision's content. This is only applicable to files with binary content in Drive.
1619 #[serde(rename = "md5Checksum")]
1620 pub md5_checksum: Option<String>,
1621 /// Output only. The MIME type of the revision.
1622 #[serde(rename = "mimeType")]
1623 pub mime_type: Option<String>,
1624 /// The last time the revision was modified (RFC 3339 date-time).
1625 #[serde(rename = "modifiedTime")]
1626 pub modified_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1627 /// Output only. The original filename used to create this revision. This is only applicable to files with binary content in Drive.
1628 #[serde(rename = "originalFilename")]
1629 pub original_filename: Option<String>,
1630 /// Whether subsequent revisions will be automatically republished. This is only applicable to Docs Editors files.
1631 #[serde(rename = "publishAuto")]
1632 pub publish_auto: Option<bool>,
1633 /// Whether this revision is published. This is only applicable to Docs Editors files.
1634 pub published: Option<bool>,
1635 /// Output only. A link to the published revision. This is only populated for Docs Editors files.
1636 #[serde(rename = "publishedLink")]
1637 pub published_link: Option<String>,
1638 /// Whether this revision is published outside the domain. This is only applicable to Docs Editors files.
1639 #[serde(rename = "publishedOutsideDomain")]
1640 pub published_outside_domain: Option<bool>,
1641 /// Output only. The size of the revision's content in bytes. This is only applicable to files with binary content in Drive.
1642 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1643 pub size: Option<i64>,
1644}
1645
1646impl common::RequestValue for Revision {}
1647impl common::Resource for Revision {}
1648impl common::ResponseResult for Revision {}
1649
1650/// A list of revisions of a file.
1651///
1652/// # Activities
1653///
1654/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1655/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1656///
1657/// * [list revisions](RevisionListCall) (response)
1658#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1659#[serde_with::serde_as]
1660#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1661pub struct RevisionList {
1662 /// Identifies what kind of resource this is. Value: the fixed string `"drive#revisionList"`.
1663 pub kind: Option<String>,
1664 /// The page token for the next page of revisions. This will be absent if the end of the revisions list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results. The page token is typically valid for several hours. However, if new items are added or removed, your expected results might differ.
1665 #[serde(rename = "nextPageToken")]
1666 pub next_page_token: Option<String>,
1667 /// The list of revisions. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
1668 pub revisions: Option<Vec<Revision>>,
1669}
1670
1671impl common::ResponseResult for RevisionList {}
1672
1673/// There is no detailed description.
1674///
1675/// # Activities
1676///
1677/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1678/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1679///
1680/// * [get start page token changes](ChangeGetStartPageTokenCall) (response)
1681#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1682#[serde_with::serde_as]
1683#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1684pub struct StartPageToken {
1685 /// Identifies what kind of resource this is. Value: the fixed string `"drive#startPageToken"`.
1686 pub kind: Option<String>,
1687 /// The starting page token for listing future changes. The page token doesn't expire.
1688 #[serde(rename = "startPageToken")]
1689 pub start_page_token: Option<String>,
1690}
1691
1692impl common::ResponseResult for StartPageToken {}
1693
1694/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
1695///
1696/// This type is not used in any activity, and only used as *part* of another schema.
1697///
1698#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1699#[serde_with::serde_as]
1700#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1701pub struct Status {
1702 /// The status code, which should be an enum value of google.rpc.Code.
1703 pub code: Option<i32>,
1704 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1705 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1706 /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
1707 pub message: Option<String>,
1708}
1709
1710impl common::Part for Status {}
1711
1712/// Deprecated: use the drive collection instead.
1713///
1714/// # Activities
1715///
1716/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1717/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1718///
1719/// * [create teamdrives](TeamdriveCreateCall) (request|response)
1720/// * [get teamdrives](TeamdriveGetCall) (response)
1721/// * [update teamdrives](TeamdriveUpdateCall) (request|response)
1722#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1723#[serde_with::serde_as]
1724#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1725pub struct TeamDrive {
1726 /// 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.
1727 #[serde(rename = "backgroundImageFile")]
1728 pub background_image_file: Option<TeamDriveBackgroundImageFile>,
1729 /// A short-lived link to this Team Drive's background image.
1730 #[serde(rename = "backgroundImageLink")]
1731 pub background_image_link: Option<String>,
1732 /// Capabilities the current user has on this Team Drive.
1733 pub capabilities: Option<TeamDriveCapabilities>,
1734 /// 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`.
1735 #[serde(rename = "colorRgb")]
1736 pub color_rgb: Option<String>,
1737 /// The time at which the Team Drive was created (RFC 3339 date-time).
1738 #[serde(rename = "createdTime")]
1739 pub created_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1740 /// The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
1741 pub id: Option<String>,
1742 /// Identifies what kind of resource this is. Value: the fixed string `"drive#teamDrive"`.
1743 pub kind: Option<String>,
1744 /// The name of this Team Drive.
1745 pub name: Option<String>,
1746 /// The organizational unit of this shared drive. This field is only populated on `drives.list` responses when the `useDomainAdminAccess` parameter is set to `true`.
1747 #[serde(rename = "orgUnitId")]
1748 pub org_unit_id: Option<String>,
1749 /// A set of restrictions that apply to this Team Drive or items inside this Team Drive.
1750 pub restrictions: Option<TeamDriveRestrictions>,
1751 /// The ID of the theme from which the background image and color will be set. The set of possible `teamDriveThemes` can be retrieved from a `drive.about.get` response. When not specified on a `drive.teamdrives.create` request, a random theme is chosen from which the background image and color are set. This is a write-only field; it can only be set on requests that don't set `colorRgb` or `backgroundImageFile`.
1752 #[serde(rename = "themeId")]
1753 pub theme_id: Option<String>,
1754}
1755
1756impl common::RequestValue for TeamDrive {}
1757impl common::Resource for TeamDrive {}
1758impl common::ResponseResult for TeamDrive {}
1759
1760/// A list of Team Drives.
1761///
1762/// # Activities
1763///
1764/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1765/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1766///
1767/// * [list teamdrives](TeamdriveListCall) (response)
1768#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1769#[serde_with::serde_as]
1770#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1771pub struct TeamDriveList {
1772 /// Identifies what kind of resource this is. Value: the fixed string `"drive#teamDriveList"`.
1773 pub kind: Option<String>,
1774 /// The page token for the next page of Team Drives. This will be absent if the end of the Team Drives list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results. The page token is typically valid for several hours. However, if new items are added or removed, your expected results might differ.
1775 #[serde(rename = "nextPageToken")]
1776 pub next_page_token: Option<String>,
1777 /// The list of Team Drives. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
1778 #[serde(rename = "teamDrives")]
1779 pub team_drives: Option<Vec<TeamDrive>>,
1780}
1781
1782impl common::ResponseResult for TeamDriveList {}
1783
1784/// Information about a Drive user.
1785///
1786/// This type is not used in any activity, and only used as *part* of another schema.
1787///
1788#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1789#[serde_with::serde_as]
1790#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1791pub struct User {
1792 /// Output only. A plain text displayable name for this user.
1793 #[serde(rename = "displayName")]
1794 pub display_name: Option<String>,
1795 /// 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.
1796 #[serde(rename = "emailAddress")]
1797 pub email_address: Option<String>,
1798 /// Output only. Identifies what kind of resource this is. Value: the fixed string `drive#user`.
1799 pub kind: Option<String>,
1800 /// Output only. Whether this user is the requesting user.
1801 pub me: Option<bool>,
1802 /// Output only. The user's ID as visible in Permission resources.
1803 #[serde(rename = "permissionId")]
1804 pub permission_id: Option<String>,
1805 /// Output only. A link to the user's profile photo, if available.
1806 #[serde(rename = "photoLink")]
1807 pub photo_link: Option<String>,
1808}
1809
1810impl common::Part for User {}
1811
1812/// A list of themes that are supported for shared drives.
1813///
1814/// This type is not used in any activity, and only used as *part* of another schema.
1815///
1816#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1817#[serde_with::serde_as]
1818#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1819pub struct AboutDriveThemes {
1820 /// A link to this theme's background image.
1821 #[serde(rename = "backgroundImageLink")]
1822 pub background_image_link: Option<String>,
1823 /// The color of this theme as an RGB hex string.
1824 #[serde(rename = "colorRgb")]
1825 pub color_rgb: Option<String>,
1826 /// The ID of the theme.
1827 pub id: Option<String>,
1828}
1829
1830impl common::NestedType for AboutDriveThemes {}
1831impl common::Part for AboutDriveThemes {}
1832
1833/// The user's storage quota limits and usage. For users that are part of an organization with pooled storage, information about the limit and usage across all services is for the organization, rather than the individual user. All fields are measured in bytes.
1834///
1835/// This type is not used in any activity, and only used as *part* of another schema.
1836///
1837#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1838#[serde_with::serde_as]
1839#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1840pub struct AboutStorageQuota {
1841 /// The usage limit, if applicable. This will not be present if the user has unlimited storage. For users that are part of an organization with pooled storage, this is the limit for the organization, rather than the individual user.
1842 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1843 pub limit: Option<i64>,
1844 /// The total usage across all services. For users that are part of an organization with pooled storage, this is the usage across all services for the organization, rather than the individual user.
1845 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1846 pub usage: Option<i64>,
1847 /// The usage by all files in Google Drive.
1848 #[serde(rename = "usageInDrive")]
1849 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1850 pub usage_in_drive: Option<i64>,
1851 /// The usage by trashed files in Google Drive.
1852 #[serde(rename = "usageInDriveTrash")]
1853 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1854 pub usage_in_drive_trash: Option<i64>,
1855}
1856
1857impl common::NestedType for AboutStorageQuota {}
1858impl common::Part for AboutStorageQuota {}
1859
1860/// Deprecated: Use `driveThemes` instead.
1861///
1862/// This type is not used in any activity, and only used as *part* of another schema.
1863///
1864#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1865#[serde_with::serde_as]
1866#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1867pub struct AboutTeamDriveThemes {
1868 /// Deprecated: Use `driveThemes/backgroundImageLink` instead.
1869 #[serde(rename = "backgroundImageLink")]
1870 pub background_image_link: Option<String>,
1871 /// Deprecated: Use `driveThemes/colorRgb` instead.
1872 #[serde(rename = "colorRgb")]
1873 pub color_rgb: Option<String>,
1874 /// Deprecated: Use `driveThemes/id` instead.
1875 pub id: Option<String>,
1876}
1877
1878impl common::NestedType for AboutTeamDriveThemes {}
1879impl common::Part for AboutTeamDriveThemes {}
1880
1881/// The file content to which the comment refers, typically within the anchor region. For a text file, for example, this would be the text at the location of the comment.
1882///
1883/// This type is not used in any activity, and only used as *part* of another schema.
1884///
1885#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1886#[serde_with::serde_as]
1887#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1888pub struct CommentQuotedFileContent {
1889 /// The MIME type of the quoted content.
1890 #[serde(rename = "mimeType")]
1891 pub mime_type: Option<String>,
1892 /// The quoted content itself. This is interpreted as plain text if set through the API.
1893 pub value: Option<String>,
1894}
1895
1896impl common::NestedType for CommentQuotedFileContent {}
1897impl common::Part for CommentQuotedFileContent {}
1898
1899/// 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.
1900///
1901/// This type is not used in any activity, and only used as *part* of another schema.
1902///
1903#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1904#[serde_with::serde_as]
1905#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1906pub struct DriveBackgroundImageFile {
1907 /// The ID of an image file in Google Drive to use for the background image.
1908 pub id: Option<String>,
1909 /// 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.
1910 pub width: Option<f32>,
1911 /// 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.
1912 #[serde(rename = "xCoordinate")]
1913 pub x_coordinate: Option<f32>,
1914 /// 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.
1915 #[serde(rename = "yCoordinate")]
1916 pub y_coordinate: Option<f32>,
1917}
1918
1919impl common::NestedType for DriveBackgroundImageFile {}
1920impl common::Part for DriveBackgroundImageFile {}
1921
1922/// Output only. Capabilities the current user has on this shared drive.
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 DriveCapabilities {
1930 /// Output only. Whether the current user can add children to folders in this shared drive.
1931 #[serde(rename = "canAddChildren")]
1932 pub can_add_children: Option<bool>,
1933 /// Output only. Whether the current user can change the `copyRequiresWriterPermission` restriction of this shared drive.
1934 #[serde(rename = "canChangeCopyRequiresWriterPermissionRestriction")]
1935 pub can_change_copy_requires_writer_permission_restriction: Option<bool>,
1936 /// Output only. Whether the current user can change the `domainUsersOnly` restriction of this shared drive.
1937 #[serde(rename = "canChangeDomainUsersOnlyRestriction")]
1938 pub can_change_domain_users_only_restriction: Option<bool>,
1939 /// Output only. Whether the current user can change organizer-applied download restrictions of this shared drive.
1940 #[serde(rename = "canChangeDownloadRestriction")]
1941 pub can_change_download_restriction: Option<bool>,
1942 /// Output only. Whether the current user can change the background of this shared drive.
1943 #[serde(rename = "canChangeDriveBackground")]
1944 pub can_change_drive_background: Option<bool>,
1945 /// Output only. Whether the current user can change the `driveMembersOnly` restriction of this shared drive.
1946 #[serde(rename = "canChangeDriveMembersOnlyRestriction")]
1947 pub can_change_drive_members_only_restriction: Option<bool>,
1948 /// Output only. Whether the current user can change the `sharingFoldersRequiresOrganizerPermission` restriction of this shared drive.
1949 #[serde(rename = "canChangeSharingFoldersRequiresOrganizerPermissionRestriction")]
1950 pub can_change_sharing_folders_requires_organizer_permission_restriction: Option<bool>,
1951 /// Output only. Whether the current user can comment on files in this shared drive.
1952 #[serde(rename = "canComment")]
1953 pub can_comment: Option<bool>,
1954 /// Output only. Whether the current user can copy files in this shared drive.
1955 #[serde(rename = "canCopy")]
1956 pub can_copy: Option<bool>,
1957 /// Output only. Whether the current user can delete children from folders in this shared drive.
1958 #[serde(rename = "canDeleteChildren")]
1959 pub can_delete_children: Option<bool>,
1960 /// 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.
1961 #[serde(rename = "canDeleteDrive")]
1962 pub can_delete_drive: Option<bool>,
1963 /// Output only. Whether the current user can download files in this shared drive.
1964 #[serde(rename = "canDownload")]
1965 pub can_download: Option<bool>,
1966 /// Output only. Whether the current user can edit files in this shared drive
1967 #[serde(rename = "canEdit")]
1968 pub can_edit: Option<bool>,
1969 /// Output only. Whether the current user can list the children of folders in this shared drive.
1970 #[serde(rename = "canListChildren")]
1971 pub can_list_children: Option<bool>,
1972 /// Output only. Whether the current user can add members to this shared drive or remove them or change their role.
1973 #[serde(rename = "canManageMembers")]
1974 pub can_manage_members: Option<bool>,
1975 /// Output only. Whether the current user can read the revisions resource of files in this shared drive.
1976 #[serde(rename = "canReadRevisions")]
1977 pub can_read_revisions: Option<bool>,
1978 /// Output only. Whether the current user can rename files or folders in this shared drive.
1979 #[serde(rename = "canRename")]
1980 pub can_rename: Option<bool>,
1981 /// Output only. Whether the current user can rename this shared drive.
1982 #[serde(rename = "canRenameDrive")]
1983 pub can_rename_drive: Option<bool>,
1984 /// Output only. Whether the current user can reset the shared drive restrictions to defaults.
1985 #[serde(rename = "canResetDriveRestrictions")]
1986 pub can_reset_drive_restrictions: Option<bool>,
1987 /// Output only. Whether the current user can share files or folders in this shared drive.
1988 #[serde(rename = "canShare")]
1989 pub can_share: Option<bool>,
1990 /// Output only. Whether the current user can trash children from folders in this shared drive.
1991 #[serde(rename = "canTrashChildren")]
1992 pub can_trash_children: Option<bool>,
1993}
1994
1995impl common::NestedType for DriveCapabilities {}
1996impl common::Part for DriveCapabilities {}
1997
1998/// A set of restrictions that apply to this shared drive or items inside this shared drive. Note that restrictions can't be set when creating a shared drive. To add a restriction, first create a shared drive and then use `drives.update` to add restrictions.
1999///
2000/// This type is not used in any activity, and only used as *part* of another schema.
2001///
2002#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2003#[serde_with::serde_as]
2004#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2005pub struct DriveRestrictions {
2006 /// Whether administrative privileges on this shared drive are required to modify restrictions.
2007 #[serde(rename = "adminManagedRestrictions")]
2008 pub admin_managed_restrictions: Option<bool>,
2009 /// 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.
2010 #[serde(rename = "copyRequiresWriterPermission")]
2011 pub copy_requires_writer_permission: Option<bool>,
2012 /// 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.
2013 #[serde(rename = "domainUsersOnly")]
2014 pub domain_users_only: Option<bool>,
2015 /// Download restrictions applied by shared drive managers.
2016 #[serde(rename = "downloadRestriction")]
2017 pub download_restriction: Option<DownloadRestriction>,
2018 /// Whether access to items inside this shared drive is restricted to its members.
2019 #[serde(rename = "driveMembersOnly")]
2020 pub drive_members_only: Option<bool>,
2021 /// 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.
2022 #[serde(rename = "sharingFoldersRequiresOrganizerPermission")]
2023 pub sharing_folders_requires_organizer_permission: Option<bool>,
2024}
2025
2026impl common::NestedType for DriveRestrictions {}
2027impl common::Part for DriveRestrictions {}
2028
2029/// Output only. Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take. For more information, see [Understand file capabilities](https://developers.google.com/workspace/drive/api/guides/manage-sharing#capabilities).
2030///
2031/// This type is not used in any activity, and only used as *part* of another schema.
2032///
2033#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2034#[serde_with::serde_as]
2035#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2036pub struct FileCapabilities {
2037 /// Output only. Whether the current user is the pending owner of the file. Not populated for shared drive files.
2038 #[serde(rename = "canAcceptOwnership")]
2039 pub can_accept_ownership: Option<bool>,
2040 /// Output only. Whether the current user can add children to this folder. This is always `false` when the item isn't a folder.
2041 #[serde(rename = "canAddChildren")]
2042 pub can_add_children: Option<bool>,
2043 /// 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 isn't a folder. Only populated for items in shared drives.
2044 #[serde(rename = "canAddFolderFromAnotherDrive")]
2045 pub can_add_folder_from_another_drive: Option<bool>,
2046 /// 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.
2047 #[serde(rename = "canAddMyDriveParent")]
2048 pub can_add_my_drive_parent: Option<bool>,
2049 /// Output only. Whether the current user can change the `copyRequiresWriterPermission` restriction of this file.
2050 #[serde(rename = "canChangeCopyRequiresWriterPermission")]
2051 pub can_change_copy_requires_writer_permission: Option<bool>,
2052 /// Output only. Whether the current user can change the owner or organizer-applied download restrictions of the file.
2053 #[serde(rename = "canChangeItemDownloadRestriction")]
2054 pub can_change_item_download_restriction: Option<bool>,
2055 /// Output only. Whether the current user can change the `securityUpdateEnabled` field on link share metadata.
2056 #[serde(rename = "canChangeSecurityUpdateEnabled")]
2057 pub can_change_security_update_enabled: Option<bool>,
2058 /// Deprecated: Output only.
2059 #[serde(rename = "canChangeViewersCanCopyContent")]
2060 pub can_change_viewers_can_copy_content: Option<bool>,
2061 /// Output only. Whether the current user can comment on this file.
2062 #[serde(rename = "canComment")]
2063 pub can_comment: Option<bool>,
2064 /// 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 if it's not a folder.
2065 #[serde(rename = "canCopy")]
2066 pub can_copy: Option<bool>,
2067 /// Output only. Whether the current user can delete this file.
2068 #[serde(rename = "canDelete")]
2069 pub can_delete: Option<bool>,
2070 /// Output only. Whether the current user can delete children of this folder. This is `false` when the item isn't a folder. Only populated for items in shared drives.
2071 #[serde(rename = "canDeleteChildren")]
2072 pub can_delete_children: Option<bool>,
2073 /// Whether a user can disable inherited permissions.
2074 #[serde(rename = "canDisableInheritedPermissions")]
2075 pub can_disable_inherited_permissions: Option<bool>,
2076 /// Output only. Whether the current user can download this file.
2077 #[serde(rename = "canDownload")]
2078 pub can_download: Option<bool>,
2079 /// 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`.
2080 #[serde(rename = "canEdit")]
2081 pub can_edit: Option<bool>,
2082 /// Whether a user can re-enable inherited permissions.
2083 #[serde(rename = "canEnableInheritedPermissions")]
2084 pub can_enable_inherited_permissions: Option<bool>,
2085 /// Output only. Whether the current user can list the children of this folder. This is always `false` when the item isn't a folder.
2086 #[serde(rename = "canListChildren")]
2087 pub can_list_children: Option<bool>,
2088 /// Output only. Whether the current user can modify the content of this file.
2089 #[serde(rename = "canModifyContent")]
2090 pub can_modify_content: Option<bool>,
2091 /// Deprecated: Output only. Use one of `canModifyEditorContentRestriction`, `canModifyOwnerContentRestriction`, or `canRemoveContentRestriction`.
2092 #[serde(rename = "canModifyContentRestriction")]
2093 pub can_modify_content_restriction: Option<bool>,
2094 /// Output only. Whether the current user can add or modify content restrictions on the file which are editor restricted.
2095 #[serde(rename = "canModifyEditorContentRestriction")]
2096 pub can_modify_editor_content_restriction: Option<bool>,
2097 /// Output only. Whether the current user can modify the labels on the file.
2098 #[serde(rename = "canModifyLabels")]
2099 pub can_modify_labels: Option<bool>,
2100 /// Output only. Whether the current user can add or modify content restrictions which are owner restricted.
2101 #[serde(rename = "canModifyOwnerContentRestriction")]
2102 pub can_modify_owner_content_restriction: Option<bool>,
2103 /// Output only. Whether the current user can move children of this folder outside of the shared drive. This is `false` when the item isn't a folder. Only populated for items in shared drives.
2104 #[serde(rename = "canMoveChildrenOutOfDrive")]
2105 pub can_move_children_out_of_drive: Option<bool>,
2106 /// Deprecated: Output only. Use `canMoveChildrenOutOfDrive` instead.
2107 #[serde(rename = "canMoveChildrenOutOfTeamDrive")]
2108 pub can_move_children_out_of_team_drive: Option<bool>,
2109 /// Output only. Whether the current user can move children of this folder within this drive. This is `false` when the item isn't 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.
2110 #[serde(rename = "canMoveChildrenWithinDrive")]
2111 pub can_move_children_within_drive: Option<bool>,
2112 /// Deprecated: Output only. Use `canMoveChildrenWithinDrive` instead.
2113 #[serde(rename = "canMoveChildrenWithinTeamDrive")]
2114 pub can_move_children_within_team_drive: Option<bool>,
2115 /// Deprecated: Output only. Use `canMoveItemOutOfDrive` instead.
2116 #[serde(rename = "canMoveItemIntoTeamDrive")]
2117 pub can_move_item_into_team_drive: Option<bool>,
2118 /// 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's being added.
2119 #[serde(rename = "canMoveItemOutOfDrive")]
2120 pub can_move_item_out_of_drive: Option<bool>,
2121 /// Deprecated: Output only. Use `canMoveItemOutOfDrive` instead.
2122 #[serde(rename = "canMoveItemOutOfTeamDrive")]
2123 pub can_move_item_out_of_team_drive: Option<bool>,
2124 /// 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's being added and the parent that is being removed.
2125 #[serde(rename = "canMoveItemWithinDrive")]
2126 pub can_move_item_within_drive: Option<bool>,
2127 /// Deprecated: Output only. Use `canMoveItemWithinDrive` instead.
2128 #[serde(rename = "canMoveItemWithinTeamDrive")]
2129 pub can_move_item_within_team_drive: Option<bool>,
2130 /// Deprecated: Output only. Use `canMoveItemWithinDrive` or `canMoveItemOutOfDrive` instead.
2131 #[serde(rename = "canMoveTeamDriveItem")]
2132 pub can_move_team_drive_item: Option<bool>,
2133 /// Output only. Whether the current user can read the shared drive to which this file belongs. Only populated for items in shared drives.
2134 #[serde(rename = "canReadDrive")]
2135 pub can_read_drive: Option<bool>,
2136 /// Output only. Whether the current user can read the labels on the file.
2137 #[serde(rename = "canReadLabels")]
2138 pub can_read_labels: Option<bool>,
2139 /// 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 if it's not a folder, can be read.
2140 #[serde(rename = "canReadRevisions")]
2141 pub can_read_revisions: Option<bool>,
2142 /// Deprecated: Output only. Use `canReadDrive` instead.
2143 #[serde(rename = "canReadTeamDrive")]
2144 pub can_read_team_drive: Option<bool>,
2145 /// Output only. Whether the current user can remove children from this folder. This is always `false` when the item isn't a folder. For a folder in a shared drive, use `canDeleteChildren` or `canTrashChildren` instead.
2146 #[serde(rename = "canRemoveChildren")]
2147 pub can_remove_children: Option<bool>,
2148 /// Output only. Whether there's a content restriction on the file that can be removed by the current user.
2149 #[serde(rename = "canRemoveContentRestriction")]
2150 pub can_remove_content_restriction: Option<bool>,
2151 /// 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.
2152 #[serde(rename = "canRemoveMyDriveParent")]
2153 pub can_remove_my_drive_parent: Option<bool>,
2154 /// Output only. Whether the current user can rename this file.
2155 #[serde(rename = "canRename")]
2156 pub can_rename: Option<bool>,
2157 /// Output only. Whether the current user can modify the sharing settings for this file.
2158 #[serde(rename = "canShare")]
2159 pub can_share: Option<bool>,
2160 /// Output only. Whether the current user can move this file to trash.
2161 #[serde(rename = "canTrash")]
2162 pub can_trash: Option<bool>,
2163 /// Output only. Whether the current user can trash children of this folder. This is `false` when the item isn't a folder. Only populated for items in shared drives.
2164 #[serde(rename = "canTrashChildren")]
2165 pub can_trash_children: Option<bool>,
2166 /// Output only. Whether the current user can restore this file from trash.
2167 #[serde(rename = "canUntrash")]
2168 pub can_untrash: Option<bool>,
2169}
2170
2171impl common::NestedType for FileCapabilities {}
2172impl common::Part for FileCapabilities {}
2173
2174/// Additional information about the content of the file. These fields are never populated in responses.
2175///
2176/// This type is not used in any activity, and only used as *part* of another schema.
2177///
2178#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2179#[serde_with::serde_as]
2180#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2181pub struct FileContentHints {
2182 /// Text to be indexed for the file to improve fullText queries. This is limited to 128 KB in length and may contain HTML elements.
2183 #[serde(rename = "indexableText")]
2184 pub indexable_text: Option<String>,
2185 /// A thumbnail for the file. This will only be used if Google Drive cannot generate a standard thumbnail.
2186 pub thumbnail: Option<FileContentHintsThumbnail>,
2187}
2188
2189impl common::NestedType for FileContentHints {}
2190impl common::Part for FileContentHints {}
2191
2192/// A thumbnail for the file. This will only be used if Google Drive cannot generate a standard thumbnail.
2193///
2194/// This type is not used in any activity, and only used as *part* of another schema.
2195///
2196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2197#[serde_with::serde_as]
2198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2199pub struct FileContentHintsThumbnail {
2200 /// The thumbnail data encoded with URL-safe Base64 ([RFC 4648 section 5](https://datatracker.ietf.org/doc/html/rfc4648#section-5)).
2201 #[serde_as(as = "Option<common::serde::urlsafe_base64::Wrapper>")]
2202 pub image: Option<Vec<u8>>,
2203 /// The MIME type of the thumbnail.
2204 #[serde(rename = "mimeType")]
2205 pub mime_type: Option<String>,
2206}
2207
2208impl common::NestedType for FileContentHintsThumbnail {}
2209impl common::Part for FileContentHintsThumbnail {}
2210
2211/// Output only. Additional metadata about image media, if available.
2212///
2213/// This type is not used in any activity, and only used as *part* of another schema.
2214///
2215#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2216#[serde_with::serde_as]
2217#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2218pub struct FileImageMediaMetadata {
2219 /// Output only. The aperture used to create the photo (f-number).
2220 pub aperture: Option<f32>,
2221 /// Output only. The make of the camera used to create the photo.
2222 #[serde(rename = "cameraMake")]
2223 pub camera_make: Option<String>,
2224 /// Output only. The model of the camera used to create the photo.
2225 #[serde(rename = "cameraModel")]
2226 pub camera_model: Option<String>,
2227 /// Output only. The color space of the photo.
2228 #[serde(rename = "colorSpace")]
2229 pub color_space: Option<String>,
2230 /// Output only. The exposure bias of the photo (APEX value).
2231 #[serde(rename = "exposureBias")]
2232 pub exposure_bias: Option<f32>,
2233 /// Output only. The exposure mode used to create the photo.
2234 #[serde(rename = "exposureMode")]
2235 pub exposure_mode: Option<String>,
2236 /// Output only. The length of the exposure, in seconds.
2237 #[serde(rename = "exposureTime")]
2238 pub exposure_time: Option<f32>,
2239 /// Output only. Whether a flash was used to create the photo.
2240 #[serde(rename = "flashUsed")]
2241 pub flash_used: Option<bool>,
2242 /// Output only. The focal length used to create the photo, in millimeters.
2243 #[serde(rename = "focalLength")]
2244 pub focal_length: Option<f32>,
2245 /// Output only. The height of the image in pixels.
2246 pub height: Option<i32>,
2247 /// Output only. The ISO speed used to create the photo.
2248 #[serde(rename = "isoSpeed")]
2249 pub iso_speed: Option<i32>,
2250 /// Output only. The lens used to create the photo.
2251 pub lens: Option<String>,
2252 /// Output only. Geographic location information stored in the image.
2253 pub location: Option<FileImageMediaMetadataLocation>,
2254 /// Output only. The smallest f-number of the lens at the focal length used to create the photo (APEX value).
2255 #[serde(rename = "maxApertureValue")]
2256 pub max_aperture_value: Option<f32>,
2257 /// Output only. The metering mode used to create the photo.
2258 #[serde(rename = "meteringMode")]
2259 pub metering_mode: Option<String>,
2260 /// Output only. The number of clockwise 90 degree rotations applied from the image's original orientation.
2261 pub rotation: Option<i32>,
2262 /// Output only. The type of sensor used to create the photo.
2263 pub sensor: Option<String>,
2264 /// Output only. The distance to the subject of the photo, in meters.
2265 #[serde(rename = "subjectDistance")]
2266 pub subject_distance: Option<i32>,
2267 /// Output only. The date and time the photo was taken (EXIF DateTime).
2268 pub time: Option<String>,
2269 /// Output only. The white balance mode used to create the photo.
2270 #[serde(rename = "whiteBalance")]
2271 pub white_balance: Option<String>,
2272 /// Output only. The width of the image in pixels.
2273 pub width: Option<i32>,
2274}
2275
2276impl common::NestedType for FileImageMediaMetadata {}
2277impl common::Part for FileImageMediaMetadata {}
2278
2279/// Output only. Geographic location information stored in the image.
2280///
2281/// This type is not used in any activity, and only used as *part* of another schema.
2282///
2283#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2284#[serde_with::serde_as]
2285#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2286pub struct FileImageMediaMetadataLocation {
2287 /// Output only. The altitude stored in the image.
2288 pub altitude: Option<f64>,
2289 /// Output only. The latitude stored in the image.
2290 pub latitude: Option<f64>,
2291 /// Output only. The longitude stored in the image.
2292 pub longitude: Option<f64>,
2293}
2294
2295impl common::NestedType for FileImageMediaMetadataLocation {}
2296impl common::Part for FileImageMediaMetadataLocation {}
2297
2298/// Output only. An overview of the labels on the file.
2299///
2300/// This type is not used in any activity, and only used as *part* of another schema.
2301///
2302#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2303#[serde_with::serde_as]
2304#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2305pub struct FileLabelInfo {
2306 /// 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.
2307 pub labels: Option<Vec<Label>>,
2308}
2309
2310impl common::NestedType for FileLabelInfo {}
2311impl common::Part for FileLabelInfo {}
2312
2313/// Contains details about the link URLs that clients are using to refer to this item.
2314///
2315/// This type is not used in any activity, and only used as *part* of another schema.
2316///
2317#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2318#[serde_with::serde_as]
2319#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2320pub struct FileLinkShareMetadata {
2321 /// Output only. Whether the file is eligible for security update.
2322 #[serde(rename = "securityUpdateEligible")]
2323 pub security_update_eligible: Option<bool>,
2324 /// Output only. Whether the security update is enabled for this file.
2325 #[serde(rename = "securityUpdateEnabled")]
2326 pub security_update_enabled: Option<bool>,
2327}
2328
2329impl common::NestedType for FileLinkShareMetadata {}
2330impl common::Part for FileLinkShareMetadata {}
2331
2332/// 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.create` requests.
2333///
2334/// This type is not used in any activity, and only used as *part* of another schema.
2335///
2336#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2337#[serde_with::serde_as]
2338#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2339pub struct FileShortcutDetails {
2340 /// The ID of the file that this shortcut points to. Can only be set on `files.create` requests.
2341 #[serde(rename = "targetId")]
2342 pub target_id: Option<String>,
2343 /// 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.
2344 #[serde(rename = "targetMimeType")]
2345 pub target_mime_type: Option<String>,
2346 /// Output only. The `resourceKey` for the target file.
2347 #[serde(rename = "targetResourceKey")]
2348 pub target_resource_key: Option<String>,
2349}
2350
2351impl common::NestedType for FileShortcutDetails {}
2352impl common::Part for FileShortcutDetails {}
2353
2354/// Output only. Additional metadata about video media. This may not be available immediately upon upload.
2355///
2356/// This type is not used in any activity, and only used as *part* of another schema.
2357///
2358#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2359#[serde_with::serde_as]
2360#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2361pub struct FileVideoMediaMetadata {
2362 /// Output only. The duration of the video in milliseconds.
2363 #[serde(rename = "durationMillis")]
2364 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2365 pub duration_millis: Option<i64>,
2366 /// Output only. The height of the video in pixels.
2367 pub height: Option<i32>,
2368 /// Output only. The width of the video in pixels.
2369 pub width: Option<i32>,
2370}
2371
2372impl common::NestedType for FileVideoMediaMetadata {}
2373impl common::Part for FileVideoMediaMetadata {}
2374
2375/// Output only. Details of whether the permissions on this item are inherited or are directly on this item.
2376///
2377/// This type is not used in any activity, and only used as *part* of another schema.
2378///
2379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2380#[serde_with::serde_as]
2381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2382pub struct PermissionPermissionDetails {
2383 /// Output only. Whether this permission is inherited. This field is always populated. This is an output-only field.
2384 pub inherited: Option<bool>,
2385 /// Output only. The ID of the item from which this permission is inherited. This is only populated for items in shared drives.
2386 #[serde(rename = "inheritedFrom")]
2387 pub inherited_from: Option<String>,
2388 /// Output only. The permission type for this user. Supported values include: * `file` * `member`
2389 #[serde(rename = "permissionType")]
2390 pub permission_type: Option<String>,
2391 /// Output only. The primary role for this user. Supported values include: * `owner` * `organizer` * `fileOrganizer` * `writer` * `commenter` * `reader` For more information, see [Roles and permissions](https://developers.google.com/workspace/drive/api/guides/ref-roles).
2392 pub role: Option<String>,
2393}
2394
2395impl common::NestedType for PermissionPermissionDetails {}
2396impl common::Part for PermissionPermissionDetails {}
2397
2398/// Output only. Deprecated: Output only. Use `permissionDetails` instead.
2399///
2400/// This type is not used in any activity, and only used as *part* of another schema.
2401///
2402#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2403#[serde_with::serde_as]
2404#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2405pub struct PermissionTeamDrivePermissionDetails {
2406 /// Deprecated: Output only. Use `permissionDetails/inherited` instead.
2407 pub inherited: Option<bool>,
2408 /// Deprecated: Output only. Use `permissionDetails/inheritedFrom` instead.
2409 #[serde(rename = "inheritedFrom")]
2410 pub inherited_from: Option<String>,
2411 /// Deprecated: Output only. Use `permissionDetails/role` instead.
2412 pub role: Option<String>,
2413 /// Deprecated: Output only. Use `permissionDetails/permissionType` instead.
2414 #[serde(rename = "teamDrivePermissionType")]
2415 pub team_drive_permission_type: Option<String>,
2416}
2417
2418impl common::NestedType for PermissionTeamDrivePermissionDetails {}
2419impl common::Part for PermissionTeamDrivePermissionDetails {}
2420
2421/// 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.
2422///
2423/// This type is not used in any activity, and only used as *part* of another schema.
2424///
2425#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2426#[serde_with::serde_as]
2427#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2428pub struct TeamDriveBackgroundImageFile {
2429 /// The ID of an image file in Drive to use for the background image.
2430 pub id: Option<String>,
2431 /// 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.
2432 pub width: Option<f32>,
2433 /// 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.
2434 #[serde(rename = "xCoordinate")]
2435 pub x_coordinate: Option<f32>,
2436 /// 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.
2437 #[serde(rename = "yCoordinate")]
2438 pub y_coordinate: Option<f32>,
2439}
2440
2441impl common::NestedType for TeamDriveBackgroundImageFile {}
2442impl common::Part for TeamDriveBackgroundImageFile {}
2443
2444/// Capabilities the current user has on this Team Drive.
2445///
2446/// This type is not used in any activity, and only used as *part* of another schema.
2447///
2448#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2449#[serde_with::serde_as]
2450#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2451pub struct TeamDriveCapabilities {
2452 /// Whether the current user can add children to folders in this Team Drive.
2453 #[serde(rename = "canAddChildren")]
2454 pub can_add_children: Option<bool>,
2455 /// Whether the current user can change the `copyRequiresWriterPermission` restriction of this Team Drive.
2456 #[serde(rename = "canChangeCopyRequiresWriterPermissionRestriction")]
2457 pub can_change_copy_requires_writer_permission_restriction: Option<bool>,
2458 /// Whether the current user can change the `domainUsersOnly` restriction of this Team Drive.
2459 #[serde(rename = "canChangeDomainUsersOnlyRestriction")]
2460 pub can_change_domain_users_only_restriction: Option<bool>,
2461 /// Whether the current user can change organizer-applied download restrictions of this shared drive.
2462 #[serde(rename = "canChangeDownloadRestriction")]
2463 pub can_change_download_restriction: Option<bool>,
2464 /// Whether the current user can change the `sharingFoldersRequiresOrganizerPermission` restriction of this Team Drive.
2465 #[serde(rename = "canChangeSharingFoldersRequiresOrganizerPermissionRestriction")]
2466 pub can_change_sharing_folders_requires_organizer_permission_restriction: Option<bool>,
2467 /// Whether the current user can change the background of this Team Drive.
2468 #[serde(rename = "canChangeTeamDriveBackground")]
2469 pub can_change_team_drive_background: Option<bool>,
2470 /// Whether the current user can change the `teamMembersOnly` restriction of this Team Drive.
2471 #[serde(rename = "canChangeTeamMembersOnlyRestriction")]
2472 pub can_change_team_members_only_restriction: Option<bool>,
2473 /// Whether the current user can comment on files in this Team Drive.
2474 #[serde(rename = "canComment")]
2475 pub can_comment: Option<bool>,
2476 /// Whether the current user can copy files in this Team Drive.
2477 #[serde(rename = "canCopy")]
2478 pub can_copy: Option<bool>,
2479 /// Whether the current user can delete children from folders in this Team Drive.
2480 #[serde(rename = "canDeleteChildren")]
2481 pub can_delete_children: Option<bool>,
2482 /// 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.
2483 #[serde(rename = "canDeleteTeamDrive")]
2484 pub can_delete_team_drive: Option<bool>,
2485 /// Whether the current user can download files in this Team Drive.
2486 #[serde(rename = "canDownload")]
2487 pub can_download: Option<bool>,
2488 /// Whether the current user can edit files in this Team Drive
2489 #[serde(rename = "canEdit")]
2490 pub can_edit: Option<bool>,
2491 /// Whether the current user can list the children of folders in this Team Drive.
2492 #[serde(rename = "canListChildren")]
2493 pub can_list_children: Option<bool>,
2494 /// Whether the current user can add members to this Team Drive or remove them or change their role.
2495 #[serde(rename = "canManageMembers")]
2496 pub can_manage_members: Option<bool>,
2497 /// Whether the current user can read the revisions resource of files in this Team Drive.
2498 #[serde(rename = "canReadRevisions")]
2499 pub can_read_revisions: Option<bool>,
2500 /// Deprecated: Use `canDeleteChildren` or `canTrashChildren` instead.
2501 #[serde(rename = "canRemoveChildren")]
2502 pub can_remove_children: Option<bool>,
2503 /// Whether the current user can rename files or folders in this Team Drive.
2504 #[serde(rename = "canRename")]
2505 pub can_rename: Option<bool>,
2506 /// Whether the current user can rename this Team Drive.
2507 #[serde(rename = "canRenameTeamDrive")]
2508 pub can_rename_team_drive: Option<bool>,
2509 /// Whether the current user can reset the Team Drive restrictions to defaults.
2510 #[serde(rename = "canResetTeamDriveRestrictions")]
2511 pub can_reset_team_drive_restrictions: Option<bool>,
2512 /// Whether the current user can share files or folders in this Team Drive.
2513 #[serde(rename = "canShare")]
2514 pub can_share: Option<bool>,
2515 /// Whether the current user can trash children from folders in this Team Drive.
2516 #[serde(rename = "canTrashChildren")]
2517 pub can_trash_children: Option<bool>,
2518}
2519
2520impl common::NestedType for TeamDriveCapabilities {}
2521impl common::Part for TeamDriveCapabilities {}
2522
2523/// A set of restrictions that apply to this Team Drive or items inside this Team Drive.
2524///
2525/// This type is not used in any activity, and only used as *part* of another schema.
2526///
2527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2528#[serde_with::serde_as]
2529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2530pub struct TeamDriveRestrictions {
2531 /// Whether administrative privileges on this Team Drive are required to modify restrictions.
2532 #[serde(rename = "adminManagedRestrictions")]
2533 pub admin_managed_restrictions: Option<bool>,
2534 /// 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.
2535 #[serde(rename = "copyRequiresWriterPermission")]
2536 pub copy_requires_writer_permission: Option<bool>,
2537 /// 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.
2538 #[serde(rename = "domainUsersOnly")]
2539 pub domain_users_only: Option<bool>,
2540 /// Download restrictions applied by shared drive managers.
2541 #[serde(rename = "downloadRestriction")]
2542 pub download_restriction: Option<DownloadRestriction>,
2543 /// 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.
2544 #[serde(rename = "sharingFoldersRequiresOrganizerPermission")]
2545 pub sharing_folders_requires_organizer_permission: Option<bool>,
2546 /// Whether access to items inside this Team Drive is restricted to members of this Team Drive.
2547 #[serde(rename = "teamMembersOnly")]
2548 pub team_members_only: Option<bool>,
2549}
2550
2551impl common::NestedType for TeamDriveRestrictions {}
2552impl common::Part for TeamDriveRestrictions {}
2553
2554// ###################
2555// MethodBuilders ###
2556// #################
2557
2558/// A builder providing access to all methods supported on *about* resources.
2559/// It is not used directly, but through the [`DriveHub`] hub.
2560///
2561/// # Example
2562///
2563/// Instantiate a resource builder
2564///
2565/// ```test_harness,no_run
2566/// extern crate hyper;
2567/// extern crate hyper_rustls;
2568/// extern crate google_drive3 as drive3;
2569///
2570/// # async fn dox() {
2571/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2572///
2573/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2574/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2575/// .with_native_roots()
2576/// .unwrap()
2577/// .https_only()
2578/// .enable_http2()
2579/// .build();
2580///
2581/// let executor = hyper_util::rt::TokioExecutor::new();
2582/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2583/// secret,
2584/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2585/// yup_oauth2::client::CustomHyperClientBuilder::from(
2586/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2587/// ),
2588/// ).build().await.unwrap();
2589///
2590/// let client = hyper_util::client::legacy::Client::builder(
2591/// hyper_util::rt::TokioExecutor::new()
2592/// )
2593/// .build(
2594/// hyper_rustls::HttpsConnectorBuilder::new()
2595/// .with_native_roots()
2596/// .unwrap()
2597/// .https_or_http()
2598/// .enable_http2()
2599/// .build()
2600/// );
2601/// let mut hub = DriveHub::new(client, auth);
2602/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2603/// // like `get(...)`
2604/// // to build up your call.
2605/// let rb = hub.about();
2606/// # }
2607/// ```
2608pub struct AboutMethods<'a, C>
2609where
2610 C: 'a,
2611{
2612 hub: &'a DriveHub<C>,
2613}
2614
2615impl<'a, C> common::MethodsBuilder for AboutMethods<'a, C> {}
2616
2617impl<'a, C> AboutMethods<'a, C> {
2618 /// Create a builder to help you perform the following task:
2619 ///
2620 /// Gets information about the user, the user's Drive, and system capabilities. For more information, see [Return user info](https://developers.google.com/workspace/drive/api/guides/user-info). Required: The `fields` parameter must be set. To return the exact fields you need, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter).
2621 pub fn get(&self) -> AboutGetCall<'a, C> {
2622 AboutGetCall {
2623 hub: self.hub,
2624 _delegate: Default::default(),
2625 _additional_params: Default::default(),
2626 _scopes: Default::default(),
2627 }
2628 }
2629}
2630
2631/// A builder providing access to all methods supported on *accessproposal* resources.
2632/// It is not used directly, but through the [`DriveHub`] hub.
2633///
2634/// # Example
2635///
2636/// Instantiate a resource builder
2637///
2638/// ```test_harness,no_run
2639/// extern crate hyper;
2640/// extern crate hyper_rustls;
2641/// extern crate google_drive3 as drive3;
2642///
2643/// # async fn dox() {
2644/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2645///
2646/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2647/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2648/// .with_native_roots()
2649/// .unwrap()
2650/// .https_only()
2651/// .enable_http2()
2652/// .build();
2653///
2654/// let executor = hyper_util::rt::TokioExecutor::new();
2655/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2656/// secret,
2657/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2658/// yup_oauth2::client::CustomHyperClientBuilder::from(
2659/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2660/// ),
2661/// ).build().await.unwrap();
2662///
2663/// let client = hyper_util::client::legacy::Client::builder(
2664/// hyper_util::rt::TokioExecutor::new()
2665/// )
2666/// .build(
2667/// hyper_rustls::HttpsConnectorBuilder::new()
2668/// .with_native_roots()
2669/// .unwrap()
2670/// .https_or_http()
2671/// .enable_http2()
2672/// .build()
2673/// );
2674/// let mut hub = DriveHub::new(client, auth);
2675/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2676/// // like `get(...)`, `list(...)` and `resolve(...)`
2677/// // to build up your call.
2678/// let rb = hub.accessproposals();
2679/// # }
2680/// ```
2681pub struct AccessproposalMethods<'a, C>
2682where
2683 C: 'a,
2684{
2685 hub: &'a DriveHub<C>,
2686}
2687
2688impl<'a, C> common::MethodsBuilder for AccessproposalMethods<'a, C> {}
2689
2690impl<'a, C> AccessproposalMethods<'a, C> {
2691 /// Create a builder to help you perform the following task:
2692 ///
2693 /// Retrieves an access proposal by ID. For more information, see [Manage pending access proposals](https://developers.google.com/workspace/drive/api/guides/pending-access).
2694 ///
2695 /// # Arguments
2696 ///
2697 /// * `fileId` - Required. The ID of the item the request is on.
2698 /// * `proposalId` - Required. The ID of the access proposal to resolve.
2699 pub fn get(&self, file_id: &str, proposal_id: &str) -> AccessproposalGetCall<'a, C> {
2700 AccessproposalGetCall {
2701 hub: self.hub,
2702 _file_id: file_id.to_string(),
2703 _proposal_id: proposal_id.to_string(),
2704 _delegate: Default::default(),
2705 _additional_params: Default::default(),
2706 _scopes: Default::default(),
2707 }
2708 }
2709
2710 /// Create a builder to help you perform the following task:
2711 ///
2712 /// List the access proposals on a file. For more information, see [Manage pending access proposals](https://developers.google.com/workspace/drive/api/guides/pending-access). Note: Only approvers are able to list access proposals on a file. If the user isn't an approver, a 403 error is returned.
2713 ///
2714 /// # Arguments
2715 ///
2716 /// * `fileId` - Required. The ID of the item the request is on.
2717 pub fn list(&self, file_id: &str) -> AccessproposalListCall<'a, C> {
2718 AccessproposalListCall {
2719 hub: self.hub,
2720 _file_id: file_id.to_string(),
2721 _page_token: Default::default(),
2722 _page_size: Default::default(),
2723 _delegate: Default::default(),
2724 _additional_params: Default::default(),
2725 _scopes: Default::default(),
2726 }
2727 }
2728
2729 /// Create a builder to help you perform the following task:
2730 ///
2731 /// Approves or denies an access proposal. For more information, see [Manage pending access proposals](https://developers.google.com/workspace/drive/api/guides/pending-access).
2732 ///
2733 /// # Arguments
2734 ///
2735 /// * `request` - No description provided.
2736 /// * `fileId` - Required. The ID of the item the request is on.
2737 /// * `proposalId` - Required. The ID of the access proposal to resolve.
2738 pub fn resolve(
2739 &self,
2740 request: ResolveAccessProposalRequest,
2741 file_id: &str,
2742 proposal_id: &str,
2743 ) -> AccessproposalResolveCall<'a, C> {
2744 AccessproposalResolveCall {
2745 hub: self.hub,
2746 _request: request,
2747 _file_id: file_id.to_string(),
2748 _proposal_id: proposal_id.to_string(),
2749 _delegate: Default::default(),
2750 _additional_params: Default::default(),
2751 _scopes: Default::default(),
2752 }
2753 }
2754}
2755
2756/// A builder providing access to all methods supported on *approval* resources.
2757/// It is not used directly, but through the [`DriveHub`] hub.
2758///
2759/// # Example
2760///
2761/// Instantiate a resource builder
2762///
2763/// ```test_harness,no_run
2764/// extern crate hyper;
2765/// extern crate hyper_rustls;
2766/// extern crate google_drive3 as drive3;
2767///
2768/// # async fn dox() {
2769/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2770///
2771/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2772/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2773/// .with_native_roots()
2774/// .unwrap()
2775/// .https_only()
2776/// .enable_http2()
2777/// .build();
2778///
2779/// let executor = hyper_util::rt::TokioExecutor::new();
2780/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2781/// secret,
2782/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2783/// yup_oauth2::client::CustomHyperClientBuilder::from(
2784/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2785/// ),
2786/// ).build().await.unwrap();
2787///
2788/// let client = hyper_util::client::legacy::Client::builder(
2789/// hyper_util::rt::TokioExecutor::new()
2790/// )
2791/// .build(
2792/// hyper_rustls::HttpsConnectorBuilder::new()
2793/// .with_native_roots()
2794/// .unwrap()
2795/// .https_or_http()
2796/// .enable_http2()
2797/// .build()
2798/// );
2799/// let mut hub = DriveHub::new(client, auth);
2800/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2801/// // like `get(...)` and `list(...)`
2802/// // to build up your call.
2803/// let rb = hub.approvals();
2804/// # }
2805/// ```
2806pub struct ApprovalMethods<'a, C>
2807where
2808 C: 'a,
2809{
2810 hub: &'a DriveHub<C>,
2811}
2812
2813impl<'a, C> common::MethodsBuilder for ApprovalMethods<'a, C> {}
2814
2815impl<'a, C> ApprovalMethods<'a, C> {
2816 /// Create a builder to help you perform the following task:
2817 ///
2818 /// Gets an Approval by ID.
2819 ///
2820 /// # Arguments
2821 ///
2822 /// * `fileId` - Required. The ID of the file the Approval is on.
2823 /// * `approvalId` - Required. The ID of the Approval.
2824 pub fn get(&self, file_id: &str, approval_id: &str) -> ApprovalGetCall<'a, C> {
2825 ApprovalGetCall {
2826 hub: self.hub,
2827 _file_id: file_id.to_string(),
2828 _approval_id: approval_id.to_string(),
2829 _delegate: Default::default(),
2830 _additional_params: Default::default(),
2831 _scopes: Default::default(),
2832 }
2833 }
2834
2835 /// Create a builder to help you perform the following task:
2836 ///
2837 /// Lists the Approvals on a file.
2838 ///
2839 /// # Arguments
2840 ///
2841 /// * `fileId` - Required. The ID of the file the Approval is on.
2842 pub fn list(&self, file_id: &str) -> ApprovalListCall<'a, C> {
2843 ApprovalListCall {
2844 hub: self.hub,
2845 _file_id: file_id.to_string(),
2846 _page_token: Default::default(),
2847 _page_size: Default::default(),
2848 _delegate: Default::default(),
2849 _additional_params: Default::default(),
2850 _scopes: Default::default(),
2851 }
2852 }
2853}
2854
2855/// A builder providing access to all methods supported on *app* resources.
2856/// It is not used directly, but through the [`DriveHub`] hub.
2857///
2858/// # Example
2859///
2860/// Instantiate a resource builder
2861///
2862/// ```test_harness,no_run
2863/// extern crate hyper;
2864/// extern crate hyper_rustls;
2865/// extern crate google_drive3 as drive3;
2866///
2867/// # async fn dox() {
2868/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2869///
2870/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2871/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2872/// .with_native_roots()
2873/// .unwrap()
2874/// .https_only()
2875/// .enable_http2()
2876/// .build();
2877///
2878/// let executor = hyper_util::rt::TokioExecutor::new();
2879/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2880/// secret,
2881/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2882/// yup_oauth2::client::CustomHyperClientBuilder::from(
2883/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2884/// ),
2885/// ).build().await.unwrap();
2886///
2887/// let client = hyper_util::client::legacy::Client::builder(
2888/// hyper_util::rt::TokioExecutor::new()
2889/// )
2890/// .build(
2891/// hyper_rustls::HttpsConnectorBuilder::new()
2892/// .with_native_roots()
2893/// .unwrap()
2894/// .https_or_http()
2895/// .enable_http2()
2896/// .build()
2897/// );
2898/// let mut hub = DriveHub::new(client, auth);
2899/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2900/// // like `get(...)` and `list(...)`
2901/// // to build up your call.
2902/// let rb = hub.apps();
2903/// # }
2904/// ```
2905pub struct AppMethods<'a, C>
2906where
2907 C: 'a,
2908{
2909 hub: &'a DriveHub<C>,
2910}
2911
2912impl<'a, C> common::MethodsBuilder for AppMethods<'a, C> {}
2913
2914impl<'a, C> AppMethods<'a, C> {
2915 /// Create a builder to help you perform the following task:
2916 ///
2917 /// Gets a specific app. For more information, see [Return user info](https://developers.google.com/workspace/drive/api/guides/user-info).
2918 ///
2919 /// # Arguments
2920 ///
2921 /// * `appId` - The ID of the app.
2922 pub fn get(&self, app_id: &str) -> AppGetCall<'a, C> {
2923 AppGetCall {
2924 hub: self.hub,
2925 _app_id: app_id.to_string(),
2926 _delegate: Default::default(),
2927 _additional_params: Default::default(),
2928 _scopes: Default::default(),
2929 }
2930 }
2931
2932 /// Create a builder to help you perform the following task:
2933 ///
2934 /// Lists a user's installed apps. For more information, see [Return user info](https://developers.google.com/workspace/drive/api/guides/user-info).
2935 pub fn list(&self) -> AppListCall<'a, C> {
2936 AppListCall {
2937 hub: self.hub,
2938 _language_code: Default::default(),
2939 _app_filter_mime_types: Default::default(),
2940 _app_filter_extensions: Default::default(),
2941 _delegate: Default::default(),
2942 _additional_params: Default::default(),
2943 _scopes: Default::default(),
2944 }
2945 }
2946}
2947
2948/// A builder providing access to all methods supported on *change* resources.
2949/// It is not used directly, but through the [`DriveHub`] hub.
2950///
2951/// # Example
2952///
2953/// Instantiate a resource builder
2954///
2955/// ```test_harness,no_run
2956/// extern crate hyper;
2957/// extern crate hyper_rustls;
2958/// extern crate google_drive3 as drive3;
2959///
2960/// # async fn dox() {
2961/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2962///
2963/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2964/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2965/// .with_native_roots()
2966/// .unwrap()
2967/// .https_only()
2968/// .enable_http2()
2969/// .build();
2970///
2971/// let executor = hyper_util::rt::TokioExecutor::new();
2972/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2973/// secret,
2974/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2975/// yup_oauth2::client::CustomHyperClientBuilder::from(
2976/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2977/// ),
2978/// ).build().await.unwrap();
2979///
2980/// let client = hyper_util::client::legacy::Client::builder(
2981/// hyper_util::rt::TokioExecutor::new()
2982/// )
2983/// .build(
2984/// hyper_rustls::HttpsConnectorBuilder::new()
2985/// .with_native_roots()
2986/// .unwrap()
2987/// .https_or_http()
2988/// .enable_http2()
2989/// .build()
2990/// );
2991/// let mut hub = DriveHub::new(client, auth);
2992/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2993/// // like `get_start_page_token(...)`, `list(...)` and `watch(...)`
2994/// // to build up your call.
2995/// let rb = hub.changes();
2996/// # }
2997/// ```
2998pub struct ChangeMethods<'a, C>
2999where
3000 C: 'a,
3001{
3002 hub: &'a DriveHub<C>,
3003}
3004
3005impl<'a, C> common::MethodsBuilder for ChangeMethods<'a, C> {}
3006
3007impl<'a, C> ChangeMethods<'a, C> {
3008 /// Create a builder to help you perform the following task:
3009 ///
3010 /// Gets the starting pageToken for listing future changes. For more information, see [Retrieve changes](https://developers.google.com/workspace/drive/api/guides/manage-changes).
3011 pub fn get_start_page_token(&self) -> ChangeGetStartPageTokenCall<'a, C> {
3012 ChangeGetStartPageTokenCall {
3013 hub: self.hub,
3014 _team_drive_id: Default::default(),
3015 _supports_team_drives: Default::default(),
3016 _supports_all_drives: Default::default(),
3017 _drive_id: Default::default(),
3018 _delegate: Default::default(),
3019 _additional_params: Default::default(),
3020 _scopes: Default::default(),
3021 }
3022 }
3023
3024 /// Create a builder to help you perform the following task:
3025 ///
3026 /// Lists the changes for a user or shared drive. For more information, see [Retrieve changes](https://developers.google.com/workspace/drive/api/guides/manage-changes).
3027 ///
3028 /// # Arguments
3029 ///
3030 /// * `pageToken` - The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.
3031 pub fn list(&self, page_token: &str) -> ChangeListCall<'a, C> {
3032 ChangeListCall {
3033 hub: self.hub,
3034 _page_token: page_token.to_string(),
3035 _team_drive_id: Default::default(),
3036 _supports_team_drives: Default::default(),
3037 _supports_all_drives: Default::default(),
3038 _spaces: Default::default(),
3039 _restrict_to_my_drive: Default::default(),
3040 _page_size: Default::default(),
3041 _include_team_drive_items: Default::default(),
3042 _include_removed: Default::default(),
3043 _include_permissions_for_view: Default::default(),
3044 _include_labels: Default::default(),
3045 _include_items_from_all_drives: Default::default(),
3046 _include_corpus_removals: Default::default(),
3047 _drive_id: Default::default(),
3048 _delegate: Default::default(),
3049 _additional_params: Default::default(),
3050 _scopes: Default::default(),
3051 }
3052 }
3053
3054 /// Create a builder to help you perform the following task:
3055 ///
3056 /// Subscribes to changes for a user. For more information, see [Notifications for resource changes](https://developers.google.com/workspace/drive/api/guides/push).
3057 ///
3058 /// # Arguments
3059 ///
3060 /// * `request` - No description provided.
3061 /// * `pageToken` - The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.
3062 pub fn watch(&self, request: Channel, page_token: &str) -> ChangeWatchCall<'a, C> {
3063 ChangeWatchCall {
3064 hub: self.hub,
3065 _request: request,
3066 _page_token: page_token.to_string(),
3067 _team_drive_id: Default::default(),
3068 _supports_team_drives: Default::default(),
3069 _supports_all_drives: Default::default(),
3070 _spaces: Default::default(),
3071 _restrict_to_my_drive: Default::default(),
3072 _page_size: Default::default(),
3073 _include_team_drive_items: Default::default(),
3074 _include_removed: Default::default(),
3075 _include_permissions_for_view: Default::default(),
3076 _include_labels: Default::default(),
3077 _include_items_from_all_drives: Default::default(),
3078 _include_corpus_removals: Default::default(),
3079 _drive_id: Default::default(),
3080 _delegate: Default::default(),
3081 _additional_params: Default::default(),
3082 _scopes: Default::default(),
3083 }
3084 }
3085}
3086
3087/// A builder providing access to all methods supported on *channel* resources.
3088/// It is not used directly, but through the [`DriveHub`] hub.
3089///
3090/// # Example
3091///
3092/// Instantiate a resource builder
3093///
3094/// ```test_harness,no_run
3095/// extern crate hyper;
3096/// extern crate hyper_rustls;
3097/// extern crate google_drive3 as drive3;
3098///
3099/// # async fn dox() {
3100/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3101///
3102/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3103/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3104/// .with_native_roots()
3105/// .unwrap()
3106/// .https_only()
3107/// .enable_http2()
3108/// .build();
3109///
3110/// let executor = hyper_util::rt::TokioExecutor::new();
3111/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3112/// secret,
3113/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3114/// yup_oauth2::client::CustomHyperClientBuilder::from(
3115/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3116/// ),
3117/// ).build().await.unwrap();
3118///
3119/// let client = hyper_util::client::legacy::Client::builder(
3120/// hyper_util::rt::TokioExecutor::new()
3121/// )
3122/// .build(
3123/// hyper_rustls::HttpsConnectorBuilder::new()
3124/// .with_native_roots()
3125/// .unwrap()
3126/// .https_or_http()
3127/// .enable_http2()
3128/// .build()
3129/// );
3130/// let mut hub = DriveHub::new(client, auth);
3131/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3132/// // like `stop(...)`
3133/// // to build up your call.
3134/// let rb = hub.channels();
3135/// # }
3136/// ```
3137pub struct ChannelMethods<'a, C>
3138where
3139 C: 'a,
3140{
3141 hub: &'a DriveHub<C>,
3142}
3143
3144impl<'a, C> common::MethodsBuilder for ChannelMethods<'a, C> {}
3145
3146impl<'a, C> ChannelMethods<'a, C> {
3147 /// Create a builder to help you perform the following task:
3148 ///
3149 /// Stops watching resources through this channel. For more information, see [Notifications for resource changes](https://developers.google.com/workspace/drive/api/guides/push).
3150 ///
3151 /// # Arguments
3152 ///
3153 /// * `request` - No description provided.
3154 pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C> {
3155 ChannelStopCall {
3156 hub: self.hub,
3157 _request: request,
3158 _delegate: Default::default(),
3159 _additional_params: Default::default(),
3160 _scopes: Default::default(),
3161 }
3162 }
3163}
3164
3165/// A builder providing access to all methods supported on *comment* resources.
3166/// It is not used directly, but through the [`DriveHub`] hub.
3167///
3168/// # Example
3169///
3170/// Instantiate a resource builder
3171///
3172/// ```test_harness,no_run
3173/// extern crate hyper;
3174/// extern crate hyper_rustls;
3175/// extern crate google_drive3 as drive3;
3176///
3177/// # async fn dox() {
3178/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3179///
3180/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3181/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3182/// .with_native_roots()
3183/// .unwrap()
3184/// .https_only()
3185/// .enable_http2()
3186/// .build();
3187///
3188/// let executor = hyper_util::rt::TokioExecutor::new();
3189/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3190/// secret,
3191/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3192/// yup_oauth2::client::CustomHyperClientBuilder::from(
3193/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3194/// ),
3195/// ).build().await.unwrap();
3196///
3197/// let client = hyper_util::client::legacy::Client::builder(
3198/// hyper_util::rt::TokioExecutor::new()
3199/// )
3200/// .build(
3201/// hyper_rustls::HttpsConnectorBuilder::new()
3202/// .with_native_roots()
3203/// .unwrap()
3204/// .https_or_http()
3205/// .enable_http2()
3206/// .build()
3207/// );
3208/// let mut hub = DriveHub::new(client, auth);
3209/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3210/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `update(...)`
3211/// // to build up your call.
3212/// let rb = hub.comments();
3213/// # }
3214/// ```
3215pub struct CommentMethods<'a, C>
3216where
3217 C: 'a,
3218{
3219 hub: &'a DriveHub<C>,
3220}
3221
3222impl<'a, C> common::MethodsBuilder for CommentMethods<'a, C> {}
3223
3224impl<'a, C> CommentMethods<'a, C> {
3225 /// Create a builder to help you perform the following task:
3226 ///
3227 /// Creates a comment on a file. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments). Required: The `fields` parameter must be set. To return the exact fields you need, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter).
3228 ///
3229 /// # Arguments
3230 ///
3231 /// * `request` - No description provided.
3232 /// * `fileId` - The ID of the file.
3233 pub fn create(&self, request: Comment, file_id: &str) -> CommentCreateCall<'a, C> {
3234 CommentCreateCall {
3235 hub: self.hub,
3236 _request: request,
3237 _file_id: file_id.to_string(),
3238 _delegate: Default::default(),
3239 _additional_params: Default::default(),
3240 _scopes: Default::default(),
3241 }
3242 }
3243
3244 /// Create a builder to help you perform the following task:
3245 ///
3246 /// Deletes a comment. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
3247 ///
3248 /// # Arguments
3249 ///
3250 /// * `fileId` - The ID of the file.
3251 /// * `commentId` - The ID of the comment.
3252 pub fn delete(&self, file_id: &str, comment_id: &str) -> CommentDeleteCall<'a, C> {
3253 CommentDeleteCall {
3254 hub: self.hub,
3255 _file_id: file_id.to_string(),
3256 _comment_id: comment_id.to_string(),
3257 _delegate: Default::default(),
3258 _additional_params: Default::default(),
3259 _scopes: Default::default(),
3260 }
3261 }
3262
3263 /// Create a builder to help you perform the following task:
3264 ///
3265 /// Gets a comment by ID. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments). Required: The `fields` parameter must be set. To return the exact fields you need, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter).
3266 ///
3267 /// # Arguments
3268 ///
3269 /// * `fileId` - The ID of the file.
3270 /// * `commentId` - The ID of the comment.
3271 pub fn get(&self, file_id: &str, comment_id: &str) -> CommentGetCall<'a, C> {
3272 CommentGetCall {
3273 hub: self.hub,
3274 _file_id: file_id.to_string(),
3275 _comment_id: comment_id.to_string(),
3276 _include_deleted: Default::default(),
3277 _delegate: Default::default(),
3278 _additional_params: Default::default(),
3279 _scopes: Default::default(),
3280 }
3281 }
3282
3283 /// Create a builder to help you perform the following task:
3284 ///
3285 /// Lists a file's comments. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments). Required: The `fields` parameter must be set. To return the exact fields you need, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter).
3286 ///
3287 /// # Arguments
3288 ///
3289 /// * `fileId` - The ID of the file.
3290 pub fn list(&self, file_id: &str) -> CommentListCall<'a, C> {
3291 CommentListCall {
3292 hub: self.hub,
3293 _file_id: file_id.to_string(),
3294 _start_modified_time: Default::default(),
3295 _page_token: Default::default(),
3296 _page_size: Default::default(),
3297 _include_deleted: Default::default(),
3298 _delegate: Default::default(),
3299 _additional_params: Default::default(),
3300 _scopes: Default::default(),
3301 }
3302 }
3303
3304 /// Create a builder to help you perform the following task:
3305 ///
3306 /// Updates a comment with patch semantics. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments). Required: The `fields` parameter must be set. To return the exact fields you need, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter).
3307 ///
3308 /// # Arguments
3309 ///
3310 /// * `request` - No description provided.
3311 /// * `fileId` - The ID of the file.
3312 /// * `commentId` - The ID of the comment.
3313 pub fn update(
3314 &self,
3315 request: Comment,
3316 file_id: &str,
3317 comment_id: &str,
3318 ) -> CommentUpdateCall<'a, C> {
3319 CommentUpdateCall {
3320 hub: self.hub,
3321 _request: request,
3322 _file_id: file_id.to_string(),
3323 _comment_id: comment_id.to_string(),
3324 _delegate: Default::default(),
3325 _additional_params: Default::default(),
3326 _scopes: Default::default(),
3327 }
3328 }
3329}
3330
3331/// A builder providing access to all methods supported on *drive* resources.
3332/// It is not used directly, but through the [`DriveHub`] hub.
3333///
3334/// # Example
3335///
3336/// Instantiate a resource builder
3337///
3338/// ```test_harness,no_run
3339/// extern crate hyper;
3340/// extern crate hyper_rustls;
3341/// extern crate google_drive3 as drive3;
3342///
3343/// # async fn dox() {
3344/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3345///
3346/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3347/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3348/// .with_native_roots()
3349/// .unwrap()
3350/// .https_only()
3351/// .enable_http2()
3352/// .build();
3353///
3354/// let executor = hyper_util::rt::TokioExecutor::new();
3355/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3356/// secret,
3357/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3358/// yup_oauth2::client::CustomHyperClientBuilder::from(
3359/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3360/// ),
3361/// ).build().await.unwrap();
3362///
3363/// let client = hyper_util::client::legacy::Client::builder(
3364/// hyper_util::rt::TokioExecutor::new()
3365/// )
3366/// .build(
3367/// hyper_rustls::HttpsConnectorBuilder::new()
3368/// .with_native_roots()
3369/// .unwrap()
3370/// .https_or_http()
3371/// .enable_http2()
3372/// .build()
3373/// );
3374/// let mut hub = DriveHub::new(client, auth);
3375/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3376/// // like `create(...)`, `delete(...)`, `get(...)`, `hide(...)`, `list(...)`, `unhide(...)` and `update(...)`
3377/// // to build up your call.
3378/// let rb = hub.drives();
3379/// # }
3380/// ```
3381pub struct DriveMethods<'a, C>
3382where
3383 C: 'a,
3384{
3385 hub: &'a DriveHub<C>,
3386}
3387
3388impl<'a, C> common::MethodsBuilder for DriveMethods<'a, C> {}
3389
3390impl<'a, C> DriveMethods<'a, C> {
3391 /// Create a builder to help you perform the following task:
3392 ///
3393 /// Creates a shared drive. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
3394 ///
3395 /// # Arguments
3396 ///
3397 /// * `request` - No description provided.
3398 /// * `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.
3399 pub fn create(&self, request: Drive, request_id: &str) -> DriveCreateCall<'a, C> {
3400 DriveCreateCall {
3401 hub: self.hub,
3402 _request: request,
3403 _request_id: request_id.to_string(),
3404 _delegate: Default::default(),
3405 _additional_params: Default::default(),
3406 _scopes: Default::default(),
3407 }
3408 }
3409
3410 /// Create a builder to help you perform the following task:
3411 ///
3412 /// Permanently deletes a shared drive for which the user is an `organizer`. The shared drive cannot contain any untrashed items. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
3413 ///
3414 /// # Arguments
3415 ///
3416 /// * `driveId` - The ID of the shared drive.
3417 pub fn delete(&self, drive_id: &str) -> DriveDeleteCall<'a, C> {
3418 DriveDeleteCall {
3419 hub: self.hub,
3420 _drive_id: drive_id.to_string(),
3421 _use_domain_admin_access: Default::default(),
3422 _allow_item_deletion: Default::default(),
3423 _delegate: Default::default(),
3424 _additional_params: Default::default(),
3425 _scopes: Default::default(),
3426 }
3427 }
3428
3429 /// Create a builder to help you perform the following task:
3430 ///
3431 /// Gets a shared drive's metadata by ID. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
3432 ///
3433 /// # Arguments
3434 ///
3435 /// * `driveId` - The ID of the shared drive.
3436 pub fn get(&self, drive_id: &str) -> DriveGetCall<'a, C> {
3437 DriveGetCall {
3438 hub: self.hub,
3439 _drive_id: drive_id.to_string(),
3440 _use_domain_admin_access: Default::default(),
3441 _delegate: Default::default(),
3442 _additional_params: Default::default(),
3443 _scopes: Default::default(),
3444 }
3445 }
3446
3447 /// Create a builder to help you perform the following task:
3448 ///
3449 /// Hides a shared drive from the default view. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
3450 ///
3451 /// # Arguments
3452 ///
3453 /// * `driveId` - The ID of the shared drive.
3454 pub fn hide(&self, drive_id: &str) -> DriveHideCall<'a, C> {
3455 DriveHideCall {
3456 hub: self.hub,
3457 _drive_id: drive_id.to_string(),
3458 _delegate: Default::default(),
3459 _additional_params: Default::default(),
3460 _scopes: Default::default(),
3461 }
3462 }
3463
3464 /// Create a builder to help you perform the following task:
3465 ///
3466 /// 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.
3467 pub fn list(&self) -> DriveListCall<'a, C> {
3468 DriveListCall {
3469 hub: self.hub,
3470 _use_domain_admin_access: Default::default(),
3471 _q: Default::default(),
3472 _page_token: Default::default(),
3473 _page_size: Default::default(),
3474 _delegate: Default::default(),
3475 _additional_params: Default::default(),
3476 _scopes: Default::default(),
3477 }
3478 }
3479
3480 /// Create a builder to help you perform the following task:
3481 ///
3482 /// Restores a shared drive to the default view. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
3483 ///
3484 /// # Arguments
3485 ///
3486 /// * `driveId` - The ID of the shared drive.
3487 pub fn unhide(&self, drive_id: &str) -> DriveUnhideCall<'a, C> {
3488 DriveUnhideCall {
3489 hub: self.hub,
3490 _drive_id: drive_id.to_string(),
3491 _delegate: Default::default(),
3492 _additional_params: Default::default(),
3493 _scopes: Default::default(),
3494 }
3495 }
3496
3497 /// Create a builder to help you perform the following task:
3498 ///
3499 /// Updates the metadata for a shared drive. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
3500 ///
3501 /// # Arguments
3502 ///
3503 /// * `request` - No description provided.
3504 /// * `driveId` - The ID of the shared drive.
3505 pub fn update(&self, request: Drive, drive_id: &str) -> DriveUpdateCall<'a, C> {
3506 DriveUpdateCall {
3507 hub: self.hub,
3508 _request: request,
3509 _drive_id: drive_id.to_string(),
3510 _use_domain_admin_access: Default::default(),
3511 _delegate: Default::default(),
3512 _additional_params: Default::default(),
3513 _scopes: Default::default(),
3514 }
3515 }
3516}
3517
3518/// A builder providing access to all methods supported on *file* resources.
3519/// It is not used directly, but through the [`DriveHub`] hub.
3520///
3521/// # Example
3522///
3523/// Instantiate a resource builder
3524///
3525/// ```test_harness,no_run
3526/// extern crate hyper;
3527/// extern crate hyper_rustls;
3528/// extern crate google_drive3 as drive3;
3529///
3530/// # async fn dox() {
3531/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3532///
3533/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3534/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3535/// .with_native_roots()
3536/// .unwrap()
3537/// .https_only()
3538/// .enable_http2()
3539/// .build();
3540///
3541/// let executor = hyper_util::rt::TokioExecutor::new();
3542/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3543/// secret,
3544/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3545/// yup_oauth2::client::CustomHyperClientBuilder::from(
3546/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3547/// ),
3548/// ).build().await.unwrap();
3549///
3550/// let client = hyper_util::client::legacy::Client::builder(
3551/// hyper_util::rt::TokioExecutor::new()
3552/// )
3553/// .build(
3554/// hyper_rustls::HttpsConnectorBuilder::new()
3555/// .with_native_roots()
3556/// .unwrap()
3557/// .https_or_http()
3558/// .enable_http2()
3559/// .build()
3560/// );
3561/// let mut hub = DriveHub::new(client, auth);
3562/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3563/// // like `copy(...)`, `create(...)`, `delete(...)`, `download(...)`, `empty_trash(...)`, `export(...)`, `generate_ids(...)`, `get(...)`, `list(...)`, `list_labels(...)`, `modify_labels(...)`, `update(...)` and `watch(...)`
3564/// // to build up your call.
3565/// let rb = hub.files();
3566/// # }
3567/// ```
3568pub struct FileMethods<'a, C>
3569where
3570 C: 'a,
3571{
3572 hub: &'a DriveHub<C>,
3573}
3574
3575impl<'a, C> common::MethodsBuilder for FileMethods<'a, C> {}
3576
3577impl<'a, C> FileMethods<'a, C> {
3578 /// Create a builder to help you perform the following task:
3579 ///
3580 /// Creates a copy of a file and applies any requested updates with patch semantics. For more information, see [Create and manage files](https://developers.google.com/workspace/drive/api/guides/create-file).
3581 ///
3582 /// # Arguments
3583 ///
3584 /// * `request` - No description provided.
3585 /// * `fileId` - The ID of the file.
3586 pub fn copy(&self, request: File, file_id: &str) -> FileCopyCall<'a, C> {
3587 FileCopyCall {
3588 hub: self.hub,
3589 _request: request,
3590 _file_id: file_id.to_string(),
3591 _supports_team_drives: Default::default(),
3592 _supports_all_drives: Default::default(),
3593 _ocr_language: Default::default(),
3594 _keep_revision_forever: Default::default(),
3595 _include_permissions_for_view: Default::default(),
3596 _include_labels: Default::default(),
3597 _ignore_default_visibility: Default::default(),
3598 _enforce_single_parent: Default::default(),
3599 _delegate: Default::default(),
3600 _additional_params: Default::default(),
3601 _scopes: Default::default(),
3602 }
3603 }
3604
3605 /// Create a builder to help you perform the following task:
3606 ///
3607 /// Creates a file. For more information, see [Create and manage files](https://developers.google.com/workspace/drive/api/guides/create-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:* `*/*` (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). Apps creating shortcuts with the `create` method must specify the MIME type `application/vnd.google-apps.shortcut`. Apps should specify a file extension in the `name` property when inserting files with the API. For example, an operation to insert a JPEG file should specify something like `"name": "cat.jpg"` in the metadata. Subsequent `GET` requests include the read-only `fileExtension` property populated with the extension originally specified in the `name` 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 name. In cases where the extension is missing, Drive attempts to determine the extension based on the file’s MIME type.
3608 ///
3609 /// # Arguments
3610 ///
3611 /// * `request` - No description provided.
3612 pub fn create(&self, request: File) -> FileCreateCall<'a, C> {
3613 FileCreateCall {
3614 hub: self.hub,
3615 _request: request,
3616 _use_content_as_indexable_text: Default::default(),
3617 _supports_team_drives: Default::default(),
3618 _supports_all_drives: Default::default(),
3619 _ocr_language: Default::default(),
3620 _keep_revision_forever: Default::default(),
3621 _include_permissions_for_view: Default::default(),
3622 _include_labels: Default::default(),
3623 _ignore_default_visibility: Default::default(),
3624 _enforce_single_parent: Default::default(),
3625 _delegate: Default::default(),
3626 _additional_params: Default::default(),
3627 _scopes: Default::default(),
3628 }
3629 }
3630
3631 /// Create a builder to help you perform the following task:
3632 ///
3633 /// Permanently deletes a file owned by the user without moving it to the trash. For more information, see [Trash or delete files and folders](https://developers.google.com/workspace/drive/api/guides/delete). 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.
3634 ///
3635 /// # Arguments
3636 ///
3637 /// * `fileId` - The ID of the file.
3638 pub fn delete(&self, file_id: &str) -> FileDeleteCall<'a, C> {
3639 FileDeleteCall {
3640 hub: self.hub,
3641 _file_id: file_id.to_string(),
3642 _supports_team_drives: Default::default(),
3643 _supports_all_drives: Default::default(),
3644 _enforce_single_parent: Default::default(),
3645 _delegate: Default::default(),
3646 _additional_params: Default::default(),
3647 _scopes: Default::default(),
3648 }
3649 }
3650
3651 /// Create a builder to help you perform the following task:
3652 ///
3653 /// Downloads the content of a file. For more information, see [Download and export files](https://developers.google.com/workspace/drive/api/guides/manage-downloads). Operations are valid for 24 hours from the time of creation.
3654 ///
3655 /// # Arguments
3656 ///
3657 /// * `fileId` - Required. The ID of the file to download.
3658 pub fn download(&self, file_id: &str) -> FileDownloadCall<'a, C> {
3659 FileDownloadCall {
3660 hub: self.hub,
3661 _file_id: file_id.to_string(),
3662 _revision_id: Default::default(),
3663 _mime_type: Default::default(),
3664 _delegate: Default::default(),
3665 _additional_params: Default::default(),
3666 _scopes: Default::default(),
3667 }
3668 }
3669
3670 /// Create a builder to help you perform the following task:
3671 ///
3672 /// Permanently deletes all of the user's trashed files. For more information, see [Trash or delete files and folders](https://developers.google.com/workspace/drive/api/guides/delete).
3673 pub fn empty_trash(&self) -> FileEmptyTrashCall<'a, C> {
3674 FileEmptyTrashCall {
3675 hub: self.hub,
3676 _enforce_single_parent: Default::default(),
3677 _drive_id: Default::default(),
3678 _delegate: Default::default(),
3679 _additional_params: Default::default(),
3680 _scopes: Default::default(),
3681 }
3682 }
3683
3684 /// Create a builder to help you perform the following task:
3685 ///
3686 /// Exports a Google Workspace document to the requested MIME type and returns exported byte content. For more information, see [Download and export files](https://developers.google.com/workspace/drive/api/guides/manage-downloads). Note that the exported content is limited to 10 MB.
3687 ///
3688 /// # Arguments
3689 ///
3690 /// * `fileId` - The ID of the file.
3691 /// * `mimeType` - Required. The MIME type of the format requested for this export. For a list of supported MIME types, see [Export MIME types for Google Workspace documents](https://developers.google.com/workspace/drive/api/guides/ref-export-formats).
3692 pub fn export(&self, file_id: &str, mime_type: &str) -> FileExportCall<'a, C> {
3693 FileExportCall {
3694 hub: self.hub,
3695 _file_id: file_id.to_string(),
3696 _mime_type: mime_type.to_string(),
3697 _delegate: Default::default(),
3698 _additional_params: Default::default(),
3699 _scopes: Default::default(),
3700 }
3701 }
3702
3703 /// Create a builder to help you perform the following task:
3704 ///
3705 /// Generates a set of file IDs which can be provided in create or copy requests. For more information, see [Create and manage files](https://developers.google.com/workspace/drive/api/guides/create-file).
3706 pub fn generate_ids(&self) -> FileGenerateIdCall<'a, C> {
3707 FileGenerateIdCall {
3708 hub: self.hub,
3709 _type_: Default::default(),
3710 _space: Default::default(),
3711 _count: Default::default(),
3712 _delegate: Default::default(),
3713 _additional_params: Default::default(),
3714 _scopes: Default::default(),
3715 }
3716 }
3717
3718 /// Create a builder to help you perform the following task:
3719 ///
3720 /// Gets a file’s metadata or content by ID. For more information, see [Search for files and folders](https://developers.google.com/workspace/drive/api/guides/search-files). 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/v3/files/export) instead. For more information, see [Download and export files](https://developers.google.com/workspace/drive/api/guides/manage-downloads).
3721 ///
3722 /// # Arguments
3723 ///
3724 /// * `fileId` - The ID of the file.
3725 pub fn get(&self, file_id: &str) -> FileGetCall<'a, C> {
3726 FileGetCall {
3727 hub: self.hub,
3728 _file_id: file_id.to_string(),
3729 _supports_team_drives: Default::default(),
3730 _supports_all_drives: Default::default(),
3731 _include_permissions_for_view: Default::default(),
3732 _include_labels: Default::default(),
3733 _acknowledge_abuse: Default::default(),
3734 _delegate: Default::default(),
3735 _additional_params: Default::default(),
3736 _scopes: Default::default(),
3737 }
3738 }
3739
3740 /// Create a builder to help you perform the following task:
3741 ///
3742 /// 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.
3743 pub fn list(&self) -> FileListCall<'a, C> {
3744 FileListCall {
3745 hub: self.hub,
3746 _team_drive_id: Default::default(),
3747 _supports_team_drives: Default::default(),
3748 _supports_all_drives: Default::default(),
3749 _spaces: Default::default(),
3750 _q: Default::default(),
3751 _page_token: Default::default(),
3752 _page_size: Default::default(),
3753 _order_by: Default::default(),
3754 _include_team_drive_items: Default::default(),
3755 _include_permissions_for_view: Default::default(),
3756 _include_labels: Default::default(),
3757 _include_items_from_all_drives: Default::default(),
3758 _drive_id: Default::default(),
3759 _corpus: Default::default(),
3760 _corpora: Default::default(),
3761 _delegate: Default::default(),
3762 _additional_params: Default::default(),
3763 _scopes: Default::default(),
3764 }
3765 }
3766
3767 /// Create a builder to help you perform the following task:
3768 ///
3769 /// Lists the labels on a file. For more information, see [List labels on a file](https://developers.google.com/workspace/drive/api/guides/list-labels).
3770 ///
3771 /// # Arguments
3772 ///
3773 /// * `fileId` - The ID for the file.
3774 pub fn list_labels(&self, file_id: &str) -> FileListLabelCall<'a, C> {
3775 FileListLabelCall {
3776 hub: self.hub,
3777 _file_id: file_id.to_string(),
3778 _page_token: Default::default(),
3779 _max_results: Default::default(),
3780 _delegate: Default::default(),
3781 _additional_params: Default::default(),
3782 _scopes: Default::default(),
3783 }
3784 }
3785
3786 /// Create a builder to help you perform the following task:
3787 ///
3788 /// Modifies the set of labels applied to a file. For more information, see [Set a label field on a file](https://developers.google.com/workspace/drive/api/guides/set-label). Returns a list of the labels that were added or modified.
3789 ///
3790 /// # Arguments
3791 ///
3792 /// * `request` - No description provided.
3793 /// * `fileId` - The ID of the file to which the labels belong.
3794 pub fn modify_labels(
3795 &self,
3796 request: ModifyLabelsRequest,
3797 file_id: &str,
3798 ) -> FileModifyLabelCall<'a, C> {
3799 FileModifyLabelCall {
3800 hub: self.hub,
3801 _request: request,
3802 _file_id: file_id.to_string(),
3803 _delegate: Default::default(),
3804 _additional_params: Default::default(),
3805 _scopes: Default::default(),
3806 }
3807 }
3808
3809 /// Create a builder to help you perform the following task:
3810 ///
3811 /// 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).
3812 ///
3813 /// # Arguments
3814 ///
3815 /// * `request` - No description provided.
3816 /// * `fileId` - The ID of the file.
3817 pub fn update(&self, request: File, file_id: &str) -> FileUpdateCall<'a, C> {
3818 FileUpdateCall {
3819 hub: self.hub,
3820 _request: request,
3821 _file_id: file_id.to_string(),
3822 _use_content_as_indexable_text: Default::default(),
3823 _supports_team_drives: Default::default(),
3824 _supports_all_drives: Default::default(),
3825 _remove_parents: Default::default(),
3826 _ocr_language: Default::default(),
3827 _keep_revision_forever: Default::default(),
3828 _include_permissions_for_view: Default::default(),
3829 _include_labels: Default::default(),
3830 _enforce_single_parent: Default::default(),
3831 _add_parents: Default::default(),
3832 _delegate: Default::default(),
3833 _additional_params: Default::default(),
3834 _scopes: Default::default(),
3835 }
3836 }
3837
3838 /// Create a builder to help you perform the following task:
3839 ///
3840 /// Subscribes to changes to a file. For more information, see [Notifications for resource changes](https://developers.google.com/workspace/drive/api/guides/push).
3841 ///
3842 /// # Arguments
3843 ///
3844 /// * `request` - No description provided.
3845 /// * `fileId` - The ID of the file.
3846 pub fn watch(&self, request: Channel, file_id: &str) -> FileWatchCall<'a, C> {
3847 FileWatchCall {
3848 hub: self.hub,
3849 _request: request,
3850 _file_id: file_id.to_string(),
3851 _supports_team_drives: Default::default(),
3852 _supports_all_drives: Default::default(),
3853 _include_permissions_for_view: Default::default(),
3854 _include_labels: Default::default(),
3855 _acknowledge_abuse: Default::default(),
3856 _delegate: Default::default(),
3857 _additional_params: Default::default(),
3858 _scopes: Default::default(),
3859 }
3860 }
3861}
3862
3863/// A builder providing access to all methods supported on *operation* resources.
3864/// It is not used directly, but through the [`DriveHub`] hub.
3865///
3866/// # Example
3867///
3868/// Instantiate a resource builder
3869///
3870/// ```test_harness,no_run
3871/// extern crate hyper;
3872/// extern crate hyper_rustls;
3873/// extern crate google_drive3 as drive3;
3874///
3875/// # async fn dox() {
3876/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3877///
3878/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3879/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3880/// .with_native_roots()
3881/// .unwrap()
3882/// .https_only()
3883/// .enable_http2()
3884/// .build();
3885///
3886/// let executor = hyper_util::rt::TokioExecutor::new();
3887/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3888/// secret,
3889/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3890/// yup_oauth2::client::CustomHyperClientBuilder::from(
3891/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3892/// ),
3893/// ).build().await.unwrap();
3894///
3895/// let client = hyper_util::client::legacy::Client::builder(
3896/// hyper_util::rt::TokioExecutor::new()
3897/// )
3898/// .build(
3899/// hyper_rustls::HttpsConnectorBuilder::new()
3900/// .with_native_roots()
3901/// .unwrap()
3902/// .https_or_http()
3903/// .enable_http2()
3904/// .build()
3905/// );
3906/// let mut hub = DriveHub::new(client, auth);
3907/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3908/// // like `get(...)`
3909/// // to build up your call.
3910/// let rb = hub.operations();
3911/// # }
3912/// ```
3913pub struct OperationMethods<'a, C>
3914where
3915 C: 'a,
3916{
3917 hub: &'a DriveHub<C>,
3918}
3919
3920impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
3921
3922impl<'a, C> OperationMethods<'a, C> {
3923 /// Create a builder to help you perform the following task:
3924 ///
3925 /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
3926 ///
3927 /// # Arguments
3928 ///
3929 /// * `name` - The name of the operation resource.
3930 pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
3931 OperationGetCall {
3932 hub: self.hub,
3933 _name: name.to_string(),
3934 _delegate: Default::default(),
3935 _additional_params: Default::default(),
3936 _scopes: Default::default(),
3937 }
3938 }
3939}
3940
3941/// A builder providing access to all methods supported on *permission* resources.
3942/// It is not used directly, but through the [`DriveHub`] hub.
3943///
3944/// # Example
3945///
3946/// Instantiate a resource builder
3947///
3948/// ```test_harness,no_run
3949/// extern crate hyper;
3950/// extern crate hyper_rustls;
3951/// extern crate google_drive3 as drive3;
3952///
3953/// # async fn dox() {
3954/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3955///
3956/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3957/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3958/// .with_native_roots()
3959/// .unwrap()
3960/// .https_only()
3961/// .enable_http2()
3962/// .build();
3963///
3964/// let executor = hyper_util::rt::TokioExecutor::new();
3965/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3966/// secret,
3967/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3968/// yup_oauth2::client::CustomHyperClientBuilder::from(
3969/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3970/// ),
3971/// ).build().await.unwrap();
3972///
3973/// let client = hyper_util::client::legacy::Client::builder(
3974/// hyper_util::rt::TokioExecutor::new()
3975/// )
3976/// .build(
3977/// hyper_rustls::HttpsConnectorBuilder::new()
3978/// .with_native_roots()
3979/// .unwrap()
3980/// .https_or_http()
3981/// .enable_http2()
3982/// .build()
3983/// );
3984/// let mut hub = DriveHub::new(client, auth);
3985/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3986/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `update(...)`
3987/// // to build up your call.
3988/// let rb = hub.permissions();
3989/// # }
3990/// ```
3991pub struct PermissionMethods<'a, C>
3992where
3993 C: 'a,
3994{
3995 hub: &'a DriveHub<C>,
3996}
3997
3998impl<'a, C> common::MethodsBuilder for PermissionMethods<'a, C> {}
3999
4000impl<'a, C> PermissionMethods<'a, C> {
4001 /// Create a builder to help you perform the following task:
4002 ///
4003 /// Creates a permission for a file or shared drive. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing). **Warning:** Concurrent permissions operations on the same file aren't supported; only the last update is applied.
4004 ///
4005 /// # Arguments
4006 ///
4007 /// * `request` - No description provided.
4008 /// * `fileId` - The ID of the file or shared drive.
4009 pub fn create(&self, request: Permission, file_id: &str) -> PermissionCreateCall<'a, C> {
4010 PermissionCreateCall {
4011 hub: self.hub,
4012 _request: request,
4013 _file_id: file_id.to_string(),
4014 _use_domain_admin_access: Default::default(),
4015 _transfer_ownership: Default::default(),
4016 _supports_team_drives: Default::default(),
4017 _supports_all_drives: Default::default(),
4018 _send_notification_email: Default::default(),
4019 _move_to_new_owners_root: Default::default(),
4020 _enforce_single_parent: Default::default(),
4021 _enforce_expansive_access: Default::default(),
4022 _email_message: Default::default(),
4023 _delegate: Default::default(),
4024 _additional_params: Default::default(),
4025 _scopes: Default::default(),
4026 }
4027 }
4028
4029 /// Create a builder to help you perform the following task:
4030 ///
4031 /// Deletes a permission. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing). **Warning:** Concurrent permissions operations on the same file aren't supported; only the last update is applied.
4032 ///
4033 /// # Arguments
4034 ///
4035 /// * `fileId` - The ID of the file or shared drive.
4036 /// * `permissionId` - The ID of the permission.
4037 pub fn delete(&self, file_id: &str, permission_id: &str) -> PermissionDeleteCall<'a, C> {
4038 PermissionDeleteCall {
4039 hub: self.hub,
4040 _file_id: file_id.to_string(),
4041 _permission_id: permission_id.to_string(),
4042 _use_domain_admin_access: Default::default(),
4043 _supports_team_drives: Default::default(),
4044 _supports_all_drives: Default::default(),
4045 _enforce_expansive_access: Default::default(),
4046 _delegate: Default::default(),
4047 _additional_params: Default::default(),
4048 _scopes: Default::default(),
4049 }
4050 }
4051
4052 /// Create a builder to help you perform the following task:
4053 ///
4054 /// Gets a permission by ID. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing).
4055 ///
4056 /// # Arguments
4057 ///
4058 /// * `fileId` - The ID of the file.
4059 /// * `permissionId` - The ID of the permission.
4060 pub fn get(&self, file_id: &str, permission_id: &str) -> PermissionGetCall<'a, C> {
4061 PermissionGetCall {
4062 hub: self.hub,
4063 _file_id: file_id.to_string(),
4064 _permission_id: permission_id.to_string(),
4065 _use_domain_admin_access: Default::default(),
4066 _supports_team_drives: Default::default(),
4067 _supports_all_drives: Default::default(),
4068 _delegate: Default::default(),
4069 _additional_params: Default::default(),
4070 _scopes: Default::default(),
4071 }
4072 }
4073
4074 /// Create a builder to help you perform the following task:
4075 ///
4076 /// Lists a file's or shared drive's permissions. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing).
4077 ///
4078 /// # Arguments
4079 ///
4080 /// * `fileId` - The ID of the file or shared drive.
4081 pub fn list(&self, file_id: &str) -> PermissionListCall<'a, C> {
4082 PermissionListCall {
4083 hub: self.hub,
4084 _file_id: file_id.to_string(),
4085 _use_domain_admin_access: Default::default(),
4086 _supports_team_drives: Default::default(),
4087 _supports_all_drives: Default::default(),
4088 _page_token: Default::default(),
4089 _page_size: Default::default(),
4090 _include_permissions_for_view: Default::default(),
4091 _delegate: Default::default(),
4092 _additional_params: Default::default(),
4093 _scopes: Default::default(),
4094 }
4095 }
4096
4097 /// Create a builder to help you perform the following task:
4098 ///
4099 /// Updates a permission with patch semantics. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing). **Warning:** Concurrent permissions operations on the same file aren't supported; only the last update is applied.
4100 ///
4101 /// # Arguments
4102 ///
4103 /// * `request` - No description provided.
4104 /// * `fileId` - The ID of the file or shared drive.
4105 /// * `permissionId` - The ID of the permission.
4106 pub fn update(
4107 &self,
4108 request: Permission,
4109 file_id: &str,
4110 permission_id: &str,
4111 ) -> PermissionUpdateCall<'a, C> {
4112 PermissionUpdateCall {
4113 hub: self.hub,
4114 _request: request,
4115 _file_id: file_id.to_string(),
4116 _permission_id: permission_id.to_string(),
4117 _use_domain_admin_access: Default::default(),
4118 _transfer_ownership: Default::default(),
4119 _supports_team_drives: Default::default(),
4120 _supports_all_drives: Default::default(),
4121 _remove_expiration: Default::default(),
4122 _enforce_expansive_access: Default::default(),
4123 _delegate: Default::default(),
4124 _additional_params: Default::default(),
4125 _scopes: Default::default(),
4126 }
4127 }
4128}
4129
4130/// A builder providing access to all methods supported on *reply* resources.
4131/// It is not used directly, but through the [`DriveHub`] hub.
4132///
4133/// # Example
4134///
4135/// Instantiate a resource builder
4136///
4137/// ```test_harness,no_run
4138/// extern crate hyper;
4139/// extern crate hyper_rustls;
4140/// extern crate google_drive3 as drive3;
4141///
4142/// # async fn dox() {
4143/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4144///
4145/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4146/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4147/// .with_native_roots()
4148/// .unwrap()
4149/// .https_only()
4150/// .enable_http2()
4151/// .build();
4152///
4153/// let executor = hyper_util::rt::TokioExecutor::new();
4154/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4155/// secret,
4156/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4157/// yup_oauth2::client::CustomHyperClientBuilder::from(
4158/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4159/// ),
4160/// ).build().await.unwrap();
4161///
4162/// let client = hyper_util::client::legacy::Client::builder(
4163/// hyper_util::rt::TokioExecutor::new()
4164/// )
4165/// .build(
4166/// hyper_rustls::HttpsConnectorBuilder::new()
4167/// .with_native_roots()
4168/// .unwrap()
4169/// .https_or_http()
4170/// .enable_http2()
4171/// .build()
4172/// );
4173/// let mut hub = DriveHub::new(client, auth);
4174/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4175/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `update(...)`
4176/// // to build up your call.
4177/// let rb = hub.replies();
4178/// # }
4179/// ```
4180pub struct ReplyMethods<'a, C>
4181where
4182 C: 'a,
4183{
4184 hub: &'a DriveHub<C>,
4185}
4186
4187impl<'a, C> common::MethodsBuilder for ReplyMethods<'a, C> {}
4188
4189impl<'a, C> ReplyMethods<'a, C> {
4190 /// Create a builder to help you perform the following task:
4191 ///
4192 /// Creates a reply to a comment. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
4193 ///
4194 /// # Arguments
4195 ///
4196 /// * `request` - No description provided.
4197 /// * `fileId` - The ID of the file.
4198 /// * `commentId` - The ID of the comment.
4199 pub fn create(
4200 &self,
4201 request: Reply,
4202 file_id: &str,
4203 comment_id: &str,
4204 ) -> ReplyCreateCall<'a, C> {
4205 ReplyCreateCall {
4206 hub: self.hub,
4207 _request: request,
4208 _file_id: file_id.to_string(),
4209 _comment_id: comment_id.to_string(),
4210 _delegate: Default::default(),
4211 _additional_params: Default::default(),
4212 _scopes: Default::default(),
4213 }
4214 }
4215
4216 /// Create a builder to help you perform the following task:
4217 ///
4218 /// Deletes a reply. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
4219 ///
4220 /// # Arguments
4221 ///
4222 /// * `fileId` - The ID of the file.
4223 /// * `commentId` - The ID of the comment.
4224 /// * `replyId` - The ID of the reply.
4225 pub fn delete(
4226 &self,
4227 file_id: &str,
4228 comment_id: &str,
4229 reply_id: &str,
4230 ) -> ReplyDeleteCall<'a, C> {
4231 ReplyDeleteCall {
4232 hub: self.hub,
4233 _file_id: file_id.to_string(),
4234 _comment_id: comment_id.to_string(),
4235 _reply_id: reply_id.to_string(),
4236 _delegate: Default::default(),
4237 _additional_params: Default::default(),
4238 _scopes: Default::default(),
4239 }
4240 }
4241
4242 /// Create a builder to help you perform the following task:
4243 ///
4244 /// Gets a reply by ID. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
4245 ///
4246 /// # Arguments
4247 ///
4248 /// * `fileId` - The ID of the file.
4249 /// * `commentId` - The ID of the comment.
4250 /// * `replyId` - The ID of the reply.
4251 pub fn get(&self, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyGetCall<'a, C> {
4252 ReplyGetCall {
4253 hub: self.hub,
4254 _file_id: file_id.to_string(),
4255 _comment_id: comment_id.to_string(),
4256 _reply_id: reply_id.to_string(),
4257 _include_deleted: Default::default(),
4258 _delegate: Default::default(),
4259 _additional_params: Default::default(),
4260 _scopes: Default::default(),
4261 }
4262 }
4263
4264 /// Create a builder to help you perform the following task:
4265 ///
4266 /// Lists a comment's replies. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
4267 ///
4268 /// # Arguments
4269 ///
4270 /// * `fileId` - The ID of the file.
4271 /// * `commentId` - The ID of the comment.
4272 pub fn list(&self, file_id: &str, comment_id: &str) -> ReplyListCall<'a, C> {
4273 ReplyListCall {
4274 hub: self.hub,
4275 _file_id: file_id.to_string(),
4276 _comment_id: comment_id.to_string(),
4277 _page_token: Default::default(),
4278 _page_size: Default::default(),
4279 _include_deleted: Default::default(),
4280 _delegate: Default::default(),
4281 _additional_params: Default::default(),
4282 _scopes: Default::default(),
4283 }
4284 }
4285
4286 /// Create a builder to help you perform the following task:
4287 ///
4288 /// Updates a reply with patch semantics. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
4289 ///
4290 /// # Arguments
4291 ///
4292 /// * `request` - No description provided.
4293 /// * `fileId` - The ID of the file.
4294 /// * `commentId` - The ID of the comment.
4295 /// * `replyId` - The ID of the reply.
4296 pub fn update(
4297 &self,
4298 request: Reply,
4299 file_id: &str,
4300 comment_id: &str,
4301 reply_id: &str,
4302 ) -> ReplyUpdateCall<'a, C> {
4303 ReplyUpdateCall {
4304 hub: self.hub,
4305 _request: request,
4306 _file_id: file_id.to_string(),
4307 _comment_id: comment_id.to_string(),
4308 _reply_id: reply_id.to_string(),
4309 _delegate: Default::default(),
4310 _additional_params: Default::default(),
4311 _scopes: Default::default(),
4312 }
4313 }
4314}
4315
4316/// A builder providing access to all methods supported on *revision* resources.
4317/// It is not used directly, but through the [`DriveHub`] hub.
4318///
4319/// # Example
4320///
4321/// Instantiate a resource builder
4322///
4323/// ```test_harness,no_run
4324/// extern crate hyper;
4325/// extern crate hyper_rustls;
4326/// extern crate google_drive3 as drive3;
4327///
4328/// # async fn dox() {
4329/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4330///
4331/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4332/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4333/// .with_native_roots()
4334/// .unwrap()
4335/// .https_only()
4336/// .enable_http2()
4337/// .build();
4338///
4339/// let executor = hyper_util::rt::TokioExecutor::new();
4340/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4341/// secret,
4342/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4343/// yup_oauth2::client::CustomHyperClientBuilder::from(
4344/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4345/// ),
4346/// ).build().await.unwrap();
4347///
4348/// let client = hyper_util::client::legacy::Client::builder(
4349/// hyper_util::rt::TokioExecutor::new()
4350/// )
4351/// .build(
4352/// hyper_rustls::HttpsConnectorBuilder::new()
4353/// .with_native_roots()
4354/// .unwrap()
4355/// .https_or_http()
4356/// .enable_http2()
4357/// .build()
4358/// );
4359/// let mut hub = DriveHub::new(client, auth);
4360/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4361/// // like `delete(...)`, `get(...)`, `list(...)` and `update(...)`
4362/// // to build up your call.
4363/// let rb = hub.revisions();
4364/// # }
4365/// ```
4366pub struct RevisionMethods<'a, C>
4367where
4368 C: 'a,
4369{
4370 hub: &'a DriveHub<C>,
4371}
4372
4373impl<'a, C> common::MethodsBuilder for RevisionMethods<'a, C> {}
4374
4375impl<'a, C> RevisionMethods<'a, C> {
4376 /// Create a builder to help you perform the following task:
4377 ///
4378 /// Permanently deletes a file version. You can only delete revisions for files with binary content in Google Drive, like images or videos. Revisions for other files, like Google Docs or Sheets, and the last remaining file version can't be deleted. For more information, see [Manage file revisions](https://developers.google.com/drive/api/guides/manage-revisions).
4379 ///
4380 /// # Arguments
4381 ///
4382 /// * `fileId` - The ID of the file.
4383 /// * `revisionId` - The ID of the revision.
4384 pub fn delete(&self, file_id: &str, revision_id: &str) -> RevisionDeleteCall<'a, C> {
4385 RevisionDeleteCall {
4386 hub: self.hub,
4387 _file_id: file_id.to_string(),
4388 _revision_id: revision_id.to_string(),
4389 _delegate: Default::default(),
4390 _additional_params: Default::default(),
4391 _scopes: Default::default(),
4392 }
4393 }
4394
4395 /// Create a builder to help you perform the following task:
4396 ///
4397 /// Gets a revision's metadata or content by ID. For more information, see [Manage file revisions](https://developers.google.com/workspace/drive/api/guides/manage-revisions).
4398 ///
4399 /// # Arguments
4400 ///
4401 /// * `fileId` - The ID of the file.
4402 /// * `revisionId` - The ID of the revision.
4403 pub fn get(&self, file_id: &str, revision_id: &str) -> RevisionGetCall<'a, C> {
4404 RevisionGetCall {
4405 hub: self.hub,
4406 _file_id: file_id.to_string(),
4407 _revision_id: revision_id.to_string(),
4408 _acknowledge_abuse: Default::default(),
4409 _delegate: Default::default(),
4410 _additional_params: Default::default(),
4411 _scopes: Default::default(),
4412 }
4413 }
4414
4415 /// Create a builder to help you perform the following task:
4416 ///
4417 /// Lists a file's revisions. For more information, see [Manage file revisions](https://developers.google.com/workspace/drive/api/guides/manage-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.
4418 ///
4419 /// # Arguments
4420 ///
4421 /// * `fileId` - The ID of the file.
4422 pub fn list(&self, file_id: &str) -> RevisionListCall<'a, C> {
4423 RevisionListCall {
4424 hub: self.hub,
4425 _file_id: file_id.to_string(),
4426 _page_token: Default::default(),
4427 _page_size: Default::default(),
4428 _delegate: Default::default(),
4429 _additional_params: Default::default(),
4430 _scopes: Default::default(),
4431 }
4432 }
4433
4434 /// Create a builder to help you perform the following task:
4435 ///
4436 /// Updates a revision with patch semantics. For more information, see [Manage file revisions](https://developers.google.com/workspace/drive/api/guides/manage-revisions).
4437 ///
4438 /// # Arguments
4439 ///
4440 /// * `request` - No description provided.
4441 /// * `fileId` - The ID of the file.
4442 /// * `revisionId` - The ID of the revision.
4443 pub fn update(
4444 &self,
4445 request: Revision,
4446 file_id: &str,
4447 revision_id: &str,
4448 ) -> RevisionUpdateCall<'a, C> {
4449 RevisionUpdateCall {
4450 hub: self.hub,
4451 _request: request,
4452 _file_id: file_id.to_string(),
4453 _revision_id: revision_id.to_string(),
4454 _delegate: Default::default(),
4455 _additional_params: Default::default(),
4456 _scopes: Default::default(),
4457 }
4458 }
4459}
4460
4461/// A builder providing access to all methods supported on *teamdrive* resources.
4462/// It is not used directly, but through the [`DriveHub`] hub.
4463///
4464/// # Example
4465///
4466/// Instantiate a resource builder
4467///
4468/// ```test_harness,no_run
4469/// extern crate hyper;
4470/// extern crate hyper_rustls;
4471/// extern crate google_drive3 as drive3;
4472///
4473/// # async fn dox() {
4474/// use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4475///
4476/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4477/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4478/// .with_native_roots()
4479/// .unwrap()
4480/// .https_only()
4481/// .enable_http2()
4482/// .build();
4483///
4484/// let executor = hyper_util::rt::TokioExecutor::new();
4485/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4486/// secret,
4487/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4488/// yup_oauth2::client::CustomHyperClientBuilder::from(
4489/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4490/// ),
4491/// ).build().await.unwrap();
4492///
4493/// let client = hyper_util::client::legacy::Client::builder(
4494/// hyper_util::rt::TokioExecutor::new()
4495/// )
4496/// .build(
4497/// hyper_rustls::HttpsConnectorBuilder::new()
4498/// .with_native_roots()
4499/// .unwrap()
4500/// .https_or_http()
4501/// .enable_http2()
4502/// .build()
4503/// );
4504/// let mut hub = DriveHub::new(client, auth);
4505/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4506/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `update(...)`
4507/// // to build up your call.
4508/// let rb = hub.teamdrives();
4509/// # }
4510/// ```
4511pub struct TeamdriveMethods<'a, C>
4512where
4513 C: 'a,
4514{
4515 hub: &'a DriveHub<C>,
4516}
4517
4518impl<'a, C> common::MethodsBuilder for TeamdriveMethods<'a, C> {}
4519
4520impl<'a, C> TeamdriveMethods<'a, C> {
4521 /// Create a builder to help you perform the following task:
4522 ///
4523 /// Deprecated: Use `drives.create` instead.
4524 ///
4525 /// # Arguments
4526 ///
4527 /// * `request` - No description provided.
4528 /// * `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.
4529 pub fn create(&self, request: TeamDrive, request_id: &str) -> TeamdriveCreateCall<'a, C> {
4530 TeamdriveCreateCall {
4531 hub: self.hub,
4532 _request: request,
4533 _request_id: request_id.to_string(),
4534 _delegate: Default::default(),
4535 _additional_params: Default::default(),
4536 _scopes: Default::default(),
4537 }
4538 }
4539
4540 /// Create a builder to help you perform the following task:
4541 ///
4542 /// Deprecated: Use `drives.delete` instead.
4543 ///
4544 /// # Arguments
4545 ///
4546 /// * `teamDriveId` - The ID of the Team Drive
4547 pub fn delete(&self, team_drive_id: &str) -> TeamdriveDeleteCall<'a, C> {
4548 TeamdriveDeleteCall {
4549 hub: self.hub,
4550 _team_drive_id: team_drive_id.to_string(),
4551 _delegate: Default::default(),
4552 _additional_params: Default::default(),
4553 _scopes: Default::default(),
4554 }
4555 }
4556
4557 /// Create a builder to help you perform the following task:
4558 ///
4559 /// Deprecated: Use `drives.get` instead.
4560 ///
4561 /// # Arguments
4562 ///
4563 /// * `teamDriveId` - The ID of the Team Drive
4564 pub fn get(&self, team_drive_id: &str) -> TeamdriveGetCall<'a, C> {
4565 TeamdriveGetCall {
4566 hub: self.hub,
4567 _team_drive_id: team_drive_id.to_string(),
4568 _use_domain_admin_access: Default::default(),
4569 _delegate: Default::default(),
4570 _additional_params: Default::default(),
4571 _scopes: Default::default(),
4572 }
4573 }
4574
4575 /// Create a builder to help you perform the following task:
4576 ///
4577 /// Deprecated: Use `drives.list` instead.
4578 pub fn list(&self) -> TeamdriveListCall<'a, C> {
4579 TeamdriveListCall {
4580 hub: self.hub,
4581 _use_domain_admin_access: Default::default(),
4582 _q: Default::default(),
4583 _page_token: Default::default(),
4584 _page_size: Default::default(),
4585 _delegate: Default::default(),
4586 _additional_params: Default::default(),
4587 _scopes: Default::default(),
4588 }
4589 }
4590
4591 /// Create a builder to help you perform the following task:
4592 ///
4593 /// Deprecated: Use `drives.update` instead.
4594 ///
4595 /// # Arguments
4596 ///
4597 /// * `request` - No description provided.
4598 /// * `teamDriveId` - The ID of the Team Drive
4599 pub fn update(&self, request: TeamDrive, team_drive_id: &str) -> TeamdriveUpdateCall<'a, C> {
4600 TeamdriveUpdateCall {
4601 hub: self.hub,
4602 _request: request,
4603 _team_drive_id: team_drive_id.to_string(),
4604 _use_domain_admin_access: Default::default(),
4605 _delegate: Default::default(),
4606 _additional_params: Default::default(),
4607 _scopes: Default::default(),
4608 }
4609 }
4610}
4611
4612// ###################
4613// CallBuilders ###
4614// #################
4615
4616/// Gets information about the user, the user's Drive, and system capabilities. For more information, see [Return user info](https://developers.google.com/workspace/drive/api/guides/user-info). Required: The `fields` parameter must be set. To return the exact fields you need, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter).
4617///
4618/// A builder for the *get* method supported by a *about* resource.
4619/// It is not used directly, but through a [`AboutMethods`] instance.
4620///
4621/// # Example
4622///
4623/// Instantiate a resource method builder
4624///
4625/// ```test_harness,no_run
4626/// # extern crate hyper;
4627/// # extern crate hyper_rustls;
4628/// # extern crate google_drive3 as drive3;
4629/// # async fn dox() {
4630/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4631///
4632/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4633/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4634/// # .with_native_roots()
4635/// # .unwrap()
4636/// # .https_only()
4637/// # .enable_http2()
4638/// # .build();
4639///
4640/// # let executor = hyper_util::rt::TokioExecutor::new();
4641/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4642/// # secret,
4643/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4644/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4645/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4646/// # ),
4647/// # ).build().await.unwrap();
4648///
4649/// # let client = hyper_util::client::legacy::Client::builder(
4650/// # hyper_util::rt::TokioExecutor::new()
4651/// # )
4652/// # .build(
4653/// # hyper_rustls::HttpsConnectorBuilder::new()
4654/// # .with_native_roots()
4655/// # .unwrap()
4656/// # .https_or_http()
4657/// # .enable_http2()
4658/// # .build()
4659/// # );
4660/// # let mut hub = DriveHub::new(client, auth);
4661/// // You can configure optional parameters by calling the respective setters at will, and
4662/// // execute the final call using `doit()`.
4663/// // Values shown here are possibly random and not representative !
4664/// let result = hub.about().get()
4665/// .doit().await;
4666/// # }
4667/// ```
4668pub struct AboutGetCall<'a, C>
4669where
4670 C: 'a,
4671{
4672 hub: &'a DriveHub<C>,
4673 _delegate: Option<&'a mut dyn common::Delegate>,
4674 _additional_params: HashMap<String, String>,
4675 _scopes: BTreeSet<String>,
4676}
4677
4678impl<'a, C> common::CallBuilder for AboutGetCall<'a, C> {}
4679
4680impl<'a, C> AboutGetCall<'a, C>
4681where
4682 C: common::Connector,
4683{
4684 /// Perform the operation you have build so far.
4685 pub async fn doit(mut self) -> common::Result<(common::Response, About)> {
4686 use std::borrow::Cow;
4687 use std::io::{Read, Seek};
4688
4689 use common::{url::Params, ToParts};
4690 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4691
4692 let mut dd = common::DefaultDelegate;
4693 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4694 dlg.begin(common::MethodInfo {
4695 id: "drive.about.get",
4696 http_method: hyper::Method::GET,
4697 });
4698
4699 for &field in ["alt"].iter() {
4700 if self._additional_params.contains_key(field) {
4701 dlg.finished(false);
4702 return Err(common::Error::FieldClash(field));
4703 }
4704 }
4705
4706 let mut params = Params::with_capacity(2 + self._additional_params.len());
4707
4708 params.extend(self._additional_params.iter());
4709
4710 params.push("alt", "json");
4711 let mut url = self.hub._base_url.clone() + "about";
4712 if self._scopes.is_empty() {
4713 self._scopes
4714 .insert(Scope::MetadataReadonly.as_ref().to_string());
4715 }
4716
4717 let url = params.parse_with_url(&url);
4718
4719 loop {
4720 let token = match self
4721 .hub
4722 .auth
4723 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4724 .await
4725 {
4726 Ok(token) => token,
4727 Err(e) => match dlg.token(e) {
4728 Ok(token) => token,
4729 Err(e) => {
4730 dlg.finished(false);
4731 return Err(common::Error::MissingToken(e));
4732 }
4733 },
4734 };
4735 let mut req_result = {
4736 let client = &self.hub.client;
4737 dlg.pre_request();
4738 let mut req_builder = hyper::Request::builder()
4739 .method(hyper::Method::GET)
4740 .uri(url.as_str())
4741 .header(USER_AGENT, self.hub._user_agent.clone());
4742
4743 if let Some(token) = token.as_ref() {
4744 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4745 }
4746
4747 let request = req_builder
4748 .header(CONTENT_LENGTH, 0_u64)
4749 .body(common::to_body::<String>(None));
4750
4751 client.request(request.unwrap()).await
4752 };
4753
4754 match req_result {
4755 Err(err) => {
4756 if let common::Retry::After(d) = dlg.http_error(&err) {
4757 sleep(d).await;
4758 continue;
4759 }
4760 dlg.finished(false);
4761 return Err(common::Error::HttpError(err));
4762 }
4763 Ok(res) => {
4764 let (mut parts, body) = res.into_parts();
4765 let mut body = common::Body::new(body);
4766 if !parts.status.is_success() {
4767 let bytes = common::to_bytes(body).await.unwrap_or_default();
4768 let error = serde_json::from_str(&common::to_string(&bytes));
4769 let response = common::to_response(parts, bytes.into());
4770
4771 if let common::Retry::After(d) =
4772 dlg.http_failure(&response, error.as_ref().ok())
4773 {
4774 sleep(d).await;
4775 continue;
4776 }
4777
4778 dlg.finished(false);
4779
4780 return Err(match error {
4781 Ok(value) => common::Error::BadRequest(value),
4782 _ => common::Error::Failure(response),
4783 });
4784 }
4785 let response = {
4786 let bytes = common::to_bytes(body).await.unwrap_or_default();
4787 let encoded = common::to_string(&bytes);
4788 match serde_json::from_str(&encoded) {
4789 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4790 Err(error) => {
4791 dlg.response_json_decode_error(&encoded, &error);
4792 return Err(common::Error::JsonDecodeError(
4793 encoded.to_string(),
4794 error,
4795 ));
4796 }
4797 }
4798 };
4799
4800 dlg.finished(true);
4801 return Ok(response);
4802 }
4803 }
4804 }
4805 }
4806
4807 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4808 /// while executing the actual API request.
4809 ///
4810 /// ````text
4811 /// It should be used to handle progress information, and to implement a certain level of resilience.
4812 /// ````
4813 ///
4814 /// Sets the *delegate* property to the given value.
4815 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AboutGetCall<'a, C> {
4816 self._delegate = Some(new_value);
4817 self
4818 }
4819
4820 /// Set any additional parameter of the query string used in the request.
4821 /// It should be used to set parameters which are not yet available through their own
4822 /// setters.
4823 ///
4824 /// Please note that this method must not be used to set any of the known parameters
4825 /// which have their own setter method. If done anyway, the request will fail.
4826 ///
4827 /// # Additional Parameters
4828 ///
4829 /// * *$.xgafv* (query-string) - V1 error format.
4830 /// * *access_token* (query-string) - OAuth access token.
4831 /// * *alt* (query-string) - Data format for response.
4832 /// * *callback* (query-string) - JSONP
4833 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4834 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4835 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4836 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4837 /// * *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.
4838 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4839 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4840 pub fn param<T>(mut self, name: T, value: T) -> AboutGetCall<'a, C>
4841 where
4842 T: AsRef<str>,
4843 {
4844 self._additional_params
4845 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4846 self
4847 }
4848
4849 /// Identifies the authorization scope for the method you are building.
4850 ///
4851 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4852 /// [`Scope::MetadataReadonly`].
4853 ///
4854 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4855 /// tokens for more than one scope.
4856 ///
4857 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4858 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4859 /// sufficient, a read-write scope will do as well.
4860 pub fn add_scope<St>(mut self, scope: St) -> AboutGetCall<'a, C>
4861 where
4862 St: AsRef<str>,
4863 {
4864 self._scopes.insert(String::from(scope.as_ref()));
4865 self
4866 }
4867 /// Identifies the authorization scope(s) for the method you are building.
4868 ///
4869 /// See [`Self::add_scope()`] for details.
4870 pub fn add_scopes<I, St>(mut self, scopes: I) -> AboutGetCall<'a, C>
4871 where
4872 I: IntoIterator<Item = St>,
4873 St: AsRef<str>,
4874 {
4875 self._scopes
4876 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4877 self
4878 }
4879
4880 /// Removes all scopes, and no default scope will be used either.
4881 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4882 /// for details).
4883 pub fn clear_scopes(mut self) -> AboutGetCall<'a, C> {
4884 self._scopes.clear();
4885 self
4886 }
4887}
4888
4889/// Retrieves an access proposal by ID. For more information, see [Manage pending access proposals](https://developers.google.com/workspace/drive/api/guides/pending-access).
4890///
4891/// A builder for the *get* method supported by a *accessproposal* resource.
4892/// It is not used directly, but through a [`AccessproposalMethods`] instance.
4893///
4894/// # Example
4895///
4896/// Instantiate a resource method builder
4897///
4898/// ```test_harness,no_run
4899/// # extern crate hyper;
4900/// # extern crate hyper_rustls;
4901/// # extern crate google_drive3 as drive3;
4902/// # async fn dox() {
4903/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4904///
4905/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4906/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4907/// # .with_native_roots()
4908/// # .unwrap()
4909/// # .https_only()
4910/// # .enable_http2()
4911/// # .build();
4912///
4913/// # let executor = hyper_util::rt::TokioExecutor::new();
4914/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4915/// # secret,
4916/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4917/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4918/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4919/// # ),
4920/// # ).build().await.unwrap();
4921///
4922/// # let client = hyper_util::client::legacy::Client::builder(
4923/// # hyper_util::rt::TokioExecutor::new()
4924/// # )
4925/// # .build(
4926/// # hyper_rustls::HttpsConnectorBuilder::new()
4927/// # .with_native_roots()
4928/// # .unwrap()
4929/// # .https_or_http()
4930/// # .enable_http2()
4931/// # .build()
4932/// # );
4933/// # let mut hub = DriveHub::new(client, auth);
4934/// // You can configure optional parameters by calling the respective setters at will, and
4935/// // execute the final call using `doit()`.
4936/// // Values shown here are possibly random and not representative !
4937/// let result = hub.accessproposals().get("fileId", "proposalId")
4938/// .doit().await;
4939/// # }
4940/// ```
4941pub struct AccessproposalGetCall<'a, C>
4942where
4943 C: 'a,
4944{
4945 hub: &'a DriveHub<C>,
4946 _file_id: String,
4947 _proposal_id: String,
4948 _delegate: Option<&'a mut dyn common::Delegate>,
4949 _additional_params: HashMap<String, String>,
4950 _scopes: BTreeSet<String>,
4951}
4952
4953impl<'a, C> common::CallBuilder for AccessproposalGetCall<'a, C> {}
4954
4955impl<'a, C> AccessproposalGetCall<'a, C>
4956where
4957 C: common::Connector,
4958{
4959 /// Perform the operation you have build so far.
4960 pub async fn doit(mut self) -> common::Result<(common::Response, AccessProposal)> {
4961 use std::borrow::Cow;
4962 use std::io::{Read, Seek};
4963
4964 use common::{url::Params, ToParts};
4965 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4966
4967 let mut dd = common::DefaultDelegate;
4968 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4969 dlg.begin(common::MethodInfo {
4970 id: "drive.accessproposals.get",
4971 http_method: hyper::Method::GET,
4972 });
4973
4974 for &field in ["alt", "fileId", "proposalId"].iter() {
4975 if self._additional_params.contains_key(field) {
4976 dlg.finished(false);
4977 return Err(common::Error::FieldClash(field));
4978 }
4979 }
4980
4981 let mut params = Params::with_capacity(4 + self._additional_params.len());
4982 params.push("fileId", self._file_id);
4983 params.push("proposalId", self._proposal_id);
4984
4985 params.extend(self._additional_params.iter());
4986
4987 params.push("alt", "json");
4988 let mut url = self.hub._base_url.clone() + "files/{fileId}/accessproposals/{proposalId}";
4989 if self._scopes.is_empty() {
4990 self._scopes
4991 .insert(Scope::MetadataReadonly.as_ref().to_string());
4992 }
4993
4994 #[allow(clippy::single_element_loop)]
4995 for &(find_this, param_name) in
4996 [("{fileId}", "fileId"), ("{proposalId}", "proposalId")].iter()
4997 {
4998 url = params.uri_replacement(url, param_name, find_this, false);
4999 }
5000 {
5001 let to_remove = ["proposalId", "fileId"];
5002 params.remove_params(&to_remove);
5003 }
5004
5005 let url = params.parse_with_url(&url);
5006
5007 loop {
5008 let token = match self
5009 .hub
5010 .auth
5011 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5012 .await
5013 {
5014 Ok(token) => token,
5015 Err(e) => match dlg.token(e) {
5016 Ok(token) => token,
5017 Err(e) => {
5018 dlg.finished(false);
5019 return Err(common::Error::MissingToken(e));
5020 }
5021 },
5022 };
5023 let mut req_result = {
5024 let client = &self.hub.client;
5025 dlg.pre_request();
5026 let mut req_builder = hyper::Request::builder()
5027 .method(hyper::Method::GET)
5028 .uri(url.as_str())
5029 .header(USER_AGENT, self.hub._user_agent.clone());
5030
5031 if let Some(token) = token.as_ref() {
5032 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5033 }
5034
5035 let request = req_builder
5036 .header(CONTENT_LENGTH, 0_u64)
5037 .body(common::to_body::<String>(None));
5038
5039 client.request(request.unwrap()).await
5040 };
5041
5042 match req_result {
5043 Err(err) => {
5044 if let common::Retry::After(d) = dlg.http_error(&err) {
5045 sleep(d).await;
5046 continue;
5047 }
5048 dlg.finished(false);
5049 return Err(common::Error::HttpError(err));
5050 }
5051 Ok(res) => {
5052 let (mut parts, body) = res.into_parts();
5053 let mut body = common::Body::new(body);
5054 if !parts.status.is_success() {
5055 let bytes = common::to_bytes(body).await.unwrap_or_default();
5056 let error = serde_json::from_str(&common::to_string(&bytes));
5057 let response = common::to_response(parts, bytes.into());
5058
5059 if let common::Retry::After(d) =
5060 dlg.http_failure(&response, error.as_ref().ok())
5061 {
5062 sleep(d).await;
5063 continue;
5064 }
5065
5066 dlg.finished(false);
5067
5068 return Err(match error {
5069 Ok(value) => common::Error::BadRequest(value),
5070 _ => common::Error::Failure(response),
5071 });
5072 }
5073 let response = {
5074 let bytes = common::to_bytes(body).await.unwrap_or_default();
5075 let encoded = common::to_string(&bytes);
5076 match serde_json::from_str(&encoded) {
5077 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5078 Err(error) => {
5079 dlg.response_json_decode_error(&encoded, &error);
5080 return Err(common::Error::JsonDecodeError(
5081 encoded.to_string(),
5082 error,
5083 ));
5084 }
5085 }
5086 };
5087
5088 dlg.finished(true);
5089 return Ok(response);
5090 }
5091 }
5092 }
5093 }
5094
5095 /// Required. The ID of the item the request is on.
5096 ///
5097 /// Sets the *file id* path property to the given value.
5098 ///
5099 /// Even though the property as already been set when instantiating this call,
5100 /// we provide this method for API completeness.
5101 pub fn file_id(mut self, new_value: &str) -> AccessproposalGetCall<'a, C> {
5102 self._file_id = new_value.to_string();
5103 self
5104 }
5105 /// Required. The ID of the access proposal to resolve.
5106 ///
5107 /// Sets the *proposal id* path property to the given value.
5108 ///
5109 /// Even though the property as already been set when instantiating this call,
5110 /// we provide this method for API completeness.
5111 pub fn proposal_id(mut self, new_value: &str) -> AccessproposalGetCall<'a, C> {
5112 self._proposal_id = new_value.to_string();
5113 self
5114 }
5115 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5116 /// while executing the actual API request.
5117 ///
5118 /// ````text
5119 /// It should be used to handle progress information, and to implement a certain level of resilience.
5120 /// ````
5121 ///
5122 /// Sets the *delegate* property to the given value.
5123 pub fn delegate(
5124 mut self,
5125 new_value: &'a mut dyn common::Delegate,
5126 ) -> AccessproposalGetCall<'a, C> {
5127 self._delegate = Some(new_value);
5128 self
5129 }
5130
5131 /// Set any additional parameter of the query string used in the request.
5132 /// It should be used to set parameters which are not yet available through their own
5133 /// setters.
5134 ///
5135 /// Please note that this method must not be used to set any of the known parameters
5136 /// which have their own setter method. If done anyway, the request will fail.
5137 ///
5138 /// # Additional Parameters
5139 ///
5140 /// * *$.xgafv* (query-string) - V1 error format.
5141 /// * *access_token* (query-string) - OAuth access token.
5142 /// * *alt* (query-string) - Data format for response.
5143 /// * *callback* (query-string) - JSONP
5144 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5145 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5146 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5147 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5148 /// * *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.
5149 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5150 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5151 pub fn param<T>(mut self, name: T, value: T) -> AccessproposalGetCall<'a, C>
5152 where
5153 T: AsRef<str>,
5154 {
5155 self._additional_params
5156 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5157 self
5158 }
5159
5160 /// Identifies the authorization scope for the method you are building.
5161 ///
5162 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5163 /// [`Scope::MetadataReadonly`].
5164 ///
5165 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5166 /// tokens for more than one scope.
5167 ///
5168 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5169 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5170 /// sufficient, a read-write scope will do as well.
5171 pub fn add_scope<St>(mut self, scope: St) -> AccessproposalGetCall<'a, C>
5172 where
5173 St: AsRef<str>,
5174 {
5175 self._scopes.insert(String::from(scope.as_ref()));
5176 self
5177 }
5178 /// Identifies the authorization scope(s) for the method you are building.
5179 ///
5180 /// See [`Self::add_scope()`] for details.
5181 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessproposalGetCall<'a, C>
5182 where
5183 I: IntoIterator<Item = St>,
5184 St: AsRef<str>,
5185 {
5186 self._scopes
5187 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5188 self
5189 }
5190
5191 /// Removes all scopes, and no default scope will be used either.
5192 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5193 /// for details).
5194 pub fn clear_scopes(mut self) -> AccessproposalGetCall<'a, C> {
5195 self._scopes.clear();
5196 self
5197 }
5198}
5199
5200/// List the access proposals on a file. For more information, see [Manage pending access proposals](https://developers.google.com/workspace/drive/api/guides/pending-access). Note: Only approvers are able to list access proposals on a file. If the user isn't an approver, a 403 error is returned.
5201///
5202/// A builder for the *list* method supported by a *accessproposal* resource.
5203/// It is not used directly, but through a [`AccessproposalMethods`] instance.
5204///
5205/// # Example
5206///
5207/// Instantiate a resource method builder
5208///
5209/// ```test_harness,no_run
5210/// # extern crate hyper;
5211/// # extern crate hyper_rustls;
5212/// # extern crate google_drive3 as drive3;
5213/// # async fn dox() {
5214/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5215///
5216/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5217/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5218/// # .with_native_roots()
5219/// # .unwrap()
5220/// # .https_only()
5221/// # .enable_http2()
5222/// # .build();
5223///
5224/// # let executor = hyper_util::rt::TokioExecutor::new();
5225/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5226/// # secret,
5227/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5228/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5229/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5230/// # ),
5231/// # ).build().await.unwrap();
5232///
5233/// # let client = hyper_util::client::legacy::Client::builder(
5234/// # hyper_util::rt::TokioExecutor::new()
5235/// # )
5236/// # .build(
5237/// # hyper_rustls::HttpsConnectorBuilder::new()
5238/// # .with_native_roots()
5239/// # .unwrap()
5240/// # .https_or_http()
5241/// # .enable_http2()
5242/// # .build()
5243/// # );
5244/// # let mut hub = DriveHub::new(client, auth);
5245/// // You can configure optional parameters by calling the respective setters at will, and
5246/// // execute the final call using `doit()`.
5247/// // Values shown here are possibly random and not representative !
5248/// let result = hub.accessproposals().list("fileId")
5249/// .page_token("amet.")
5250/// .page_size(-96)
5251/// .doit().await;
5252/// # }
5253/// ```
5254pub struct AccessproposalListCall<'a, C>
5255where
5256 C: 'a,
5257{
5258 hub: &'a DriveHub<C>,
5259 _file_id: String,
5260 _page_token: Option<String>,
5261 _page_size: Option<i32>,
5262 _delegate: Option<&'a mut dyn common::Delegate>,
5263 _additional_params: HashMap<String, String>,
5264 _scopes: BTreeSet<String>,
5265}
5266
5267impl<'a, C> common::CallBuilder for AccessproposalListCall<'a, C> {}
5268
5269impl<'a, C> AccessproposalListCall<'a, C>
5270where
5271 C: common::Connector,
5272{
5273 /// Perform the operation you have build so far.
5274 pub async fn doit(mut self) -> common::Result<(common::Response, ListAccessProposalsResponse)> {
5275 use std::borrow::Cow;
5276 use std::io::{Read, Seek};
5277
5278 use common::{url::Params, ToParts};
5279 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5280
5281 let mut dd = common::DefaultDelegate;
5282 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5283 dlg.begin(common::MethodInfo {
5284 id: "drive.accessproposals.list",
5285 http_method: hyper::Method::GET,
5286 });
5287
5288 for &field in ["alt", "fileId", "pageToken", "pageSize"].iter() {
5289 if self._additional_params.contains_key(field) {
5290 dlg.finished(false);
5291 return Err(common::Error::FieldClash(field));
5292 }
5293 }
5294
5295 let mut params = Params::with_capacity(5 + self._additional_params.len());
5296 params.push("fileId", self._file_id);
5297 if let Some(value) = self._page_token.as_ref() {
5298 params.push("pageToken", value);
5299 }
5300 if let Some(value) = self._page_size.as_ref() {
5301 params.push("pageSize", value.to_string());
5302 }
5303
5304 params.extend(self._additional_params.iter());
5305
5306 params.push("alt", "json");
5307 let mut url = self.hub._base_url.clone() + "files/{fileId}/accessproposals";
5308 if self._scopes.is_empty() {
5309 self._scopes
5310 .insert(Scope::MetadataReadonly.as_ref().to_string());
5311 }
5312
5313 #[allow(clippy::single_element_loop)]
5314 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
5315 url = params.uri_replacement(url, param_name, find_this, false);
5316 }
5317 {
5318 let to_remove = ["fileId"];
5319 params.remove_params(&to_remove);
5320 }
5321
5322 let url = params.parse_with_url(&url);
5323
5324 loop {
5325 let token = match self
5326 .hub
5327 .auth
5328 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5329 .await
5330 {
5331 Ok(token) => token,
5332 Err(e) => match dlg.token(e) {
5333 Ok(token) => token,
5334 Err(e) => {
5335 dlg.finished(false);
5336 return Err(common::Error::MissingToken(e));
5337 }
5338 },
5339 };
5340 let mut req_result = {
5341 let client = &self.hub.client;
5342 dlg.pre_request();
5343 let mut req_builder = hyper::Request::builder()
5344 .method(hyper::Method::GET)
5345 .uri(url.as_str())
5346 .header(USER_AGENT, self.hub._user_agent.clone());
5347
5348 if let Some(token) = token.as_ref() {
5349 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5350 }
5351
5352 let request = req_builder
5353 .header(CONTENT_LENGTH, 0_u64)
5354 .body(common::to_body::<String>(None));
5355
5356 client.request(request.unwrap()).await
5357 };
5358
5359 match req_result {
5360 Err(err) => {
5361 if let common::Retry::After(d) = dlg.http_error(&err) {
5362 sleep(d).await;
5363 continue;
5364 }
5365 dlg.finished(false);
5366 return Err(common::Error::HttpError(err));
5367 }
5368 Ok(res) => {
5369 let (mut parts, body) = res.into_parts();
5370 let mut body = common::Body::new(body);
5371 if !parts.status.is_success() {
5372 let bytes = common::to_bytes(body).await.unwrap_or_default();
5373 let error = serde_json::from_str(&common::to_string(&bytes));
5374 let response = common::to_response(parts, bytes.into());
5375
5376 if let common::Retry::After(d) =
5377 dlg.http_failure(&response, error.as_ref().ok())
5378 {
5379 sleep(d).await;
5380 continue;
5381 }
5382
5383 dlg.finished(false);
5384
5385 return Err(match error {
5386 Ok(value) => common::Error::BadRequest(value),
5387 _ => common::Error::Failure(response),
5388 });
5389 }
5390 let response = {
5391 let bytes = common::to_bytes(body).await.unwrap_or_default();
5392 let encoded = common::to_string(&bytes);
5393 match serde_json::from_str(&encoded) {
5394 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5395 Err(error) => {
5396 dlg.response_json_decode_error(&encoded, &error);
5397 return Err(common::Error::JsonDecodeError(
5398 encoded.to_string(),
5399 error,
5400 ));
5401 }
5402 }
5403 };
5404
5405 dlg.finished(true);
5406 return Ok(response);
5407 }
5408 }
5409 }
5410 }
5411
5412 /// Required. The ID of the item the request is on.
5413 ///
5414 /// Sets the *file id* path property to the given value.
5415 ///
5416 /// Even though the property as already been set when instantiating this call,
5417 /// we provide this method for API completeness.
5418 pub fn file_id(mut self, new_value: &str) -> AccessproposalListCall<'a, C> {
5419 self._file_id = new_value.to_string();
5420 self
5421 }
5422 /// Optional. The continuation token on the list of access requests.
5423 ///
5424 /// Sets the *page token* query property to the given value.
5425 pub fn page_token(mut self, new_value: &str) -> AccessproposalListCall<'a, C> {
5426 self._page_token = Some(new_value.to_string());
5427 self
5428 }
5429 /// Optional. The number of results per page.
5430 ///
5431 /// Sets the *page size* query property to the given value.
5432 pub fn page_size(mut self, new_value: i32) -> AccessproposalListCall<'a, C> {
5433 self._page_size = Some(new_value);
5434 self
5435 }
5436 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5437 /// while executing the actual API request.
5438 ///
5439 /// ````text
5440 /// It should be used to handle progress information, and to implement a certain level of resilience.
5441 /// ````
5442 ///
5443 /// Sets the *delegate* property to the given value.
5444 pub fn delegate(
5445 mut self,
5446 new_value: &'a mut dyn common::Delegate,
5447 ) -> AccessproposalListCall<'a, C> {
5448 self._delegate = Some(new_value);
5449 self
5450 }
5451
5452 /// Set any additional parameter of the query string used in the request.
5453 /// It should be used to set parameters which are not yet available through their own
5454 /// setters.
5455 ///
5456 /// Please note that this method must not be used to set any of the known parameters
5457 /// which have their own setter method. If done anyway, the request will fail.
5458 ///
5459 /// # Additional Parameters
5460 ///
5461 /// * *$.xgafv* (query-string) - V1 error format.
5462 /// * *access_token* (query-string) - OAuth access token.
5463 /// * *alt* (query-string) - Data format for response.
5464 /// * *callback* (query-string) - JSONP
5465 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5466 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5467 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5468 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5469 /// * *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.
5470 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5471 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5472 pub fn param<T>(mut self, name: T, value: T) -> AccessproposalListCall<'a, C>
5473 where
5474 T: AsRef<str>,
5475 {
5476 self._additional_params
5477 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5478 self
5479 }
5480
5481 /// Identifies the authorization scope for the method you are building.
5482 ///
5483 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5484 /// [`Scope::MetadataReadonly`].
5485 ///
5486 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5487 /// tokens for more than one scope.
5488 ///
5489 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5490 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5491 /// sufficient, a read-write scope will do as well.
5492 pub fn add_scope<St>(mut self, scope: St) -> AccessproposalListCall<'a, C>
5493 where
5494 St: AsRef<str>,
5495 {
5496 self._scopes.insert(String::from(scope.as_ref()));
5497 self
5498 }
5499 /// Identifies the authorization scope(s) for the method you are building.
5500 ///
5501 /// See [`Self::add_scope()`] for details.
5502 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessproposalListCall<'a, C>
5503 where
5504 I: IntoIterator<Item = St>,
5505 St: AsRef<str>,
5506 {
5507 self._scopes
5508 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5509 self
5510 }
5511
5512 /// Removes all scopes, and no default scope will be used either.
5513 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5514 /// for details).
5515 pub fn clear_scopes(mut self) -> AccessproposalListCall<'a, C> {
5516 self._scopes.clear();
5517 self
5518 }
5519}
5520
5521/// Approves or denies an access proposal. For more information, see [Manage pending access proposals](https://developers.google.com/workspace/drive/api/guides/pending-access).
5522///
5523/// A builder for the *resolve* method supported by a *accessproposal* resource.
5524/// It is not used directly, but through a [`AccessproposalMethods`] instance.
5525///
5526/// # Example
5527///
5528/// Instantiate a resource method builder
5529///
5530/// ```test_harness,no_run
5531/// # extern crate hyper;
5532/// # extern crate hyper_rustls;
5533/// # extern crate google_drive3 as drive3;
5534/// use drive3::api::ResolveAccessProposalRequest;
5535/// # async fn dox() {
5536/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5537///
5538/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5539/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5540/// # .with_native_roots()
5541/// # .unwrap()
5542/// # .https_only()
5543/// # .enable_http2()
5544/// # .build();
5545///
5546/// # let executor = hyper_util::rt::TokioExecutor::new();
5547/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5548/// # secret,
5549/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5550/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5551/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5552/// # ),
5553/// # ).build().await.unwrap();
5554///
5555/// # let client = hyper_util::client::legacy::Client::builder(
5556/// # hyper_util::rt::TokioExecutor::new()
5557/// # )
5558/// # .build(
5559/// # hyper_rustls::HttpsConnectorBuilder::new()
5560/// # .with_native_roots()
5561/// # .unwrap()
5562/// # .https_or_http()
5563/// # .enable_http2()
5564/// # .build()
5565/// # );
5566/// # let mut hub = DriveHub::new(client, auth);
5567/// // As the method needs a request, you would usually fill it with the desired information
5568/// // into the respective structure. Some of the parts shown here might not be applicable !
5569/// // Values shown here are possibly random and not representative !
5570/// let mut req = ResolveAccessProposalRequest::default();
5571///
5572/// // You can configure optional parameters by calling the respective setters at will, and
5573/// // execute the final call using `doit()`.
5574/// // Values shown here are possibly random and not representative !
5575/// let result = hub.accessproposals().resolve(req, "fileId", "proposalId")
5576/// .doit().await;
5577/// # }
5578/// ```
5579pub struct AccessproposalResolveCall<'a, C>
5580where
5581 C: 'a,
5582{
5583 hub: &'a DriveHub<C>,
5584 _request: ResolveAccessProposalRequest,
5585 _file_id: String,
5586 _proposal_id: String,
5587 _delegate: Option<&'a mut dyn common::Delegate>,
5588 _additional_params: HashMap<String, String>,
5589 _scopes: BTreeSet<String>,
5590}
5591
5592impl<'a, C> common::CallBuilder for AccessproposalResolveCall<'a, C> {}
5593
5594impl<'a, C> AccessproposalResolveCall<'a, C>
5595where
5596 C: common::Connector,
5597{
5598 /// Perform the operation you have build so far.
5599 pub async fn doit(mut self) -> common::Result<common::Response> {
5600 use std::borrow::Cow;
5601 use std::io::{Read, Seek};
5602
5603 use common::{url::Params, ToParts};
5604 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5605
5606 let mut dd = common::DefaultDelegate;
5607 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5608 dlg.begin(common::MethodInfo {
5609 id: "drive.accessproposals.resolve",
5610 http_method: hyper::Method::POST,
5611 });
5612
5613 for &field in ["fileId", "proposalId"].iter() {
5614 if self._additional_params.contains_key(field) {
5615 dlg.finished(false);
5616 return Err(common::Error::FieldClash(field));
5617 }
5618 }
5619
5620 let mut params = Params::with_capacity(4 + self._additional_params.len());
5621 params.push("fileId", self._file_id);
5622 params.push("proposalId", self._proposal_id);
5623
5624 params.extend(self._additional_params.iter());
5625
5626 let mut url =
5627 self.hub._base_url.clone() + "files/{fileId}/accessproposals/{proposalId}:resolve";
5628 if self._scopes.is_empty() {
5629 self._scopes.insert(Scope::Full.as_ref().to_string());
5630 }
5631
5632 #[allow(clippy::single_element_loop)]
5633 for &(find_this, param_name) in
5634 [("{fileId}", "fileId"), ("{proposalId}", "proposalId")].iter()
5635 {
5636 url = params.uri_replacement(url, param_name, find_this, false);
5637 }
5638 {
5639 let to_remove = ["proposalId", "fileId"];
5640 params.remove_params(&to_remove);
5641 }
5642
5643 let url = params.parse_with_url(&url);
5644
5645 let mut json_mime_type = mime::APPLICATION_JSON;
5646 let mut request_value_reader = {
5647 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5648 common::remove_json_null_values(&mut value);
5649 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5650 serde_json::to_writer(&mut dst, &value).unwrap();
5651 dst
5652 };
5653 let request_size = request_value_reader
5654 .seek(std::io::SeekFrom::End(0))
5655 .unwrap();
5656 request_value_reader
5657 .seek(std::io::SeekFrom::Start(0))
5658 .unwrap();
5659
5660 loop {
5661 let token = match self
5662 .hub
5663 .auth
5664 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5665 .await
5666 {
5667 Ok(token) => token,
5668 Err(e) => match dlg.token(e) {
5669 Ok(token) => token,
5670 Err(e) => {
5671 dlg.finished(false);
5672 return Err(common::Error::MissingToken(e));
5673 }
5674 },
5675 };
5676 request_value_reader
5677 .seek(std::io::SeekFrom::Start(0))
5678 .unwrap();
5679 let mut req_result = {
5680 let client = &self.hub.client;
5681 dlg.pre_request();
5682 let mut req_builder = hyper::Request::builder()
5683 .method(hyper::Method::POST)
5684 .uri(url.as_str())
5685 .header(USER_AGENT, self.hub._user_agent.clone());
5686
5687 if let Some(token) = token.as_ref() {
5688 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5689 }
5690
5691 let request = req_builder
5692 .header(CONTENT_TYPE, json_mime_type.to_string())
5693 .header(CONTENT_LENGTH, request_size as u64)
5694 .body(common::to_body(
5695 request_value_reader.get_ref().clone().into(),
5696 ));
5697
5698 client.request(request.unwrap()).await
5699 };
5700
5701 match req_result {
5702 Err(err) => {
5703 if let common::Retry::After(d) = dlg.http_error(&err) {
5704 sleep(d).await;
5705 continue;
5706 }
5707 dlg.finished(false);
5708 return Err(common::Error::HttpError(err));
5709 }
5710 Ok(res) => {
5711 let (mut parts, body) = res.into_parts();
5712 let mut body = common::Body::new(body);
5713 if !parts.status.is_success() {
5714 let bytes = common::to_bytes(body).await.unwrap_or_default();
5715 let error = serde_json::from_str(&common::to_string(&bytes));
5716 let response = common::to_response(parts, bytes.into());
5717
5718 if let common::Retry::After(d) =
5719 dlg.http_failure(&response, error.as_ref().ok())
5720 {
5721 sleep(d).await;
5722 continue;
5723 }
5724
5725 dlg.finished(false);
5726
5727 return Err(match error {
5728 Ok(value) => common::Error::BadRequest(value),
5729 _ => common::Error::Failure(response),
5730 });
5731 }
5732 let response = common::Response::from_parts(parts, body);
5733
5734 dlg.finished(true);
5735 return Ok(response);
5736 }
5737 }
5738 }
5739 }
5740
5741 ///
5742 /// Sets the *request* property to the given value.
5743 ///
5744 /// Even though the property as already been set when instantiating this call,
5745 /// we provide this method for API completeness.
5746 pub fn request(
5747 mut self,
5748 new_value: ResolveAccessProposalRequest,
5749 ) -> AccessproposalResolveCall<'a, C> {
5750 self._request = new_value;
5751 self
5752 }
5753 /// Required. The ID of the item the request is on.
5754 ///
5755 /// Sets the *file id* path property to the given value.
5756 ///
5757 /// Even though the property as already been set when instantiating this call,
5758 /// we provide this method for API completeness.
5759 pub fn file_id(mut self, new_value: &str) -> AccessproposalResolveCall<'a, C> {
5760 self._file_id = new_value.to_string();
5761 self
5762 }
5763 /// Required. The ID of the access proposal to resolve.
5764 ///
5765 /// Sets the *proposal id* path property to the given value.
5766 ///
5767 /// Even though the property as already been set when instantiating this call,
5768 /// we provide this method for API completeness.
5769 pub fn proposal_id(mut self, new_value: &str) -> AccessproposalResolveCall<'a, C> {
5770 self._proposal_id = new_value.to_string();
5771 self
5772 }
5773 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5774 /// while executing the actual API request.
5775 ///
5776 /// ````text
5777 /// It should be used to handle progress information, and to implement a certain level of resilience.
5778 /// ````
5779 ///
5780 /// Sets the *delegate* property to the given value.
5781 pub fn delegate(
5782 mut self,
5783 new_value: &'a mut dyn common::Delegate,
5784 ) -> AccessproposalResolveCall<'a, C> {
5785 self._delegate = Some(new_value);
5786 self
5787 }
5788
5789 /// Set any additional parameter of the query string used in the request.
5790 /// It should be used to set parameters which are not yet available through their own
5791 /// setters.
5792 ///
5793 /// Please note that this method must not be used to set any of the known parameters
5794 /// which have their own setter method. If done anyway, the request will fail.
5795 ///
5796 /// # Additional Parameters
5797 ///
5798 /// * *$.xgafv* (query-string) - V1 error format.
5799 /// * *access_token* (query-string) - OAuth access token.
5800 /// * *alt* (query-string) - Data format for response.
5801 /// * *callback* (query-string) - JSONP
5802 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5803 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5804 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5805 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5806 /// * *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.
5807 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5808 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5809 pub fn param<T>(mut self, name: T, value: T) -> AccessproposalResolveCall<'a, C>
5810 where
5811 T: AsRef<str>,
5812 {
5813 self._additional_params
5814 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5815 self
5816 }
5817
5818 /// Identifies the authorization scope for the method you are building.
5819 ///
5820 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5821 /// [`Scope::Full`].
5822 ///
5823 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5824 /// tokens for more than one scope.
5825 ///
5826 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5827 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5828 /// sufficient, a read-write scope will do as well.
5829 pub fn add_scope<St>(mut self, scope: St) -> AccessproposalResolveCall<'a, C>
5830 where
5831 St: AsRef<str>,
5832 {
5833 self._scopes.insert(String::from(scope.as_ref()));
5834 self
5835 }
5836 /// Identifies the authorization scope(s) for the method you are building.
5837 ///
5838 /// See [`Self::add_scope()`] for details.
5839 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessproposalResolveCall<'a, C>
5840 where
5841 I: IntoIterator<Item = St>,
5842 St: AsRef<str>,
5843 {
5844 self._scopes
5845 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5846 self
5847 }
5848
5849 /// Removes all scopes, and no default scope will be used either.
5850 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5851 /// for details).
5852 pub fn clear_scopes(mut self) -> AccessproposalResolveCall<'a, C> {
5853 self._scopes.clear();
5854 self
5855 }
5856}
5857
5858/// Gets an Approval by ID.
5859///
5860/// A builder for the *get* method supported by a *approval* resource.
5861/// It is not used directly, but through a [`ApprovalMethods`] instance.
5862///
5863/// # Example
5864///
5865/// Instantiate a resource method builder
5866///
5867/// ```test_harness,no_run
5868/// # extern crate hyper;
5869/// # extern crate hyper_rustls;
5870/// # extern crate google_drive3 as drive3;
5871/// # async fn dox() {
5872/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5873///
5874/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5875/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5876/// # .with_native_roots()
5877/// # .unwrap()
5878/// # .https_only()
5879/// # .enable_http2()
5880/// # .build();
5881///
5882/// # let executor = hyper_util::rt::TokioExecutor::new();
5883/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5884/// # secret,
5885/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5886/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5887/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5888/// # ),
5889/// # ).build().await.unwrap();
5890///
5891/// # let client = hyper_util::client::legacy::Client::builder(
5892/// # hyper_util::rt::TokioExecutor::new()
5893/// # )
5894/// # .build(
5895/// # hyper_rustls::HttpsConnectorBuilder::new()
5896/// # .with_native_roots()
5897/// # .unwrap()
5898/// # .https_or_http()
5899/// # .enable_http2()
5900/// # .build()
5901/// # );
5902/// # let mut hub = DriveHub::new(client, auth);
5903/// // You can configure optional parameters by calling the respective setters at will, and
5904/// // execute the final call using `doit()`.
5905/// // Values shown here are possibly random and not representative !
5906/// let result = hub.approvals().get("fileId", "approvalId")
5907/// .doit().await;
5908/// # }
5909/// ```
5910pub struct ApprovalGetCall<'a, C>
5911where
5912 C: 'a,
5913{
5914 hub: &'a DriveHub<C>,
5915 _file_id: String,
5916 _approval_id: String,
5917 _delegate: Option<&'a mut dyn common::Delegate>,
5918 _additional_params: HashMap<String, String>,
5919 _scopes: BTreeSet<String>,
5920}
5921
5922impl<'a, C> common::CallBuilder for ApprovalGetCall<'a, C> {}
5923
5924impl<'a, C> ApprovalGetCall<'a, C>
5925where
5926 C: common::Connector,
5927{
5928 /// Perform the operation you have build so far.
5929 pub async fn doit(mut self) -> common::Result<(common::Response, Approval)> {
5930 use std::borrow::Cow;
5931 use std::io::{Read, Seek};
5932
5933 use common::{url::Params, ToParts};
5934 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5935
5936 let mut dd = common::DefaultDelegate;
5937 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5938 dlg.begin(common::MethodInfo {
5939 id: "drive.approvals.get",
5940 http_method: hyper::Method::GET,
5941 });
5942
5943 for &field in ["alt", "fileId", "approvalId"].iter() {
5944 if self._additional_params.contains_key(field) {
5945 dlg.finished(false);
5946 return Err(common::Error::FieldClash(field));
5947 }
5948 }
5949
5950 let mut params = Params::with_capacity(4 + self._additional_params.len());
5951 params.push("fileId", self._file_id);
5952 params.push("approvalId", self._approval_id);
5953
5954 params.extend(self._additional_params.iter());
5955
5956 params.push("alt", "json");
5957 let mut url = self.hub._base_url.clone() + "files/{fileId}/approvals/{approvalId}";
5958 if self._scopes.is_empty() {
5959 self._scopes
5960 .insert(Scope::MetadataReadonly.as_ref().to_string());
5961 }
5962
5963 #[allow(clippy::single_element_loop)]
5964 for &(find_this, param_name) in
5965 [("{fileId}", "fileId"), ("{approvalId}", "approvalId")].iter()
5966 {
5967 url = params.uri_replacement(url, param_name, find_this, false);
5968 }
5969 {
5970 let to_remove = ["approvalId", "fileId"];
5971 params.remove_params(&to_remove);
5972 }
5973
5974 let url = params.parse_with_url(&url);
5975
5976 loop {
5977 let token = match self
5978 .hub
5979 .auth
5980 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5981 .await
5982 {
5983 Ok(token) => token,
5984 Err(e) => match dlg.token(e) {
5985 Ok(token) => token,
5986 Err(e) => {
5987 dlg.finished(false);
5988 return Err(common::Error::MissingToken(e));
5989 }
5990 },
5991 };
5992 let mut req_result = {
5993 let client = &self.hub.client;
5994 dlg.pre_request();
5995 let mut req_builder = hyper::Request::builder()
5996 .method(hyper::Method::GET)
5997 .uri(url.as_str())
5998 .header(USER_AGENT, self.hub._user_agent.clone());
5999
6000 if let Some(token) = token.as_ref() {
6001 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6002 }
6003
6004 let request = req_builder
6005 .header(CONTENT_LENGTH, 0_u64)
6006 .body(common::to_body::<String>(None));
6007
6008 client.request(request.unwrap()).await
6009 };
6010
6011 match req_result {
6012 Err(err) => {
6013 if let common::Retry::After(d) = dlg.http_error(&err) {
6014 sleep(d).await;
6015 continue;
6016 }
6017 dlg.finished(false);
6018 return Err(common::Error::HttpError(err));
6019 }
6020 Ok(res) => {
6021 let (mut parts, body) = res.into_parts();
6022 let mut body = common::Body::new(body);
6023 if !parts.status.is_success() {
6024 let bytes = common::to_bytes(body).await.unwrap_or_default();
6025 let error = serde_json::from_str(&common::to_string(&bytes));
6026 let response = common::to_response(parts, bytes.into());
6027
6028 if let common::Retry::After(d) =
6029 dlg.http_failure(&response, error.as_ref().ok())
6030 {
6031 sleep(d).await;
6032 continue;
6033 }
6034
6035 dlg.finished(false);
6036
6037 return Err(match error {
6038 Ok(value) => common::Error::BadRequest(value),
6039 _ => common::Error::Failure(response),
6040 });
6041 }
6042 let response = {
6043 let bytes = common::to_bytes(body).await.unwrap_or_default();
6044 let encoded = common::to_string(&bytes);
6045 match serde_json::from_str(&encoded) {
6046 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6047 Err(error) => {
6048 dlg.response_json_decode_error(&encoded, &error);
6049 return Err(common::Error::JsonDecodeError(
6050 encoded.to_string(),
6051 error,
6052 ));
6053 }
6054 }
6055 };
6056
6057 dlg.finished(true);
6058 return Ok(response);
6059 }
6060 }
6061 }
6062 }
6063
6064 /// Required. The ID of the file the Approval is on.
6065 ///
6066 /// Sets the *file id* path property to the given value.
6067 ///
6068 /// Even though the property as already been set when instantiating this call,
6069 /// we provide this method for API completeness.
6070 pub fn file_id(mut self, new_value: &str) -> ApprovalGetCall<'a, C> {
6071 self._file_id = new_value.to_string();
6072 self
6073 }
6074 /// Required. The ID of the Approval.
6075 ///
6076 /// Sets the *approval id* path property to the given value.
6077 ///
6078 /// Even though the property as already been set when instantiating this call,
6079 /// we provide this method for API completeness.
6080 pub fn approval_id(mut self, new_value: &str) -> ApprovalGetCall<'a, C> {
6081 self._approval_id = new_value.to_string();
6082 self
6083 }
6084 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6085 /// while executing the actual API request.
6086 ///
6087 /// ````text
6088 /// It should be used to handle progress information, and to implement a certain level of resilience.
6089 /// ````
6090 ///
6091 /// Sets the *delegate* property to the given value.
6092 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ApprovalGetCall<'a, C> {
6093 self._delegate = Some(new_value);
6094 self
6095 }
6096
6097 /// Set any additional parameter of the query string used in the request.
6098 /// It should be used to set parameters which are not yet available through their own
6099 /// setters.
6100 ///
6101 /// Please note that this method must not be used to set any of the known parameters
6102 /// which have their own setter method. If done anyway, the request will fail.
6103 ///
6104 /// # Additional Parameters
6105 ///
6106 /// * *$.xgafv* (query-string) - V1 error format.
6107 /// * *access_token* (query-string) - OAuth access token.
6108 /// * *alt* (query-string) - Data format for response.
6109 /// * *callback* (query-string) - JSONP
6110 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6111 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6112 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6113 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6114 /// * *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.
6115 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6116 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6117 pub fn param<T>(mut self, name: T, value: T) -> ApprovalGetCall<'a, C>
6118 where
6119 T: AsRef<str>,
6120 {
6121 self._additional_params
6122 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6123 self
6124 }
6125
6126 /// Identifies the authorization scope for the method you are building.
6127 ///
6128 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6129 /// [`Scope::MetadataReadonly`].
6130 ///
6131 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6132 /// tokens for more than one scope.
6133 ///
6134 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6135 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6136 /// sufficient, a read-write scope will do as well.
6137 pub fn add_scope<St>(mut self, scope: St) -> ApprovalGetCall<'a, C>
6138 where
6139 St: AsRef<str>,
6140 {
6141 self._scopes.insert(String::from(scope.as_ref()));
6142 self
6143 }
6144 /// Identifies the authorization scope(s) for the method you are building.
6145 ///
6146 /// See [`Self::add_scope()`] for details.
6147 pub fn add_scopes<I, St>(mut self, scopes: I) -> ApprovalGetCall<'a, C>
6148 where
6149 I: IntoIterator<Item = St>,
6150 St: AsRef<str>,
6151 {
6152 self._scopes
6153 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6154 self
6155 }
6156
6157 /// Removes all scopes, and no default scope will be used either.
6158 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6159 /// for details).
6160 pub fn clear_scopes(mut self) -> ApprovalGetCall<'a, C> {
6161 self._scopes.clear();
6162 self
6163 }
6164}
6165
6166/// Lists the Approvals on a file.
6167///
6168/// A builder for the *list* method supported by a *approval* resource.
6169/// It is not used directly, but through a [`ApprovalMethods`] instance.
6170///
6171/// # Example
6172///
6173/// Instantiate a resource method builder
6174///
6175/// ```test_harness,no_run
6176/// # extern crate hyper;
6177/// # extern crate hyper_rustls;
6178/// # extern crate google_drive3 as drive3;
6179/// # async fn dox() {
6180/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6181///
6182/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6183/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6184/// # .with_native_roots()
6185/// # .unwrap()
6186/// # .https_only()
6187/// # .enable_http2()
6188/// # .build();
6189///
6190/// # let executor = hyper_util::rt::TokioExecutor::new();
6191/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6192/// # secret,
6193/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6194/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6195/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6196/// # ),
6197/// # ).build().await.unwrap();
6198///
6199/// # let client = hyper_util::client::legacy::Client::builder(
6200/// # hyper_util::rt::TokioExecutor::new()
6201/// # )
6202/// # .build(
6203/// # hyper_rustls::HttpsConnectorBuilder::new()
6204/// # .with_native_roots()
6205/// # .unwrap()
6206/// # .https_or_http()
6207/// # .enable_http2()
6208/// # .build()
6209/// # );
6210/// # let mut hub = DriveHub::new(client, auth);
6211/// // You can configure optional parameters by calling the respective setters at will, and
6212/// // execute the final call using `doit()`.
6213/// // Values shown here are possibly random and not representative !
6214/// let result = hub.approvals().list("fileId")
6215/// .page_token("Stet")
6216/// .page_size(-99)
6217/// .doit().await;
6218/// # }
6219/// ```
6220pub struct ApprovalListCall<'a, C>
6221where
6222 C: 'a,
6223{
6224 hub: &'a DriveHub<C>,
6225 _file_id: String,
6226 _page_token: Option<String>,
6227 _page_size: Option<i32>,
6228 _delegate: Option<&'a mut dyn common::Delegate>,
6229 _additional_params: HashMap<String, String>,
6230 _scopes: BTreeSet<String>,
6231}
6232
6233impl<'a, C> common::CallBuilder for ApprovalListCall<'a, C> {}
6234
6235impl<'a, C> ApprovalListCall<'a, C>
6236where
6237 C: common::Connector,
6238{
6239 /// Perform the operation you have build so far.
6240 pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalList)> {
6241 use std::borrow::Cow;
6242 use std::io::{Read, Seek};
6243
6244 use common::{url::Params, ToParts};
6245 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6246
6247 let mut dd = common::DefaultDelegate;
6248 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6249 dlg.begin(common::MethodInfo {
6250 id: "drive.approvals.list",
6251 http_method: hyper::Method::GET,
6252 });
6253
6254 for &field in ["alt", "fileId", "pageToken", "pageSize"].iter() {
6255 if self._additional_params.contains_key(field) {
6256 dlg.finished(false);
6257 return Err(common::Error::FieldClash(field));
6258 }
6259 }
6260
6261 let mut params = Params::with_capacity(5 + self._additional_params.len());
6262 params.push("fileId", self._file_id);
6263 if let Some(value) = self._page_token.as_ref() {
6264 params.push("pageToken", value);
6265 }
6266 if let Some(value) = self._page_size.as_ref() {
6267 params.push("pageSize", value.to_string());
6268 }
6269
6270 params.extend(self._additional_params.iter());
6271
6272 params.push("alt", "json");
6273 let mut url = self.hub._base_url.clone() + "files/{fileId}/approvals";
6274 if self._scopes.is_empty() {
6275 self._scopes
6276 .insert(Scope::MetadataReadonly.as_ref().to_string());
6277 }
6278
6279 #[allow(clippy::single_element_loop)]
6280 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
6281 url = params.uri_replacement(url, param_name, find_this, false);
6282 }
6283 {
6284 let to_remove = ["fileId"];
6285 params.remove_params(&to_remove);
6286 }
6287
6288 let url = params.parse_with_url(&url);
6289
6290 loop {
6291 let token = match self
6292 .hub
6293 .auth
6294 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6295 .await
6296 {
6297 Ok(token) => token,
6298 Err(e) => match dlg.token(e) {
6299 Ok(token) => token,
6300 Err(e) => {
6301 dlg.finished(false);
6302 return Err(common::Error::MissingToken(e));
6303 }
6304 },
6305 };
6306 let mut req_result = {
6307 let client = &self.hub.client;
6308 dlg.pre_request();
6309 let mut req_builder = hyper::Request::builder()
6310 .method(hyper::Method::GET)
6311 .uri(url.as_str())
6312 .header(USER_AGENT, self.hub._user_agent.clone());
6313
6314 if let Some(token) = token.as_ref() {
6315 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6316 }
6317
6318 let request = req_builder
6319 .header(CONTENT_LENGTH, 0_u64)
6320 .body(common::to_body::<String>(None));
6321
6322 client.request(request.unwrap()).await
6323 };
6324
6325 match req_result {
6326 Err(err) => {
6327 if let common::Retry::After(d) = dlg.http_error(&err) {
6328 sleep(d).await;
6329 continue;
6330 }
6331 dlg.finished(false);
6332 return Err(common::Error::HttpError(err));
6333 }
6334 Ok(res) => {
6335 let (mut parts, body) = res.into_parts();
6336 let mut body = common::Body::new(body);
6337 if !parts.status.is_success() {
6338 let bytes = common::to_bytes(body).await.unwrap_or_default();
6339 let error = serde_json::from_str(&common::to_string(&bytes));
6340 let response = common::to_response(parts, bytes.into());
6341
6342 if let common::Retry::After(d) =
6343 dlg.http_failure(&response, error.as_ref().ok())
6344 {
6345 sleep(d).await;
6346 continue;
6347 }
6348
6349 dlg.finished(false);
6350
6351 return Err(match error {
6352 Ok(value) => common::Error::BadRequest(value),
6353 _ => common::Error::Failure(response),
6354 });
6355 }
6356 let response = {
6357 let bytes = common::to_bytes(body).await.unwrap_or_default();
6358 let encoded = common::to_string(&bytes);
6359 match serde_json::from_str(&encoded) {
6360 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6361 Err(error) => {
6362 dlg.response_json_decode_error(&encoded, &error);
6363 return Err(common::Error::JsonDecodeError(
6364 encoded.to_string(),
6365 error,
6366 ));
6367 }
6368 }
6369 };
6370
6371 dlg.finished(true);
6372 return Ok(response);
6373 }
6374 }
6375 }
6376 }
6377
6378 /// Required. The ID of the file the Approval is on.
6379 ///
6380 /// Sets the *file id* path property to the given value.
6381 ///
6382 /// Even though the property as already been set when instantiating this call,
6383 /// we provide this method for API completeness.
6384 pub fn file_id(mut self, new_value: &str) -> ApprovalListCall<'a, C> {
6385 self._file_id = new_value.to_string();
6386 self
6387 }
6388 /// The token for continuing a previous list request on the next page. This should be set to the value of nextPageToken from a previous response.
6389 ///
6390 /// Sets the *page token* query property to the given value.
6391 pub fn page_token(mut self, new_value: &str) -> ApprovalListCall<'a, C> {
6392 self._page_token = Some(new_value.to_string());
6393 self
6394 }
6395 /// The maximum number of Approvals to return. When not set, at most 100 Approvals will be returned.
6396 ///
6397 /// Sets the *page size* query property to the given value.
6398 pub fn page_size(mut self, new_value: i32) -> ApprovalListCall<'a, C> {
6399 self._page_size = Some(new_value);
6400 self
6401 }
6402 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6403 /// while executing the actual API request.
6404 ///
6405 /// ````text
6406 /// It should be used to handle progress information, and to implement a certain level of resilience.
6407 /// ````
6408 ///
6409 /// Sets the *delegate* property to the given value.
6410 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ApprovalListCall<'a, C> {
6411 self._delegate = Some(new_value);
6412 self
6413 }
6414
6415 /// Set any additional parameter of the query string used in the request.
6416 /// It should be used to set parameters which are not yet available through their own
6417 /// setters.
6418 ///
6419 /// Please note that this method must not be used to set any of the known parameters
6420 /// which have their own setter method. If done anyway, the request will fail.
6421 ///
6422 /// # Additional Parameters
6423 ///
6424 /// * *$.xgafv* (query-string) - V1 error format.
6425 /// * *access_token* (query-string) - OAuth access token.
6426 /// * *alt* (query-string) - Data format for response.
6427 /// * *callback* (query-string) - JSONP
6428 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6429 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6430 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6431 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6432 /// * *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.
6433 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6434 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6435 pub fn param<T>(mut self, name: T, value: T) -> ApprovalListCall<'a, C>
6436 where
6437 T: AsRef<str>,
6438 {
6439 self._additional_params
6440 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6441 self
6442 }
6443
6444 /// Identifies the authorization scope for the method you are building.
6445 ///
6446 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6447 /// [`Scope::MetadataReadonly`].
6448 ///
6449 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6450 /// tokens for more than one scope.
6451 ///
6452 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6453 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6454 /// sufficient, a read-write scope will do as well.
6455 pub fn add_scope<St>(mut self, scope: St) -> ApprovalListCall<'a, C>
6456 where
6457 St: AsRef<str>,
6458 {
6459 self._scopes.insert(String::from(scope.as_ref()));
6460 self
6461 }
6462 /// Identifies the authorization scope(s) for the method you are building.
6463 ///
6464 /// See [`Self::add_scope()`] for details.
6465 pub fn add_scopes<I, St>(mut self, scopes: I) -> ApprovalListCall<'a, C>
6466 where
6467 I: IntoIterator<Item = St>,
6468 St: AsRef<str>,
6469 {
6470 self._scopes
6471 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6472 self
6473 }
6474
6475 /// Removes all scopes, and no default scope will be used either.
6476 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6477 /// for details).
6478 pub fn clear_scopes(mut self) -> ApprovalListCall<'a, C> {
6479 self._scopes.clear();
6480 self
6481 }
6482}
6483
6484/// Gets a specific app. For more information, see [Return user info](https://developers.google.com/workspace/drive/api/guides/user-info).
6485///
6486/// A builder for the *get* method supported by a *app* resource.
6487/// It is not used directly, but through a [`AppMethods`] instance.
6488///
6489/// # Example
6490///
6491/// Instantiate a resource method builder
6492///
6493/// ```test_harness,no_run
6494/// # extern crate hyper;
6495/// # extern crate hyper_rustls;
6496/// # extern crate google_drive3 as drive3;
6497/// # async fn dox() {
6498/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6499///
6500/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6501/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6502/// # .with_native_roots()
6503/// # .unwrap()
6504/// # .https_only()
6505/// # .enable_http2()
6506/// # .build();
6507///
6508/// # let executor = hyper_util::rt::TokioExecutor::new();
6509/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6510/// # secret,
6511/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6512/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6513/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6514/// # ),
6515/// # ).build().await.unwrap();
6516///
6517/// # let client = hyper_util::client::legacy::Client::builder(
6518/// # hyper_util::rt::TokioExecutor::new()
6519/// # )
6520/// # .build(
6521/// # hyper_rustls::HttpsConnectorBuilder::new()
6522/// # .with_native_roots()
6523/// # .unwrap()
6524/// # .https_or_http()
6525/// # .enable_http2()
6526/// # .build()
6527/// # );
6528/// # let mut hub = DriveHub::new(client, auth);
6529/// // You can configure optional parameters by calling the respective setters at will, and
6530/// // execute the final call using `doit()`.
6531/// // Values shown here are possibly random and not representative !
6532/// let result = hub.apps().get("appId")
6533/// .doit().await;
6534/// # }
6535/// ```
6536pub struct AppGetCall<'a, C>
6537where
6538 C: 'a,
6539{
6540 hub: &'a DriveHub<C>,
6541 _app_id: String,
6542 _delegate: Option<&'a mut dyn common::Delegate>,
6543 _additional_params: HashMap<String, String>,
6544 _scopes: BTreeSet<String>,
6545}
6546
6547impl<'a, C> common::CallBuilder for AppGetCall<'a, C> {}
6548
6549impl<'a, C> AppGetCall<'a, C>
6550where
6551 C: common::Connector,
6552{
6553 /// Perform the operation you have build so far.
6554 pub async fn doit(mut self) -> common::Result<(common::Response, App)> {
6555 use std::borrow::Cow;
6556 use std::io::{Read, Seek};
6557
6558 use common::{url::Params, ToParts};
6559 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6560
6561 let mut dd = common::DefaultDelegate;
6562 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6563 dlg.begin(common::MethodInfo {
6564 id: "drive.apps.get",
6565 http_method: hyper::Method::GET,
6566 });
6567
6568 for &field in ["alt", "appId"].iter() {
6569 if self._additional_params.contains_key(field) {
6570 dlg.finished(false);
6571 return Err(common::Error::FieldClash(field));
6572 }
6573 }
6574
6575 let mut params = Params::with_capacity(3 + self._additional_params.len());
6576 params.push("appId", self._app_id);
6577
6578 params.extend(self._additional_params.iter());
6579
6580 params.push("alt", "json");
6581 let mut url = self.hub._base_url.clone() + "apps/{appId}";
6582 if self._scopes.is_empty() {
6583 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
6584 }
6585
6586 #[allow(clippy::single_element_loop)]
6587 for &(find_this, param_name) in [("{appId}", "appId")].iter() {
6588 url = params.uri_replacement(url, param_name, find_this, false);
6589 }
6590 {
6591 let to_remove = ["appId"];
6592 params.remove_params(&to_remove);
6593 }
6594
6595 let url = params.parse_with_url(&url);
6596
6597 loop {
6598 let token = match self
6599 .hub
6600 .auth
6601 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6602 .await
6603 {
6604 Ok(token) => token,
6605 Err(e) => match dlg.token(e) {
6606 Ok(token) => token,
6607 Err(e) => {
6608 dlg.finished(false);
6609 return Err(common::Error::MissingToken(e));
6610 }
6611 },
6612 };
6613 let mut req_result = {
6614 let client = &self.hub.client;
6615 dlg.pre_request();
6616 let mut req_builder = hyper::Request::builder()
6617 .method(hyper::Method::GET)
6618 .uri(url.as_str())
6619 .header(USER_AGENT, self.hub._user_agent.clone());
6620
6621 if let Some(token) = token.as_ref() {
6622 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6623 }
6624
6625 let request = req_builder
6626 .header(CONTENT_LENGTH, 0_u64)
6627 .body(common::to_body::<String>(None));
6628
6629 client.request(request.unwrap()).await
6630 };
6631
6632 match req_result {
6633 Err(err) => {
6634 if let common::Retry::After(d) = dlg.http_error(&err) {
6635 sleep(d).await;
6636 continue;
6637 }
6638 dlg.finished(false);
6639 return Err(common::Error::HttpError(err));
6640 }
6641 Ok(res) => {
6642 let (mut parts, body) = res.into_parts();
6643 let mut body = common::Body::new(body);
6644 if !parts.status.is_success() {
6645 let bytes = common::to_bytes(body).await.unwrap_or_default();
6646 let error = serde_json::from_str(&common::to_string(&bytes));
6647 let response = common::to_response(parts, bytes.into());
6648
6649 if let common::Retry::After(d) =
6650 dlg.http_failure(&response, error.as_ref().ok())
6651 {
6652 sleep(d).await;
6653 continue;
6654 }
6655
6656 dlg.finished(false);
6657
6658 return Err(match error {
6659 Ok(value) => common::Error::BadRequest(value),
6660 _ => common::Error::Failure(response),
6661 });
6662 }
6663 let response = {
6664 let bytes = common::to_bytes(body).await.unwrap_or_default();
6665 let encoded = common::to_string(&bytes);
6666 match serde_json::from_str(&encoded) {
6667 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6668 Err(error) => {
6669 dlg.response_json_decode_error(&encoded, &error);
6670 return Err(common::Error::JsonDecodeError(
6671 encoded.to_string(),
6672 error,
6673 ));
6674 }
6675 }
6676 };
6677
6678 dlg.finished(true);
6679 return Ok(response);
6680 }
6681 }
6682 }
6683 }
6684
6685 /// The ID of the app.
6686 ///
6687 /// Sets the *app id* path property to the given value.
6688 ///
6689 /// Even though the property as already been set when instantiating this call,
6690 /// we provide this method for API completeness.
6691 pub fn app_id(mut self, new_value: &str) -> AppGetCall<'a, C> {
6692 self._app_id = new_value.to_string();
6693 self
6694 }
6695 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6696 /// while executing the actual API request.
6697 ///
6698 /// ````text
6699 /// It should be used to handle progress information, and to implement a certain level of resilience.
6700 /// ````
6701 ///
6702 /// Sets the *delegate* property to the given value.
6703 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AppGetCall<'a, C> {
6704 self._delegate = Some(new_value);
6705 self
6706 }
6707
6708 /// Set any additional parameter of the query string used in the request.
6709 /// It should be used to set parameters which are not yet available through their own
6710 /// setters.
6711 ///
6712 /// Please note that this method must not be used to set any of the known parameters
6713 /// which have their own setter method. If done anyway, the request will fail.
6714 ///
6715 /// # Additional Parameters
6716 ///
6717 /// * *$.xgafv* (query-string) - V1 error format.
6718 /// * *access_token* (query-string) - OAuth access token.
6719 /// * *alt* (query-string) - Data format for response.
6720 /// * *callback* (query-string) - JSONP
6721 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6722 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6723 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6724 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6725 /// * *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.
6726 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6727 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6728 pub fn param<T>(mut self, name: T, value: T) -> AppGetCall<'a, C>
6729 where
6730 T: AsRef<str>,
6731 {
6732 self._additional_params
6733 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6734 self
6735 }
6736
6737 /// Identifies the authorization scope for the method you are building.
6738 ///
6739 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6740 /// [`Scope::AppReadonly`].
6741 ///
6742 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6743 /// tokens for more than one scope.
6744 ///
6745 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6746 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6747 /// sufficient, a read-write scope will do as well.
6748 pub fn add_scope<St>(mut self, scope: St) -> AppGetCall<'a, C>
6749 where
6750 St: AsRef<str>,
6751 {
6752 self._scopes.insert(String::from(scope.as_ref()));
6753 self
6754 }
6755 /// Identifies the authorization scope(s) for the method you are building.
6756 ///
6757 /// See [`Self::add_scope()`] for details.
6758 pub fn add_scopes<I, St>(mut self, scopes: I) -> AppGetCall<'a, C>
6759 where
6760 I: IntoIterator<Item = St>,
6761 St: AsRef<str>,
6762 {
6763 self._scopes
6764 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6765 self
6766 }
6767
6768 /// Removes all scopes, and no default scope will be used either.
6769 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6770 /// for details).
6771 pub fn clear_scopes(mut self) -> AppGetCall<'a, C> {
6772 self._scopes.clear();
6773 self
6774 }
6775}
6776
6777/// Lists a user's installed apps. For more information, see [Return user info](https://developers.google.com/workspace/drive/api/guides/user-info).
6778///
6779/// A builder for the *list* method supported by a *app* resource.
6780/// It is not used directly, but through a [`AppMethods`] instance.
6781///
6782/// # Example
6783///
6784/// Instantiate a resource method builder
6785///
6786/// ```test_harness,no_run
6787/// # extern crate hyper;
6788/// # extern crate hyper_rustls;
6789/// # extern crate google_drive3 as drive3;
6790/// # async fn dox() {
6791/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6792///
6793/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6794/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6795/// # .with_native_roots()
6796/// # .unwrap()
6797/// # .https_only()
6798/// # .enable_http2()
6799/// # .build();
6800///
6801/// # let executor = hyper_util::rt::TokioExecutor::new();
6802/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6803/// # secret,
6804/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6805/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6806/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6807/// # ),
6808/// # ).build().await.unwrap();
6809///
6810/// # let client = hyper_util::client::legacy::Client::builder(
6811/// # hyper_util::rt::TokioExecutor::new()
6812/// # )
6813/// # .build(
6814/// # hyper_rustls::HttpsConnectorBuilder::new()
6815/// # .with_native_roots()
6816/// # .unwrap()
6817/// # .https_or_http()
6818/// # .enable_http2()
6819/// # .build()
6820/// # );
6821/// # let mut hub = DriveHub::new(client, auth);
6822/// // You can configure optional parameters by calling the respective setters at will, and
6823/// // execute the final call using `doit()`.
6824/// // Values shown here are possibly random and not representative !
6825/// let result = hub.apps().list()
6826/// .language_code("vero")
6827/// .app_filter_mime_types("vero")
6828/// .app_filter_extensions("invidunt")
6829/// .doit().await;
6830/// # }
6831/// ```
6832pub struct AppListCall<'a, C>
6833where
6834 C: 'a,
6835{
6836 hub: &'a DriveHub<C>,
6837 _language_code: Option<String>,
6838 _app_filter_mime_types: Option<String>,
6839 _app_filter_extensions: Option<String>,
6840 _delegate: Option<&'a mut dyn common::Delegate>,
6841 _additional_params: HashMap<String, String>,
6842 _scopes: BTreeSet<String>,
6843}
6844
6845impl<'a, C> common::CallBuilder for AppListCall<'a, C> {}
6846
6847impl<'a, C> AppListCall<'a, C>
6848where
6849 C: common::Connector,
6850{
6851 /// Perform the operation you have build so far.
6852 pub async fn doit(mut self) -> common::Result<(common::Response, AppList)> {
6853 use std::borrow::Cow;
6854 use std::io::{Read, Seek};
6855
6856 use common::{url::Params, ToParts};
6857 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6858
6859 let mut dd = common::DefaultDelegate;
6860 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6861 dlg.begin(common::MethodInfo {
6862 id: "drive.apps.list",
6863 http_method: hyper::Method::GET,
6864 });
6865
6866 for &field in [
6867 "alt",
6868 "languageCode",
6869 "appFilterMimeTypes",
6870 "appFilterExtensions",
6871 ]
6872 .iter()
6873 {
6874 if self._additional_params.contains_key(field) {
6875 dlg.finished(false);
6876 return Err(common::Error::FieldClash(field));
6877 }
6878 }
6879
6880 let mut params = Params::with_capacity(5 + self._additional_params.len());
6881 if let Some(value) = self._language_code.as_ref() {
6882 params.push("languageCode", value);
6883 }
6884 if let Some(value) = self._app_filter_mime_types.as_ref() {
6885 params.push("appFilterMimeTypes", value);
6886 }
6887 if let Some(value) = self._app_filter_extensions.as_ref() {
6888 params.push("appFilterExtensions", value);
6889 }
6890
6891 params.extend(self._additional_params.iter());
6892
6893 params.push("alt", "json");
6894 let mut url = self.hub._base_url.clone() + "apps";
6895 if self._scopes.is_empty() {
6896 self._scopes.insert(Scope::AppReadonly.as_ref().to_string());
6897 }
6898
6899 let url = params.parse_with_url(&url);
6900
6901 loop {
6902 let token = match self
6903 .hub
6904 .auth
6905 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6906 .await
6907 {
6908 Ok(token) => token,
6909 Err(e) => match dlg.token(e) {
6910 Ok(token) => token,
6911 Err(e) => {
6912 dlg.finished(false);
6913 return Err(common::Error::MissingToken(e));
6914 }
6915 },
6916 };
6917 let mut req_result = {
6918 let client = &self.hub.client;
6919 dlg.pre_request();
6920 let mut req_builder = hyper::Request::builder()
6921 .method(hyper::Method::GET)
6922 .uri(url.as_str())
6923 .header(USER_AGENT, self.hub._user_agent.clone());
6924
6925 if let Some(token) = token.as_ref() {
6926 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6927 }
6928
6929 let request = req_builder
6930 .header(CONTENT_LENGTH, 0_u64)
6931 .body(common::to_body::<String>(None));
6932
6933 client.request(request.unwrap()).await
6934 };
6935
6936 match req_result {
6937 Err(err) => {
6938 if let common::Retry::After(d) = dlg.http_error(&err) {
6939 sleep(d).await;
6940 continue;
6941 }
6942 dlg.finished(false);
6943 return Err(common::Error::HttpError(err));
6944 }
6945 Ok(res) => {
6946 let (mut parts, body) = res.into_parts();
6947 let mut body = common::Body::new(body);
6948 if !parts.status.is_success() {
6949 let bytes = common::to_bytes(body).await.unwrap_or_default();
6950 let error = serde_json::from_str(&common::to_string(&bytes));
6951 let response = common::to_response(parts, bytes.into());
6952
6953 if let common::Retry::After(d) =
6954 dlg.http_failure(&response, error.as_ref().ok())
6955 {
6956 sleep(d).await;
6957 continue;
6958 }
6959
6960 dlg.finished(false);
6961
6962 return Err(match error {
6963 Ok(value) => common::Error::BadRequest(value),
6964 _ => common::Error::Failure(response),
6965 });
6966 }
6967 let response = {
6968 let bytes = common::to_bytes(body).await.unwrap_or_default();
6969 let encoded = common::to_string(&bytes);
6970 match serde_json::from_str(&encoded) {
6971 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6972 Err(error) => {
6973 dlg.response_json_decode_error(&encoded, &error);
6974 return Err(common::Error::JsonDecodeError(
6975 encoded.to_string(),
6976 error,
6977 ));
6978 }
6979 }
6980 };
6981
6982 dlg.finished(true);
6983 return Ok(response);
6984 }
6985 }
6986 }
6987 }
6988
6989 /// A language or locale code, as defined by BCP 47, with some extensions from Unicode's LDML format (http://www.unicode.org/reports/tr35/).
6990 ///
6991 /// Sets the *language code* query property to the given value.
6992 pub fn language_code(mut self, new_value: &str) -> AppListCall<'a, C> {
6993 self._language_code = Some(new_value.to_string());
6994 self
6995 }
6996 /// A comma-separated list of file extensions to limit returned results. All results 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.
6997 ///
6998 /// Sets the *app filter mime types* query property to the given value.
6999 pub fn app_filter_mime_types(mut self, new_value: &str) -> AppListCall<'a, C> {
7000 self._app_filter_mime_types = Some(new_value.to_string());
7001 self
7002 }
7003 /// A comma-separated list of file extensions to limit returned results. All results within the given app query scope which can open any of the given file extensions are included in the response. If `appFilterMimeTypes` are provided as well, the result is a union of the two resulting app lists.
7004 ///
7005 /// Sets the *app filter extensions* query property to the given value.
7006 pub fn app_filter_extensions(mut self, new_value: &str) -> AppListCall<'a, C> {
7007 self._app_filter_extensions = Some(new_value.to_string());
7008 self
7009 }
7010 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7011 /// while executing the actual API request.
7012 ///
7013 /// ````text
7014 /// It should be used to handle progress information, and to implement a certain level of resilience.
7015 /// ````
7016 ///
7017 /// Sets the *delegate* property to the given value.
7018 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AppListCall<'a, C> {
7019 self._delegate = Some(new_value);
7020 self
7021 }
7022
7023 /// Set any additional parameter of the query string used in the request.
7024 /// It should be used to set parameters which are not yet available through their own
7025 /// setters.
7026 ///
7027 /// Please note that this method must not be used to set any of the known parameters
7028 /// which have their own setter method. If done anyway, the request will fail.
7029 ///
7030 /// # Additional Parameters
7031 ///
7032 /// * *$.xgafv* (query-string) - V1 error format.
7033 /// * *access_token* (query-string) - OAuth access token.
7034 /// * *alt* (query-string) - Data format for response.
7035 /// * *callback* (query-string) - JSONP
7036 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7037 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7038 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7039 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7040 /// * *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.
7041 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7042 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7043 pub fn param<T>(mut self, name: T, value: T) -> AppListCall<'a, C>
7044 where
7045 T: AsRef<str>,
7046 {
7047 self._additional_params
7048 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7049 self
7050 }
7051
7052 /// Identifies the authorization scope for the method you are building.
7053 ///
7054 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7055 /// [`Scope::AppReadonly`].
7056 ///
7057 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7058 /// tokens for more than one scope.
7059 ///
7060 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7061 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7062 /// sufficient, a read-write scope will do as well.
7063 pub fn add_scope<St>(mut self, scope: St) -> AppListCall<'a, C>
7064 where
7065 St: AsRef<str>,
7066 {
7067 self._scopes.insert(String::from(scope.as_ref()));
7068 self
7069 }
7070 /// Identifies the authorization scope(s) for the method you are building.
7071 ///
7072 /// See [`Self::add_scope()`] for details.
7073 pub fn add_scopes<I, St>(mut self, scopes: I) -> AppListCall<'a, C>
7074 where
7075 I: IntoIterator<Item = St>,
7076 St: AsRef<str>,
7077 {
7078 self._scopes
7079 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7080 self
7081 }
7082
7083 /// Removes all scopes, and no default scope will be used either.
7084 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7085 /// for details).
7086 pub fn clear_scopes(mut self) -> AppListCall<'a, C> {
7087 self._scopes.clear();
7088 self
7089 }
7090}
7091
7092/// Gets the starting pageToken for listing future changes. For more information, see [Retrieve changes](https://developers.google.com/workspace/drive/api/guides/manage-changes).
7093///
7094/// A builder for the *getStartPageToken* method supported by a *change* resource.
7095/// It is not used directly, but through a [`ChangeMethods`] instance.
7096///
7097/// # Example
7098///
7099/// Instantiate a resource method builder
7100///
7101/// ```test_harness,no_run
7102/// # extern crate hyper;
7103/// # extern crate hyper_rustls;
7104/// # extern crate google_drive3 as drive3;
7105/// # async fn dox() {
7106/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7107///
7108/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7109/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7110/// # .with_native_roots()
7111/// # .unwrap()
7112/// # .https_only()
7113/// # .enable_http2()
7114/// # .build();
7115///
7116/// # let executor = hyper_util::rt::TokioExecutor::new();
7117/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7118/// # secret,
7119/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7120/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7121/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7122/// # ),
7123/// # ).build().await.unwrap();
7124///
7125/// # let client = hyper_util::client::legacy::Client::builder(
7126/// # hyper_util::rt::TokioExecutor::new()
7127/// # )
7128/// # .build(
7129/// # hyper_rustls::HttpsConnectorBuilder::new()
7130/// # .with_native_roots()
7131/// # .unwrap()
7132/// # .https_or_http()
7133/// # .enable_http2()
7134/// # .build()
7135/// # );
7136/// # let mut hub = DriveHub::new(client, auth);
7137/// // You can configure optional parameters by calling the respective setters at will, and
7138/// // execute the final call using `doit()`.
7139/// // Values shown here are possibly random and not representative !
7140/// let result = hub.changes().get_start_page_token()
7141/// .team_drive_id("Stet")
7142/// .supports_team_drives(false)
7143/// .supports_all_drives(true)
7144/// .drive_id("Lorem")
7145/// .doit().await;
7146/// # }
7147/// ```
7148pub struct ChangeGetStartPageTokenCall<'a, C>
7149where
7150 C: 'a,
7151{
7152 hub: &'a DriveHub<C>,
7153 _team_drive_id: Option<String>,
7154 _supports_team_drives: Option<bool>,
7155 _supports_all_drives: Option<bool>,
7156 _drive_id: Option<String>,
7157 _delegate: Option<&'a mut dyn common::Delegate>,
7158 _additional_params: HashMap<String, String>,
7159 _scopes: BTreeSet<String>,
7160}
7161
7162impl<'a, C> common::CallBuilder for ChangeGetStartPageTokenCall<'a, C> {}
7163
7164impl<'a, C> ChangeGetStartPageTokenCall<'a, C>
7165where
7166 C: common::Connector,
7167{
7168 /// Perform the operation you have build so far.
7169 pub async fn doit(mut self) -> common::Result<(common::Response, StartPageToken)> {
7170 use std::borrow::Cow;
7171 use std::io::{Read, Seek};
7172
7173 use common::{url::Params, ToParts};
7174 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7175
7176 let mut dd = common::DefaultDelegate;
7177 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7178 dlg.begin(common::MethodInfo {
7179 id: "drive.changes.getStartPageToken",
7180 http_method: hyper::Method::GET,
7181 });
7182
7183 for &field in [
7184 "alt",
7185 "teamDriveId",
7186 "supportsTeamDrives",
7187 "supportsAllDrives",
7188 "driveId",
7189 ]
7190 .iter()
7191 {
7192 if self._additional_params.contains_key(field) {
7193 dlg.finished(false);
7194 return Err(common::Error::FieldClash(field));
7195 }
7196 }
7197
7198 let mut params = Params::with_capacity(6 + self._additional_params.len());
7199 if let Some(value) = self._team_drive_id.as_ref() {
7200 params.push("teamDriveId", value);
7201 }
7202 if let Some(value) = self._supports_team_drives.as_ref() {
7203 params.push("supportsTeamDrives", value.to_string());
7204 }
7205 if let Some(value) = self._supports_all_drives.as_ref() {
7206 params.push("supportsAllDrives", value.to_string());
7207 }
7208 if let Some(value) = self._drive_id.as_ref() {
7209 params.push("driveId", value);
7210 }
7211
7212 params.extend(self._additional_params.iter());
7213
7214 params.push("alt", "json");
7215 let mut url = self.hub._base_url.clone() + "changes/startPageToken";
7216 if self._scopes.is_empty() {
7217 self._scopes
7218 .insert(Scope::MeetReadonly.as_ref().to_string());
7219 }
7220
7221 let url = params.parse_with_url(&url);
7222
7223 loop {
7224 let token = match self
7225 .hub
7226 .auth
7227 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7228 .await
7229 {
7230 Ok(token) => token,
7231 Err(e) => match dlg.token(e) {
7232 Ok(token) => token,
7233 Err(e) => {
7234 dlg.finished(false);
7235 return Err(common::Error::MissingToken(e));
7236 }
7237 },
7238 };
7239 let mut req_result = {
7240 let client = &self.hub.client;
7241 dlg.pre_request();
7242 let mut req_builder = hyper::Request::builder()
7243 .method(hyper::Method::GET)
7244 .uri(url.as_str())
7245 .header(USER_AGENT, self.hub._user_agent.clone());
7246
7247 if let Some(token) = token.as_ref() {
7248 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7249 }
7250
7251 let request = req_builder
7252 .header(CONTENT_LENGTH, 0_u64)
7253 .body(common::to_body::<String>(None));
7254
7255 client.request(request.unwrap()).await
7256 };
7257
7258 match req_result {
7259 Err(err) => {
7260 if let common::Retry::After(d) = dlg.http_error(&err) {
7261 sleep(d).await;
7262 continue;
7263 }
7264 dlg.finished(false);
7265 return Err(common::Error::HttpError(err));
7266 }
7267 Ok(res) => {
7268 let (mut parts, body) = res.into_parts();
7269 let mut body = common::Body::new(body);
7270 if !parts.status.is_success() {
7271 let bytes = common::to_bytes(body).await.unwrap_or_default();
7272 let error = serde_json::from_str(&common::to_string(&bytes));
7273 let response = common::to_response(parts, bytes.into());
7274
7275 if let common::Retry::After(d) =
7276 dlg.http_failure(&response, error.as_ref().ok())
7277 {
7278 sleep(d).await;
7279 continue;
7280 }
7281
7282 dlg.finished(false);
7283
7284 return Err(match error {
7285 Ok(value) => common::Error::BadRequest(value),
7286 _ => common::Error::Failure(response),
7287 });
7288 }
7289 let response = {
7290 let bytes = common::to_bytes(body).await.unwrap_or_default();
7291 let encoded = common::to_string(&bytes);
7292 match serde_json::from_str(&encoded) {
7293 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7294 Err(error) => {
7295 dlg.response_json_decode_error(&encoded, &error);
7296 return Err(common::Error::JsonDecodeError(
7297 encoded.to_string(),
7298 error,
7299 ));
7300 }
7301 }
7302 };
7303
7304 dlg.finished(true);
7305 return Ok(response);
7306 }
7307 }
7308 }
7309 }
7310
7311 /// Deprecated: Use `driveId` instead.
7312 ///
7313 /// Sets the *team drive id* query property to the given value.
7314 pub fn team_drive_id(mut self, new_value: &str) -> ChangeGetStartPageTokenCall<'a, C> {
7315 self._team_drive_id = Some(new_value.to_string());
7316 self
7317 }
7318 /// Deprecated: Use `supportsAllDrives` instead.
7319 ///
7320 /// Sets the *supports team drives* query property to the given value.
7321 pub fn supports_team_drives(mut self, new_value: bool) -> ChangeGetStartPageTokenCall<'a, C> {
7322 self._supports_team_drives = Some(new_value);
7323 self
7324 }
7325 /// Whether the requesting application supports both My Drives and shared drives.
7326 ///
7327 /// Sets the *supports all drives* query property to the given value.
7328 pub fn supports_all_drives(mut self, new_value: bool) -> ChangeGetStartPageTokenCall<'a, C> {
7329 self._supports_all_drives = Some(new_value);
7330 self
7331 }
7332 /// The ID of the shared drive for which the starting pageToken for listing future changes from that shared drive will be returned.
7333 ///
7334 /// Sets the *drive id* query property to the given value.
7335 pub fn drive_id(mut self, new_value: &str) -> ChangeGetStartPageTokenCall<'a, C> {
7336 self._drive_id = Some(new_value.to_string());
7337 self
7338 }
7339 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7340 /// while executing the actual API request.
7341 ///
7342 /// ````text
7343 /// It should be used to handle progress information, and to implement a certain level of resilience.
7344 /// ````
7345 ///
7346 /// Sets the *delegate* property to the given value.
7347 pub fn delegate(
7348 mut self,
7349 new_value: &'a mut dyn common::Delegate,
7350 ) -> ChangeGetStartPageTokenCall<'a, C> {
7351 self._delegate = Some(new_value);
7352 self
7353 }
7354
7355 /// Set any additional parameter of the query string used in the request.
7356 /// It should be used to set parameters which are not yet available through their own
7357 /// setters.
7358 ///
7359 /// Please note that this method must not be used to set any of the known parameters
7360 /// which have their own setter method. If done anyway, the request will fail.
7361 ///
7362 /// # Additional Parameters
7363 ///
7364 /// * *$.xgafv* (query-string) - V1 error format.
7365 /// * *access_token* (query-string) - OAuth access token.
7366 /// * *alt* (query-string) - Data format for response.
7367 /// * *callback* (query-string) - JSONP
7368 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7369 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7370 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7371 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7372 /// * *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.
7373 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7374 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7375 pub fn param<T>(mut self, name: T, value: T) -> ChangeGetStartPageTokenCall<'a, C>
7376 where
7377 T: AsRef<str>,
7378 {
7379 self._additional_params
7380 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7381 self
7382 }
7383
7384 /// Identifies the authorization scope for the method you are building.
7385 ///
7386 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7387 /// [`Scope::MeetReadonly`].
7388 ///
7389 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7390 /// tokens for more than one scope.
7391 ///
7392 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7393 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7394 /// sufficient, a read-write scope will do as well.
7395 pub fn add_scope<St>(mut self, scope: St) -> ChangeGetStartPageTokenCall<'a, C>
7396 where
7397 St: AsRef<str>,
7398 {
7399 self._scopes.insert(String::from(scope.as_ref()));
7400 self
7401 }
7402 /// Identifies the authorization scope(s) for the method you are building.
7403 ///
7404 /// See [`Self::add_scope()`] for details.
7405 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeGetStartPageTokenCall<'a, C>
7406 where
7407 I: IntoIterator<Item = St>,
7408 St: AsRef<str>,
7409 {
7410 self._scopes
7411 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7412 self
7413 }
7414
7415 /// Removes all scopes, and no default scope will be used either.
7416 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7417 /// for details).
7418 pub fn clear_scopes(mut self) -> ChangeGetStartPageTokenCall<'a, C> {
7419 self._scopes.clear();
7420 self
7421 }
7422}
7423
7424/// Lists the changes for a user or shared drive. For more information, see [Retrieve changes](https://developers.google.com/workspace/drive/api/guides/manage-changes).
7425///
7426/// A builder for the *list* method supported by a *change* resource.
7427/// It is not used directly, but through a [`ChangeMethods`] instance.
7428///
7429/// # Example
7430///
7431/// Instantiate a resource method builder
7432///
7433/// ```test_harness,no_run
7434/// # extern crate hyper;
7435/// # extern crate hyper_rustls;
7436/// # extern crate google_drive3 as drive3;
7437/// # async fn dox() {
7438/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7439///
7440/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7441/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7442/// # .with_native_roots()
7443/// # .unwrap()
7444/// # .https_only()
7445/// # .enable_http2()
7446/// # .build();
7447///
7448/// # let executor = hyper_util::rt::TokioExecutor::new();
7449/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7450/// # secret,
7451/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7452/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7453/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7454/// # ),
7455/// # ).build().await.unwrap();
7456///
7457/// # let client = hyper_util::client::legacy::Client::builder(
7458/// # hyper_util::rt::TokioExecutor::new()
7459/// # )
7460/// # .build(
7461/// # hyper_rustls::HttpsConnectorBuilder::new()
7462/// # .with_native_roots()
7463/// # .unwrap()
7464/// # .https_or_http()
7465/// # .enable_http2()
7466/// # .build()
7467/// # );
7468/// # let mut hub = DriveHub::new(client, auth);
7469/// // You can configure optional parameters by calling the respective setters at will, and
7470/// // execute the final call using `doit()`.
7471/// // Values shown here are possibly random and not representative !
7472/// let result = hub.changes().list("pageToken")
7473/// .team_drive_id("no")
7474/// .supports_team_drives(false)
7475/// .supports_all_drives(true)
7476/// .spaces("consetetur")
7477/// .restrict_to_my_drive(false)
7478/// .page_size(-31)
7479/// .include_team_drive_items(false)
7480/// .include_removed(true)
7481/// .include_permissions_for_view("et")
7482/// .include_labels("accusam")
7483/// .include_items_from_all_drives(false)
7484/// .include_corpus_removals(false)
7485/// .drive_id("amet.")
7486/// .doit().await;
7487/// # }
7488/// ```
7489pub struct ChangeListCall<'a, C>
7490where
7491 C: 'a,
7492{
7493 hub: &'a DriveHub<C>,
7494 _page_token: String,
7495 _team_drive_id: Option<String>,
7496 _supports_team_drives: Option<bool>,
7497 _supports_all_drives: Option<bool>,
7498 _spaces: Option<String>,
7499 _restrict_to_my_drive: Option<bool>,
7500 _page_size: Option<i32>,
7501 _include_team_drive_items: Option<bool>,
7502 _include_removed: Option<bool>,
7503 _include_permissions_for_view: Option<String>,
7504 _include_labels: Option<String>,
7505 _include_items_from_all_drives: Option<bool>,
7506 _include_corpus_removals: Option<bool>,
7507 _drive_id: Option<String>,
7508 _delegate: Option<&'a mut dyn common::Delegate>,
7509 _additional_params: HashMap<String, String>,
7510 _scopes: BTreeSet<String>,
7511}
7512
7513impl<'a, C> common::CallBuilder for ChangeListCall<'a, C> {}
7514
7515impl<'a, C> ChangeListCall<'a, C>
7516where
7517 C: common::Connector,
7518{
7519 /// Perform the operation you have build so far.
7520 pub async fn doit(mut self) -> common::Result<(common::Response, ChangeList)> {
7521 use std::borrow::Cow;
7522 use std::io::{Read, Seek};
7523
7524 use common::{url::Params, ToParts};
7525 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7526
7527 let mut dd = common::DefaultDelegate;
7528 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7529 dlg.begin(common::MethodInfo {
7530 id: "drive.changes.list",
7531 http_method: hyper::Method::GET,
7532 });
7533
7534 for &field in [
7535 "alt",
7536 "pageToken",
7537 "teamDriveId",
7538 "supportsTeamDrives",
7539 "supportsAllDrives",
7540 "spaces",
7541 "restrictToMyDrive",
7542 "pageSize",
7543 "includeTeamDriveItems",
7544 "includeRemoved",
7545 "includePermissionsForView",
7546 "includeLabels",
7547 "includeItemsFromAllDrives",
7548 "includeCorpusRemovals",
7549 "driveId",
7550 ]
7551 .iter()
7552 {
7553 if self._additional_params.contains_key(field) {
7554 dlg.finished(false);
7555 return Err(common::Error::FieldClash(field));
7556 }
7557 }
7558
7559 let mut params = Params::with_capacity(16 + self._additional_params.len());
7560 params.push("pageToken", self._page_token);
7561 if let Some(value) = self._team_drive_id.as_ref() {
7562 params.push("teamDriveId", value);
7563 }
7564 if let Some(value) = self._supports_team_drives.as_ref() {
7565 params.push("supportsTeamDrives", value.to_string());
7566 }
7567 if let Some(value) = self._supports_all_drives.as_ref() {
7568 params.push("supportsAllDrives", value.to_string());
7569 }
7570 if let Some(value) = self._spaces.as_ref() {
7571 params.push("spaces", value);
7572 }
7573 if let Some(value) = self._restrict_to_my_drive.as_ref() {
7574 params.push("restrictToMyDrive", value.to_string());
7575 }
7576 if let Some(value) = self._page_size.as_ref() {
7577 params.push("pageSize", value.to_string());
7578 }
7579 if let Some(value) = self._include_team_drive_items.as_ref() {
7580 params.push("includeTeamDriveItems", value.to_string());
7581 }
7582 if let Some(value) = self._include_removed.as_ref() {
7583 params.push("includeRemoved", value.to_string());
7584 }
7585 if let Some(value) = self._include_permissions_for_view.as_ref() {
7586 params.push("includePermissionsForView", value);
7587 }
7588 if let Some(value) = self._include_labels.as_ref() {
7589 params.push("includeLabels", value);
7590 }
7591 if let Some(value) = self._include_items_from_all_drives.as_ref() {
7592 params.push("includeItemsFromAllDrives", value.to_string());
7593 }
7594 if let Some(value) = self._include_corpus_removals.as_ref() {
7595 params.push("includeCorpusRemovals", value.to_string());
7596 }
7597 if let Some(value) = self._drive_id.as_ref() {
7598 params.push("driveId", value);
7599 }
7600
7601 params.extend(self._additional_params.iter());
7602
7603 params.push("alt", "json");
7604 let mut url = self.hub._base_url.clone() + "changes";
7605 if self._scopes.is_empty() {
7606 self._scopes
7607 .insert(Scope::MeetReadonly.as_ref().to_string());
7608 }
7609
7610 let url = params.parse_with_url(&url);
7611
7612 loop {
7613 let token = match self
7614 .hub
7615 .auth
7616 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7617 .await
7618 {
7619 Ok(token) => token,
7620 Err(e) => match dlg.token(e) {
7621 Ok(token) => token,
7622 Err(e) => {
7623 dlg.finished(false);
7624 return Err(common::Error::MissingToken(e));
7625 }
7626 },
7627 };
7628 let mut req_result = {
7629 let client = &self.hub.client;
7630 dlg.pre_request();
7631 let mut req_builder = hyper::Request::builder()
7632 .method(hyper::Method::GET)
7633 .uri(url.as_str())
7634 .header(USER_AGENT, self.hub._user_agent.clone());
7635
7636 if let Some(token) = token.as_ref() {
7637 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7638 }
7639
7640 let request = req_builder
7641 .header(CONTENT_LENGTH, 0_u64)
7642 .body(common::to_body::<String>(None));
7643
7644 client.request(request.unwrap()).await
7645 };
7646
7647 match req_result {
7648 Err(err) => {
7649 if let common::Retry::After(d) = dlg.http_error(&err) {
7650 sleep(d).await;
7651 continue;
7652 }
7653 dlg.finished(false);
7654 return Err(common::Error::HttpError(err));
7655 }
7656 Ok(res) => {
7657 let (mut parts, body) = res.into_parts();
7658 let mut body = common::Body::new(body);
7659 if !parts.status.is_success() {
7660 let bytes = common::to_bytes(body).await.unwrap_or_default();
7661 let error = serde_json::from_str(&common::to_string(&bytes));
7662 let response = common::to_response(parts, bytes.into());
7663
7664 if let common::Retry::After(d) =
7665 dlg.http_failure(&response, error.as_ref().ok())
7666 {
7667 sleep(d).await;
7668 continue;
7669 }
7670
7671 dlg.finished(false);
7672
7673 return Err(match error {
7674 Ok(value) => common::Error::BadRequest(value),
7675 _ => common::Error::Failure(response),
7676 });
7677 }
7678 let response = {
7679 let bytes = common::to_bytes(body).await.unwrap_or_default();
7680 let encoded = common::to_string(&bytes);
7681 match serde_json::from_str(&encoded) {
7682 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7683 Err(error) => {
7684 dlg.response_json_decode_error(&encoded, &error);
7685 return Err(common::Error::JsonDecodeError(
7686 encoded.to_string(),
7687 error,
7688 ));
7689 }
7690 }
7691 };
7692
7693 dlg.finished(true);
7694 return Ok(response);
7695 }
7696 }
7697 }
7698 }
7699
7700 /// 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.
7701 ///
7702 /// Sets the *page token* query property to the given value.
7703 ///
7704 /// Even though the property as already been set when instantiating this call,
7705 /// we provide this method for API completeness.
7706 pub fn page_token(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7707 self._page_token = new_value.to_string();
7708 self
7709 }
7710 /// Deprecated: Use `driveId` instead.
7711 ///
7712 /// Sets the *team drive id* query property to the given value.
7713 pub fn team_drive_id(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7714 self._team_drive_id = Some(new_value.to_string());
7715 self
7716 }
7717 /// Deprecated: Use `supportsAllDrives` instead.
7718 ///
7719 /// Sets the *supports team drives* query property to the given value.
7720 pub fn supports_team_drives(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7721 self._supports_team_drives = Some(new_value);
7722 self
7723 }
7724 /// Whether the requesting application supports both My Drives and shared drives.
7725 ///
7726 /// Sets the *supports all drives* query property to the given value.
7727 pub fn supports_all_drives(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7728 self._supports_all_drives = Some(new_value);
7729 self
7730 }
7731 /// A comma-separated list of spaces to query within the corpora. Supported values are 'drive' and 'appDataFolder'.
7732 ///
7733 /// Sets the *spaces* query property to the given value.
7734 pub fn spaces(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7735 self._spaces = Some(new_value.to_string());
7736 self
7737 }
7738 /// Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.
7739 ///
7740 /// Sets the *restrict to my drive* query property to the given value.
7741 pub fn restrict_to_my_drive(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7742 self._restrict_to_my_drive = Some(new_value);
7743 self
7744 }
7745 /// The maximum number of changes to return per page.
7746 ///
7747 /// Sets the *page size* query property to the given value.
7748 pub fn page_size(mut self, new_value: i32) -> ChangeListCall<'a, C> {
7749 self._page_size = Some(new_value);
7750 self
7751 }
7752 /// Deprecated: Use `includeItemsFromAllDrives` instead.
7753 ///
7754 /// Sets the *include team drive items* query property to the given value.
7755 pub fn include_team_drive_items(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7756 self._include_team_drive_items = Some(new_value);
7757 self
7758 }
7759 /// Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.
7760 ///
7761 /// Sets the *include removed* query property to the given value.
7762 pub fn include_removed(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7763 self._include_removed = Some(new_value);
7764 self
7765 }
7766 /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
7767 ///
7768 /// Sets the *include permissions for view* query property to the given value.
7769 pub fn include_permissions_for_view(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7770 self._include_permissions_for_view = Some(new_value.to_string());
7771 self
7772 }
7773 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
7774 ///
7775 /// Sets the *include labels* query property to the given value.
7776 pub fn include_labels(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7777 self._include_labels = Some(new_value.to_string());
7778 self
7779 }
7780 /// Whether both My Drive and shared drive items should be included in results.
7781 ///
7782 /// Sets the *include items from all drives* query property to the given value.
7783 pub fn include_items_from_all_drives(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7784 self._include_items_from_all_drives = Some(new_value);
7785 self
7786 }
7787 /// 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.
7788 ///
7789 /// Sets the *include corpus removals* query property to the given value.
7790 pub fn include_corpus_removals(mut self, new_value: bool) -> ChangeListCall<'a, C> {
7791 self._include_corpus_removals = Some(new_value);
7792 self
7793 }
7794 /// 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.
7795 ///
7796 /// Sets the *drive id* query property to the given value.
7797 pub fn drive_id(mut self, new_value: &str) -> ChangeListCall<'a, C> {
7798 self._drive_id = Some(new_value.to_string());
7799 self
7800 }
7801 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7802 /// while executing the actual API request.
7803 ///
7804 /// ````text
7805 /// It should be used to handle progress information, and to implement a certain level of resilience.
7806 /// ````
7807 ///
7808 /// Sets the *delegate* property to the given value.
7809 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeListCall<'a, C> {
7810 self._delegate = Some(new_value);
7811 self
7812 }
7813
7814 /// Set any additional parameter of the query string used in the request.
7815 /// It should be used to set parameters which are not yet available through their own
7816 /// setters.
7817 ///
7818 /// Please note that this method must not be used to set any of the known parameters
7819 /// which have their own setter method. If done anyway, the request will fail.
7820 ///
7821 /// # Additional Parameters
7822 ///
7823 /// * *$.xgafv* (query-string) - V1 error format.
7824 /// * *access_token* (query-string) - OAuth access token.
7825 /// * *alt* (query-string) - Data format for response.
7826 /// * *callback* (query-string) - JSONP
7827 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7828 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7829 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7830 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7831 /// * *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.
7832 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7833 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7834 pub fn param<T>(mut self, name: T, value: T) -> ChangeListCall<'a, C>
7835 where
7836 T: AsRef<str>,
7837 {
7838 self._additional_params
7839 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7840 self
7841 }
7842
7843 /// Identifies the authorization scope for the method you are building.
7844 ///
7845 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7846 /// [`Scope::MeetReadonly`].
7847 ///
7848 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7849 /// tokens for more than one scope.
7850 ///
7851 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7852 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7853 /// sufficient, a read-write scope will do as well.
7854 pub fn add_scope<St>(mut self, scope: St) -> ChangeListCall<'a, C>
7855 where
7856 St: AsRef<str>,
7857 {
7858 self._scopes.insert(String::from(scope.as_ref()));
7859 self
7860 }
7861 /// Identifies the authorization scope(s) for the method you are building.
7862 ///
7863 /// See [`Self::add_scope()`] for details.
7864 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeListCall<'a, C>
7865 where
7866 I: IntoIterator<Item = St>,
7867 St: AsRef<str>,
7868 {
7869 self._scopes
7870 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7871 self
7872 }
7873
7874 /// Removes all scopes, and no default scope will be used either.
7875 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7876 /// for details).
7877 pub fn clear_scopes(mut self) -> ChangeListCall<'a, C> {
7878 self._scopes.clear();
7879 self
7880 }
7881}
7882
7883/// Subscribes to changes for a user. For more information, see [Notifications for resource changes](https://developers.google.com/workspace/drive/api/guides/push).
7884///
7885/// A builder for the *watch* method supported by a *change* resource.
7886/// It is not used directly, but through a [`ChangeMethods`] instance.
7887///
7888/// # Example
7889///
7890/// Instantiate a resource method builder
7891///
7892/// ```test_harness,no_run
7893/// # extern crate hyper;
7894/// # extern crate hyper_rustls;
7895/// # extern crate google_drive3 as drive3;
7896/// use drive3::api::Channel;
7897/// # async fn dox() {
7898/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7899///
7900/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7901/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7902/// # .with_native_roots()
7903/// # .unwrap()
7904/// # .https_only()
7905/// # .enable_http2()
7906/// # .build();
7907///
7908/// # let executor = hyper_util::rt::TokioExecutor::new();
7909/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7910/// # secret,
7911/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7912/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7913/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7914/// # ),
7915/// # ).build().await.unwrap();
7916///
7917/// # let client = hyper_util::client::legacy::Client::builder(
7918/// # hyper_util::rt::TokioExecutor::new()
7919/// # )
7920/// # .build(
7921/// # hyper_rustls::HttpsConnectorBuilder::new()
7922/// # .with_native_roots()
7923/// # .unwrap()
7924/// # .https_or_http()
7925/// # .enable_http2()
7926/// # .build()
7927/// # );
7928/// # let mut hub = DriveHub::new(client, auth);
7929/// // As the method needs a request, you would usually fill it with the desired information
7930/// // into the respective structure. Some of the parts shown here might not be applicable !
7931/// // Values shown here are possibly random and not representative !
7932/// let mut req = Channel::default();
7933///
7934/// // You can configure optional parameters by calling the respective setters at will, and
7935/// // execute the final call using `doit()`.
7936/// // Values shown here are possibly random and not representative !
7937/// let result = hub.changes().watch(req, "pageToken")
7938/// .team_drive_id("sadipscing")
7939/// .supports_team_drives(true)
7940/// .supports_all_drives(true)
7941/// .spaces("sit")
7942/// .restrict_to_my_drive(true)
7943/// .page_size(-32)
7944/// .include_team_drive_items(true)
7945/// .include_removed(true)
7946/// .include_permissions_for_view("et")
7947/// .include_labels("sed")
7948/// .include_items_from_all_drives(false)
7949/// .include_corpus_removals(false)
7950/// .drive_id("sed")
7951/// .doit().await;
7952/// # }
7953/// ```
7954pub struct ChangeWatchCall<'a, C>
7955where
7956 C: 'a,
7957{
7958 hub: &'a DriveHub<C>,
7959 _request: Channel,
7960 _page_token: String,
7961 _team_drive_id: Option<String>,
7962 _supports_team_drives: Option<bool>,
7963 _supports_all_drives: Option<bool>,
7964 _spaces: Option<String>,
7965 _restrict_to_my_drive: Option<bool>,
7966 _page_size: Option<i32>,
7967 _include_team_drive_items: Option<bool>,
7968 _include_removed: Option<bool>,
7969 _include_permissions_for_view: Option<String>,
7970 _include_labels: Option<String>,
7971 _include_items_from_all_drives: Option<bool>,
7972 _include_corpus_removals: Option<bool>,
7973 _drive_id: Option<String>,
7974 _delegate: Option<&'a mut dyn common::Delegate>,
7975 _additional_params: HashMap<String, String>,
7976 _scopes: BTreeSet<String>,
7977}
7978
7979impl<'a, C> common::CallBuilder for ChangeWatchCall<'a, C> {}
7980
7981impl<'a, C> ChangeWatchCall<'a, C>
7982where
7983 C: common::Connector,
7984{
7985 /// Perform the operation you have build so far.
7986 pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
7987 use std::borrow::Cow;
7988 use std::io::{Read, Seek};
7989
7990 use common::{url::Params, ToParts};
7991 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7992
7993 let mut dd = common::DefaultDelegate;
7994 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7995 dlg.begin(common::MethodInfo {
7996 id: "drive.changes.watch",
7997 http_method: hyper::Method::POST,
7998 });
7999
8000 for &field in [
8001 "alt",
8002 "pageToken",
8003 "teamDriveId",
8004 "supportsTeamDrives",
8005 "supportsAllDrives",
8006 "spaces",
8007 "restrictToMyDrive",
8008 "pageSize",
8009 "includeTeamDriveItems",
8010 "includeRemoved",
8011 "includePermissionsForView",
8012 "includeLabels",
8013 "includeItemsFromAllDrives",
8014 "includeCorpusRemovals",
8015 "driveId",
8016 ]
8017 .iter()
8018 {
8019 if self._additional_params.contains_key(field) {
8020 dlg.finished(false);
8021 return Err(common::Error::FieldClash(field));
8022 }
8023 }
8024
8025 let mut params = Params::with_capacity(17 + self._additional_params.len());
8026 params.push("pageToken", self._page_token);
8027 if let Some(value) = self._team_drive_id.as_ref() {
8028 params.push("teamDriveId", value);
8029 }
8030 if let Some(value) = self._supports_team_drives.as_ref() {
8031 params.push("supportsTeamDrives", value.to_string());
8032 }
8033 if let Some(value) = self._supports_all_drives.as_ref() {
8034 params.push("supportsAllDrives", value.to_string());
8035 }
8036 if let Some(value) = self._spaces.as_ref() {
8037 params.push("spaces", value);
8038 }
8039 if let Some(value) = self._restrict_to_my_drive.as_ref() {
8040 params.push("restrictToMyDrive", value.to_string());
8041 }
8042 if let Some(value) = self._page_size.as_ref() {
8043 params.push("pageSize", value.to_string());
8044 }
8045 if let Some(value) = self._include_team_drive_items.as_ref() {
8046 params.push("includeTeamDriveItems", value.to_string());
8047 }
8048 if let Some(value) = self._include_removed.as_ref() {
8049 params.push("includeRemoved", value.to_string());
8050 }
8051 if let Some(value) = self._include_permissions_for_view.as_ref() {
8052 params.push("includePermissionsForView", value);
8053 }
8054 if let Some(value) = self._include_labels.as_ref() {
8055 params.push("includeLabels", value);
8056 }
8057 if let Some(value) = self._include_items_from_all_drives.as_ref() {
8058 params.push("includeItemsFromAllDrives", value.to_string());
8059 }
8060 if let Some(value) = self._include_corpus_removals.as_ref() {
8061 params.push("includeCorpusRemovals", value.to_string());
8062 }
8063 if let Some(value) = self._drive_id.as_ref() {
8064 params.push("driveId", value);
8065 }
8066
8067 params.extend(self._additional_params.iter());
8068
8069 params.push("alt", "json");
8070 let mut url = self.hub._base_url.clone() + "changes/watch";
8071 if self._scopes.is_empty() {
8072 self._scopes
8073 .insert(Scope::MeetReadonly.as_ref().to_string());
8074 }
8075
8076 let url = params.parse_with_url(&url);
8077
8078 let mut json_mime_type = mime::APPLICATION_JSON;
8079 let mut request_value_reader = {
8080 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8081 common::remove_json_null_values(&mut value);
8082 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8083 serde_json::to_writer(&mut dst, &value).unwrap();
8084 dst
8085 };
8086 let request_size = request_value_reader
8087 .seek(std::io::SeekFrom::End(0))
8088 .unwrap();
8089 request_value_reader
8090 .seek(std::io::SeekFrom::Start(0))
8091 .unwrap();
8092
8093 loop {
8094 let token = match self
8095 .hub
8096 .auth
8097 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8098 .await
8099 {
8100 Ok(token) => token,
8101 Err(e) => match dlg.token(e) {
8102 Ok(token) => token,
8103 Err(e) => {
8104 dlg.finished(false);
8105 return Err(common::Error::MissingToken(e));
8106 }
8107 },
8108 };
8109 request_value_reader
8110 .seek(std::io::SeekFrom::Start(0))
8111 .unwrap();
8112 let mut req_result = {
8113 let client = &self.hub.client;
8114 dlg.pre_request();
8115 let mut req_builder = hyper::Request::builder()
8116 .method(hyper::Method::POST)
8117 .uri(url.as_str())
8118 .header(USER_AGENT, self.hub._user_agent.clone());
8119
8120 if let Some(token) = token.as_ref() {
8121 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8122 }
8123
8124 let request = req_builder
8125 .header(CONTENT_TYPE, json_mime_type.to_string())
8126 .header(CONTENT_LENGTH, request_size as u64)
8127 .body(common::to_body(
8128 request_value_reader.get_ref().clone().into(),
8129 ));
8130
8131 client.request(request.unwrap()).await
8132 };
8133
8134 match req_result {
8135 Err(err) => {
8136 if let common::Retry::After(d) = dlg.http_error(&err) {
8137 sleep(d).await;
8138 continue;
8139 }
8140 dlg.finished(false);
8141 return Err(common::Error::HttpError(err));
8142 }
8143 Ok(res) => {
8144 let (mut parts, body) = res.into_parts();
8145 let mut body = common::Body::new(body);
8146 if !parts.status.is_success() {
8147 let bytes = common::to_bytes(body).await.unwrap_or_default();
8148 let error = serde_json::from_str(&common::to_string(&bytes));
8149 let response = common::to_response(parts, bytes.into());
8150
8151 if let common::Retry::After(d) =
8152 dlg.http_failure(&response, error.as_ref().ok())
8153 {
8154 sleep(d).await;
8155 continue;
8156 }
8157
8158 dlg.finished(false);
8159
8160 return Err(match error {
8161 Ok(value) => common::Error::BadRequest(value),
8162 _ => common::Error::Failure(response),
8163 });
8164 }
8165 let response = {
8166 let bytes = common::to_bytes(body).await.unwrap_or_default();
8167 let encoded = common::to_string(&bytes);
8168 match serde_json::from_str(&encoded) {
8169 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8170 Err(error) => {
8171 dlg.response_json_decode_error(&encoded, &error);
8172 return Err(common::Error::JsonDecodeError(
8173 encoded.to_string(),
8174 error,
8175 ));
8176 }
8177 }
8178 };
8179
8180 dlg.finished(true);
8181 return Ok(response);
8182 }
8183 }
8184 }
8185 }
8186
8187 ///
8188 /// Sets the *request* property to the given value.
8189 ///
8190 /// Even though the property as already been set when instantiating this call,
8191 /// we provide this method for API completeness.
8192 pub fn request(mut self, new_value: Channel) -> ChangeWatchCall<'a, C> {
8193 self._request = new_value;
8194 self
8195 }
8196 /// 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.
8197 ///
8198 /// Sets the *page token* query property to the given value.
8199 ///
8200 /// Even though the property as already been set when instantiating this call,
8201 /// we provide this method for API completeness.
8202 pub fn page_token(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
8203 self._page_token = new_value.to_string();
8204 self
8205 }
8206 /// Deprecated: Use `driveId` instead.
8207 ///
8208 /// Sets the *team drive id* query property to the given value.
8209 pub fn team_drive_id(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
8210 self._team_drive_id = Some(new_value.to_string());
8211 self
8212 }
8213 /// Deprecated: Use `supportsAllDrives` instead.
8214 ///
8215 /// Sets the *supports team drives* query property to the given value.
8216 pub fn supports_team_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
8217 self._supports_team_drives = Some(new_value);
8218 self
8219 }
8220 /// Whether the requesting application supports both My Drives and shared drives.
8221 ///
8222 /// Sets the *supports all drives* query property to the given value.
8223 pub fn supports_all_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
8224 self._supports_all_drives = Some(new_value);
8225 self
8226 }
8227 /// A comma-separated list of spaces to query within the corpora. Supported values are 'drive' and 'appDataFolder'.
8228 ///
8229 /// Sets the *spaces* query property to the given value.
8230 pub fn spaces(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
8231 self._spaces = Some(new_value.to_string());
8232 self
8233 }
8234 /// Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.
8235 ///
8236 /// Sets the *restrict to my drive* query property to the given value.
8237 pub fn restrict_to_my_drive(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
8238 self._restrict_to_my_drive = Some(new_value);
8239 self
8240 }
8241 /// The maximum number of changes to return per page.
8242 ///
8243 /// Sets the *page size* query property to the given value.
8244 pub fn page_size(mut self, new_value: i32) -> ChangeWatchCall<'a, C> {
8245 self._page_size = Some(new_value);
8246 self
8247 }
8248 /// Deprecated: Use `includeItemsFromAllDrives` instead.
8249 ///
8250 /// Sets the *include team drive items* query property to the given value.
8251 pub fn include_team_drive_items(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
8252 self._include_team_drive_items = Some(new_value);
8253 self
8254 }
8255 /// Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.
8256 ///
8257 /// Sets the *include removed* query property to the given value.
8258 pub fn include_removed(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
8259 self._include_removed = Some(new_value);
8260 self
8261 }
8262 /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
8263 ///
8264 /// Sets the *include permissions for view* query property to the given value.
8265 pub fn include_permissions_for_view(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
8266 self._include_permissions_for_view = Some(new_value.to_string());
8267 self
8268 }
8269 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
8270 ///
8271 /// Sets the *include labels* query property to the given value.
8272 pub fn include_labels(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
8273 self._include_labels = Some(new_value.to_string());
8274 self
8275 }
8276 /// Whether both My Drive and shared drive items should be included in results.
8277 ///
8278 /// Sets the *include items from all drives* query property to the given value.
8279 pub fn include_items_from_all_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
8280 self._include_items_from_all_drives = Some(new_value);
8281 self
8282 }
8283 /// 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.
8284 ///
8285 /// Sets the *include corpus removals* query property to the given value.
8286 pub fn include_corpus_removals(mut self, new_value: bool) -> ChangeWatchCall<'a, C> {
8287 self._include_corpus_removals = Some(new_value);
8288 self
8289 }
8290 /// 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.
8291 ///
8292 /// Sets the *drive id* query property to the given value.
8293 pub fn drive_id(mut self, new_value: &str) -> ChangeWatchCall<'a, C> {
8294 self._drive_id = Some(new_value.to_string());
8295 self
8296 }
8297 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8298 /// while executing the actual API request.
8299 ///
8300 /// ````text
8301 /// It should be used to handle progress information, and to implement a certain level of resilience.
8302 /// ````
8303 ///
8304 /// Sets the *delegate* property to the given value.
8305 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeWatchCall<'a, C> {
8306 self._delegate = Some(new_value);
8307 self
8308 }
8309
8310 /// Set any additional parameter of the query string used in the request.
8311 /// It should be used to set parameters which are not yet available through their own
8312 /// setters.
8313 ///
8314 /// Please note that this method must not be used to set any of the known parameters
8315 /// which have their own setter method. If done anyway, the request will fail.
8316 ///
8317 /// # Additional Parameters
8318 ///
8319 /// * *$.xgafv* (query-string) - V1 error format.
8320 /// * *access_token* (query-string) - OAuth access token.
8321 /// * *alt* (query-string) - Data format for response.
8322 /// * *callback* (query-string) - JSONP
8323 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8324 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8325 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8326 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8327 /// * *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.
8328 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8329 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8330 pub fn param<T>(mut self, name: T, value: T) -> ChangeWatchCall<'a, C>
8331 where
8332 T: AsRef<str>,
8333 {
8334 self._additional_params
8335 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8336 self
8337 }
8338
8339 /// Identifies the authorization scope for the method you are building.
8340 ///
8341 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8342 /// [`Scope::MeetReadonly`].
8343 ///
8344 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8345 /// tokens for more than one scope.
8346 ///
8347 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8348 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8349 /// sufficient, a read-write scope will do as well.
8350 pub fn add_scope<St>(mut self, scope: St) -> ChangeWatchCall<'a, C>
8351 where
8352 St: AsRef<str>,
8353 {
8354 self._scopes.insert(String::from(scope.as_ref()));
8355 self
8356 }
8357 /// Identifies the authorization scope(s) for the method you are building.
8358 ///
8359 /// See [`Self::add_scope()`] for details.
8360 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeWatchCall<'a, C>
8361 where
8362 I: IntoIterator<Item = St>,
8363 St: AsRef<str>,
8364 {
8365 self._scopes
8366 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8367 self
8368 }
8369
8370 /// Removes all scopes, and no default scope will be used either.
8371 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8372 /// for details).
8373 pub fn clear_scopes(mut self) -> ChangeWatchCall<'a, C> {
8374 self._scopes.clear();
8375 self
8376 }
8377}
8378
8379/// Stops watching resources through this channel. For more information, see [Notifications for resource changes](https://developers.google.com/workspace/drive/api/guides/push).
8380///
8381/// A builder for the *stop* method supported by a *channel* resource.
8382/// It is not used directly, but through a [`ChannelMethods`] instance.
8383///
8384/// # Example
8385///
8386/// Instantiate a resource method builder
8387///
8388/// ```test_harness,no_run
8389/// # extern crate hyper;
8390/// # extern crate hyper_rustls;
8391/// # extern crate google_drive3 as drive3;
8392/// use drive3::api::Channel;
8393/// # async fn dox() {
8394/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8395///
8396/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8397/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8398/// # .with_native_roots()
8399/// # .unwrap()
8400/// # .https_only()
8401/// # .enable_http2()
8402/// # .build();
8403///
8404/// # let executor = hyper_util::rt::TokioExecutor::new();
8405/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8406/// # secret,
8407/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8408/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8409/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8410/// # ),
8411/// # ).build().await.unwrap();
8412///
8413/// # let client = hyper_util::client::legacy::Client::builder(
8414/// # hyper_util::rt::TokioExecutor::new()
8415/// # )
8416/// # .build(
8417/// # hyper_rustls::HttpsConnectorBuilder::new()
8418/// # .with_native_roots()
8419/// # .unwrap()
8420/// # .https_or_http()
8421/// # .enable_http2()
8422/// # .build()
8423/// # );
8424/// # let mut hub = DriveHub::new(client, auth);
8425/// // As the method needs a request, you would usually fill it with the desired information
8426/// // into the respective structure. Some of the parts shown here might not be applicable !
8427/// // Values shown here are possibly random and not representative !
8428/// let mut req = Channel::default();
8429///
8430/// // You can configure optional parameters by calling the respective setters at will, and
8431/// // execute the final call using `doit()`.
8432/// // Values shown here are possibly random and not representative !
8433/// let result = hub.channels().stop(req)
8434/// .doit().await;
8435/// # }
8436/// ```
8437pub struct ChannelStopCall<'a, C>
8438where
8439 C: 'a,
8440{
8441 hub: &'a DriveHub<C>,
8442 _request: Channel,
8443 _delegate: Option<&'a mut dyn common::Delegate>,
8444 _additional_params: HashMap<String, String>,
8445 _scopes: BTreeSet<String>,
8446}
8447
8448impl<'a, C> common::CallBuilder for ChannelStopCall<'a, C> {}
8449
8450impl<'a, C> ChannelStopCall<'a, C>
8451where
8452 C: common::Connector,
8453{
8454 /// Perform the operation you have build so far.
8455 pub async fn doit(mut self) -> common::Result<common::Response> {
8456 use std::borrow::Cow;
8457 use std::io::{Read, Seek};
8458
8459 use common::{url::Params, ToParts};
8460 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8461
8462 let mut dd = common::DefaultDelegate;
8463 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8464 dlg.begin(common::MethodInfo {
8465 id: "drive.channels.stop",
8466 http_method: hyper::Method::POST,
8467 });
8468
8469 for &field in [].iter() {
8470 if self._additional_params.contains_key(field) {
8471 dlg.finished(false);
8472 return Err(common::Error::FieldClash(field));
8473 }
8474 }
8475
8476 let mut params = Params::with_capacity(2 + self._additional_params.len());
8477
8478 params.extend(self._additional_params.iter());
8479
8480 let mut url = self.hub._base_url.clone() + "channels/stop";
8481 if self._scopes.is_empty() {
8482 self._scopes
8483 .insert(Scope::MeetReadonly.as_ref().to_string());
8484 }
8485
8486 let url = params.parse_with_url(&url);
8487
8488 let mut json_mime_type = mime::APPLICATION_JSON;
8489 let mut request_value_reader = {
8490 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8491 common::remove_json_null_values(&mut value);
8492 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8493 serde_json::to_writer(&mut dst, &value).unwrap();
8494 dst
8495 };
8496 let request_size = request_value_reader
8497 .seek(std::io::SeekFrom::End(0))
8498 .unwrap();
8499 request_value_reader
8500 .seek(std::io::SeekFrom::Start(0))
8501 .unwrap();
8502
8503 loop {
8504 let token = match self
8505 .hub
8506 .auth
8507 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8508 .await
8509 {
8510 Ok(token) => token,
8511 Err(e) => match dlg.token(e) {
8512 Ok(token) => token,
8513 Err(e) => {
8514 dlg.finished(false);
8515 return Err(common::Error::MissingToken(e));
8516 }
8517 },
8518 };
8519 request_value_reader
8520 .seek(std::io::SeekFrom::Start(0))
8521 .unwrap();
8522 let mut req_result = {
8523 let client = &self.hub.client;
8524 dlg.pre_request();
8525 let mut req_builder = hyper::Request::builder()
8526 .method(hyper::Method::POST)
8527 .uri(url.as_str())
8528 .header(USER_AGENT, self.hub._user_agent.clone());
8529
8530 if let Some(token) = token.as_ref() {
8531 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8532 }
8533
8534 let request = req_builder
8535 .header(CONTENT_TYPE, json_mime_type.to_string())
8536 .header(CONTENT_LENGTH, request_size as u64)
8537 .body(common::to_body(
8538 request_value_reader.get_ref().clone().into(),
8539 ));
8540
8541 client.request(request.unwrap()).await
8542 };
8543
8544 match req_result {
8545 Err(err) => {
8546 if let common::Retry::After(d) = dlg.http_error(&err) {
8547 sleep(d).await;
8548 continue;
8549 }
8550 dlg.finished(false);
8551 return Err(common::Error::HttpError(err));
8552 }
8553 Ok(res) => {
8554 let (mut parts, body) = res.into_parts();
8555 let mut body = common::Body::new(body);
8556 if !parts.status.is_success() {
8557 let bytes = common::to_bytes(body).await.unwrap_or_default();
8558 let error = serde_json::from_str(&common::to_string(&bytes));
8559 let response = common::to_response(parts, bytes.into());
8560
8561 if let common::Retry::After(d) =
8562 dlg.http_failure(&response, error.as_ref().ok())
8563 {
8564 sleep(d).await;
8565 continue;
8566 }
8567
8568 dlg.finished(false);
8569
8570 return Err(match error {
8571 Ok(value) => common::Error::BadRequest(value),
8572 _ => common::Error::Failure(response),
8573 });
8574 }
8575 let response = common::Response::from_parts(parts, body);
8576
8577 dlg.finished(true);
8578 return Ok(response);
8579 }
8580 }
8581 }
8582 }
8583
8584 ///
8585 /// Sets the *request* property to the given value.
8586 ///
8587 /// Even though the property as already been set when instantiating this call,
8588 /// we provide this method for API completeness.
8589 pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C> {
8590 self._request = new_value;
8591 self
8592 }
8593 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8594 /// while executing the actual API request.
8595 ///
8596 /// ````text
8597 /// It should be used to handle progress information, and to implement a certain level of resilience.
8598 /// ````
8599 ///
8600 /// Sets the *delegate* property to the given value.
8601 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChannelStopCall<'a, C> {
8602 self._delegate = Some(new_value);
8603 self
8604 }
8605
8606 /// Set any additional parameter of the query string used in the request.
8607 /// It should be used to set parameters which are not yet available through their own
8608 /// setters.
8609 ///
8610 /// Please note that this method must not be used to set any of the known parameters
8611 /// which have their own setter method. If done anyway, the request will fail.
8612 ///
8613 /// # Additional Parameters
8614 ///
8615 /// * *$.xgafv* (query-string) - V1 error format.
8616 /// * *access_token* (query-string) - OAuth access token.
8617 /// * *alt* (query-string) - Data format for response.
8618 /// * *callback* (query-string) - JSONP
8619 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8620 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8621 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8622 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8623 /// * *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.
8624 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8625 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8626 pub fn param<T>(mut self, name: T, value: T) -> ChannelStopCall<'a, C>
8627 where
8628 T: AsRef<str>,
8629 {
8630 self._additional_params
8631 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8632 self
8633 }
8634
8635 /// Identifies the authorization scope for the method you are building.
8636 ///
8637 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8638 /// [`Scope::MeetReadonly`].
8639 ///
8640 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8641 /// tokens for more than one scope.
8642 ///
8643 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8644 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8645 /// sufficient, a read-write scope will do as well.
8646 pub fn add_scope<St>(mut self, scope: St) -> ChannelStopCall<'a, C>
8647 where
8648 St: AsRef<str>,
8649 {
8650 self._scopes.insert(String::from(scope.as_ref()));
8651 self
8652 }
8653 /// Identifies the authorization scope(s) for the method you are building.
8654 ///
8655 /// See [`Self::add_scope()`] for details.
8656 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChannelStopCall<'a, C>
8657 where
8658 I: IntoIterator<Item = St>,
8659 St: AsRef<str>,
8660 {
8661 self._scopes
8662 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8663 self
8664 }
8665
8666 /// Removes all scopes, and no default scope will be used either.
8667 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8668 /// for details).
8669 pub fn clear_scopes(mut self) -> ChannelStopCall<'a, C> {
8670 self._scopes.clear();
8671 self
8672 }
8673}
8674
8675/// Creates a comment on a file. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments). Required: The `fields` parameter must be set. To return the exact fields you need, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter).
8676///
8677/// A builder for the *create* method supported by a *comment* resource.
8678/// It is not used directly, but through a [`CommentMethods`] instance.
8679///
8680/// # Example
8681///
8682/// Instantiate a resource method builder
8683///
8684/// ```test_harness,no_run
8685/// # extern crate hyper;
8686/// # extern crate hyper_rustls;
8687/// # extern crate google_drive3 as drive3;
8688/// use drive3::api::Comment;
8689/// # async fn dox() {
8690/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8691///
8692/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8693/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8694/// # .with_native_roots()
8695/// # .unwrap()
8696/// # .https_only()
8697/// # .enable_http2()
8698/// # .build();
8699///
8700/// # let executor = hyper_util::rt::TokioExecutor::new();
8701/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8702/// # secret,
8703/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8704/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8705/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8706/// # ),
8707/// # ).build().await.unwrap();
8708///
8709/// # let client = hyper_util::client::legacy::Client::builder(
8710/// # hyper_util::rt::TokioExecutor::new()
8711/// # )
8712/// # .build(
8713/// # hyper_rustls::HttpsConnectorBuilder::new()
8714/// # .with_native_roots()
8715/// # .unwrap()
8716/// # .https_or_http()
8717/// # .enable_http2()
8718/// # .build()
8719/// # );
8720/// # let mut hub = DriveHub::new(client, auth);
8721/// // As the method needs a request, you would usually fill it with the desired information
8722/// // into the respective structure. Some of the parts shown here might not be applicable !
8723/// // Values shown here are possibly random and not representative !
8724/// let mut req = Comment::default();
8725///
8726/// // You can configure optional parameters by calling the respective setters at will, and
8727/// // execute the final call using `doit()`.
8728/// // Values shown here are possibly random and not representative !
8729/// let result = hub.comments().create(req, "fileId")
8730/// .doit().await;
8731/// # }
8732/// ```
8733pub struct CommentCreateCall<'a, C>
8734where
8735 C: 'a,
8736{
8737 hub: &'a DriveHub<C>,
8738 _request: Comment,
8739 _file_id: String,
8740 _delegate: Option<&'a mut dyn common::Delegate>,
8741 _additional_params: HashMap<String, String>,
8742 _scopes: BTreeSet<String>,
8743}
8744
8745impl<'a, C> common::CallBuilder for CommentCreateCall<'a, C> {}
8746
8747impl<'a, C> CommentCreateCall<'a, C>
8748where
8749 C: common::Connector,
8750{
8751 /// Perform the operation you have build so far.
8752 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
8753 use std::borrow::Cow;
8754 use std::io::{Read, Seek};
8755
8756 use common::{url::Params, ToParts};
8757 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8758
8759 let mut dd = common::DefaultDelegate;
8760 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8761 dlg.begin(common::MethodInfo {
8762 id: "drive.comments.create",
8763 http_method: hyper::Method::POST,
8764 });
8765
8766 for &field in ["alt", "fileId"].iter() {
8767 if self._additional_params.contains_key(field) {
8768 dlg.finished(false);
8769 return Err(common::Error::FieldClash(field));
8770 }
8771 }
8772
8773 let mut params = Params::with_capacity(4 + self._additional_params.len());
8774 params.push("fileId", self._file_id);
8775
8776 params.extend(self._additional_params.iter());
8777
8778 params.push("alt", "json");
8779 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments";
8780 if self._scopes.is_empty() {
8781 self._scopes.insert(Scope::Full.as_ref().to_string());
8782 }
8783
8784 #[allow(clippy::single_element_loop)]
8785 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
8786 url = params.uri_replacement(url, param_name, find_this, false);
8787 }
8788 {
8789 let to_remove = ["fileId"];
8790 params.remove_params(&to_remove);
8791 }
8792
8793 let url = params.parse_with_url(&url);
8794
8795 let mut json_mime_type = mime::APPLICATION_JSON;
8796 let mut request_value_reader = {
8797 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8798 common::remove_json_null_values(&mut value);
8799 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8800 serde_json::to_writer(&mut dst, &value).unwrap();
8801 dst
8802 };
8803 let request_size = request_value_reader
8804 .seek(std::io::SeekFrom::End(0))
8805 .unwrap();
8806 request_value_reader
8807 .seek(std::io::SeekFrom::Start(0))
8808 .unwrap();
8809
8810 loop {
8811 let token = match self
8812 .hub
8813 .auth
8814 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8815 .await
8816 {
8817 Ok(token) => token,
8818 Err(e) => match dlg.token(e) {
8819 Ok(token) => token,
8820 Err(e) => {
8821 dlg.finished(false);
8822 return Err(common::Error::MissingToken(e));
8823 }
8824 },
8825 };
8826 request_value_reader
8827 .seek(std::io::SeekFrom::Start(0))
8828 .unwrap();
8829 let mut req_result = {
8830 let client = &self.hub.client;
8831 dlg.pre_request();
8832 let mut req_builder = hyper::Request::builder()
8833 .method(hyper::Method::POST)
8834 .uri(url.as_str())
8835 .header(USER_AGENT, self.hub._user_agent.clone());
8836
8837 if let Some(token) = token.as_ref() {
8838 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8839 }
8840
8841 let request = req_builder
8842 .header(CONTENT_TYPE, json_mime_type.to_string())
8843 .header(CONTENT_LENGTH, request_size as u64)
8844 .body(common::to_body(
8845 request_value_reader.get_ref().clone().into(),
8846 ));
8847
8848 client.request(request.unwrap()).await
8849 };
8850
8851 match req_result {
8852 Err(err) => {
8853 if let common::Retry::After(d) = dlg.http_error(&err) {
8854 sleep(d).await;
8855 continue;
8856 }
8857 dlg.finished(false);
8858 return Err(common::Error::HttpError(err));
8859 }
8860 Ok(res) => {
8861 let (mut parts, body) = res.into_parts();
8862 let mut body = common::Body::new(body);
8863 if !parts.status.is_success() {
8864 let bytes = common::to_bytes(body).await.unwrap_or_default();
8865 let error = serde_json::from_str(&common::to_string(&bytes));
8866 let response = common::to_response(parts, bytes.into());
8867
8868 if let common::Retry::After(d) =
8869 dlg.http_failure(&response, error.as_ref().ok())
8870 {
8871 sleep(d).await;
8872 continue;
8873 }
8874
8875 dlg.finished(false);
8876
8877 return Err(match error {
8878 Ok(value) => common::Error::BadRequest(value),
8879 _ => common::Error::Failure(response),
8880 });
8881 }
8882 let response = {
8883 let bytes = common::to_bytes(body).await.unwrap_or_default();
8884 let encoded = common::to_string(&bytes);
8885 match serde_json::from_str(&encoded) {
8886 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8887 Err(error) => {
8888 dlg.response_json_decode_error(&encoded, &error);
8889 return Err(common::Error::JsonDecodeError(
8890 encoded.to_string(),
8891 error,
8892 ));
8893 }
8894 }
8895 };
8896
8897 dlg.finished(true);
8898 return Ok(response);
8899 }
8900 }
8901 }
8902 }
8903
8904 ///
8905 /// Sets the *request* property to the given value.
8906 ///
8907 /// Even though the property as already been set when instantiating this call,
8908 /// we provide this method for API completeness.
8909 pub fn request(mut self, new_value: Comment) -> CommentCreateCall<'a, C> {
8910 self._request = new_value;
8911 self
8912 }
8913 /// The ID of the file.
8914 ///
8915 /// Sets the *file id* path property to the given value.
8916 ///
8917 /// Even though the property as already been set when instantiating this call,
8918 /// we provide this method for API completeness.
8919 pub fn file_id(mut self, new_value: &str) -> CommentCreateCall<'a, C> {
8920 self._file_id = new_value.to_string();
8921 self
8922 }
8923 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8924 /// while executing the actual API request.
8925 ///
8926 /// ````text
8927 /// It should be used to handle progress information, and to implement a certain level of resilience.
8928 /// ````
8929 ///
8930 /// Sets the *delegate* property to the given value.
8931 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentCreateCall<'a, C> {
8932 self._delegate = Some(new_value);
8933 self
8934 }
8935
8936 /// Set any additional parameter of the query string used in the request.
8937 /// It should be used to set parameters which are not yet available through their own
8938 /// setters.
8939 ///
8940 /// Please note that this method must not be used to set any of the known parameters
8941 /// which have their own setter method. If done anyway, the request will fail.
8942 ///
8943 /// # Additional Parameters
8944 ///
8945 /// * *$.xgafv* (query-string) - V1 error format.
8946 /// * *access_token* (query-string) - OAuth access token.
8947 /// * *alt* (query-string) - Data format for response.
8948 /// * *callback* (query-string) - JSONP
8949 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8950 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8951 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8952 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8953 /// * *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.
8954 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8955 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8956 pub fn param<T>(mut self, name: T, value: T) -> CommentCreateCall<'a, C>
8957 where
8958 T: AsRef<str>,
8959 {
8960 self._additional_params
8961 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8962 self
8963 }
8964
8965 /// Identifies the authorization scope for the method you are building.
8966 ///
8967 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8968 /// [`Scope::Full`].
8969 ///
8970 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8971 /// tokens for more than one scope.
8972 ///
8973 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8974 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8975 /// sufficient, a read-write scope will do as well.
8976 pub fn add_scope<St>(mut self, scope: St) -> CommentCreateCall<'a, C>
8977 where
8978 St: AsRef<str>,
8979 {
8980 self._scopes.insert(String::from(scope.as_ref()));
8981 self
8982 }
8983 /// Identifies the authorization scope(s) for the method you are building.
8984 ///
8985 /// See [`Self::add_scope()`] for details.
8986 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentCreateCall<'a, C>
8987 where
8988 I: IntoIterator<Item = St>,
8989 St: AsRef<str>,
8990 {
8991 self._scopes
8992 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8993 self
8994 }
8995
8996 /// Removes all scopes, and no default scope will be used either.
8997 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8998 /// for details).
8999 pub fn clear_scopes(mut self) -> CommentCreateCall<'a, C> {
9000 self._scopes.clear();
9001 self
9002 }
9003}
9004
9005/// Deletes a comment. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
9006///
9007/// A builder for the *delete* method supported by a *comment* resource.
9008/// It is not used directly, but through a [`CommentMethods`] instance.
9009///
9010/// # Example
9011///
9012/// Instantiate a resource method builder
9013///
9014/// ```test_harness,no_run
9015/// # extern crate hyper;
9016/// # extern crate hyper_rustls;
9017/// # extern crate google_drive3 as drive3;
9018/// # async fn dox() {
9019/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9020///
9021/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9022/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9023/// # .with_native_roots()
9024/// # .unwrap()
9025/// # .https_only()
9026/// # .enable_http2()
9027/// # .build();
9028///
9029/// # let executor = hyper_util::rt::TokioExecutor::new();
9030/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9031/// # secret,
9032/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9033/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9034/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9035/// # ),
9036/// # ).build().await.unwrap();
9037///
9038/// # let client = hyper_util::client::legacy::Client::builder(
9039/// # hyper_util::rt::TokioExecutor::new()
9040/// # )
9041/// # .build(
9042/// # hyper_rustls::HttpsConnectorBuilder::new()
9043/// # .with_native_roots()
9044/// # .unwrap()
9045/// # .https_or_http()
9046/// # .enable_http2()
9047/// # .build()
9048/// # );
9049/// # let mut hub = DriveHub::new(client, auth);
9050/// // You can configure optional parameters by calling the respective setters at will, and
9051/// // execute the final call using `doit()`.
9052/// // Values shown here are possibly random and not representative !
9053/// let result = hub.comments().delete("fileId", "commentId")
9054/// .doit().await;
9055/// # }
9056/// ```
9057pub struct CommentDeleteCall<'a, C>
9058where
9059 C: 'a,
9060{
9061 hub: &'a DriveHub<C>,
9062 _file_id: String,
9063 _comment_id: String,
9064 _delegate: Option<&'a mut dyn common::Delegate>,
9065 _additional_params: HashMap<String, String>,
9066 _scopes: BTreeSet<String>,
9067}
9068
9069impl<'a, C> common::CallBuilder for CommentDeleteCall<'a, C> {}
9070
9071impl<'a, C> CommentDeleteCall<'a, C>
9072where
9073 C: common::Connector,
9074{
9075 /// Perform the operation you have build so far.
9076 pub async fn doit(mut self) -> common::Result<common::Response> {
9077 use std::borrow::Cow;
9078 use std::io::{Read, Seek};
9079
9080 use common::{url::Params, ToParts};
9081 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9082
9083 let mut dd = common::DefaultDelegate;
9084 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9085 dlg.begin(common::MethodInfo {
9086 id: "drive.comments.delete",
9087 http_method: hyper::Method::DELETE,
9088 });
9089
9090 for &field in ["fileId", "commentId"].iter() {
9091 if self._additional_params.contains_key(field) {
9092 dlg.finished(false);
9093 return Err(common::Error::FieldClash(field));
9094 }
9095 }
9096
9097 let mut params = Params::with_capacity(3 + self._additional_params.len());
9098 params.push("fileId", self._file_id);
9099 params.push("commentId", self._comment_id);
9100
9101 params.extend(self._additional_params.iter());
9102
9103 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}";
9104 if self._scopes.is_empty() {
9105 self._scopes.insert(Scope::Full.as_ref().to_string());
9106 }
9107
9108 #[allow(clippy::single_element_loop)]
9109 for &(find_this, param_name) in
9110 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
9111 {
9112 url = params.uri_replacement(url, param_name, find_this, false);
9113 }
9114 {
9115 let to_remove = ["commentId", "fileId"];
9116 params.remove_params(&to_remove);
9117 }
9118
9119 let url = params.parse_with_url(&url);
9120
9121 loop {
9122 let token = match self
9123 .hub
9124 .auth
9125 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9126 .await
9127 {
9128 Ok(token) => token,
9129 Err(e) => match dlg.token(e) {
9130 Ok(token) => token,
9131 Err(e) => {
9132 dlg.finished(false);
9133 return Err(common::Error::MissingToken(e));
9134 }
9135 },
9136 };
9137 let mut req_result = {
9138 let client = &self.hub.client;
9139 dlg.pre_request();
9140 let mut req_builder = hyper::Request::builder()
9141 .method(hyper::Method::DELETE)
9142 .uri(url.as_str())
9143 .header(USER_AGENT, self.hub._user_agent.clone());
9144
9145 if let Some(token) = token.as_ref() {
9146 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9147 }
9148
9149 let request = req_builder
9150 .header(CONTENT_LENGTH, 0_u64)
9151 .body(common::to_body::<String>(None));
9152
9153 client.request(request.unwrap()).await
9154 };
9155
9156 match req_result {
9157 Err(err) => {
9158 if let common::Retry::After(d) = dlg.http_error(&err) {
9159 sleep(d).await;
9160 continue;
9161 }
9162 dlg.finished(false);
9163 return Err(common::Error::HttpError(err));
9164 }
9165 Ok(res) => {
9166 let (mut parts, body) = res.into_parts();
9167 let mut body = common::Body::new(body);
9168 if !parts.status.is_success() {
9169 let bytes = common::to_bytes(body).await.unwrap_or_default();
9170 let error = serde_json::from_str(&common::to_string(&bytes));
9171 let response = common::to_response(parts, bytes.into());
9172
9173 if let common::Retry::After(d) =
9174 dlg.http_failure(&response, error.as_ref().ok())
9175 {
9176 sleep(d).await;
9177 continue;
9178 }
9179
9180 dlg.finished(false);
9181
9182 return Err(match error {
9183 Ok(value) => common::Error::BadRequest(value),
9184 _ => common::Error::Failure(response),
9185 });
9186 }
9187 let response = common::Response::from_parts(parts, body);
9188
9189 dlg.finished(true);
9190 return Ok(response);
9191 }
9192 }
9193 }
9194 }
9195
9196 /// The ID of the file.
9197 ///
9198 /// Sets the *file id* path property to the given value.
9199 ///
9200 /// Even though the property as already been set when instantiating this call,
9201 /// we provide this method for API completeness.
9202 pub fn file_id(mut self, new_value: &str) -> CommentDeleteCall<'a, C> {
9203 self._file_id = new_value.to_string();
9204 self
9205 }
9206 /// The ID of the comment.
9207 ///
9208 /// Sets the *comment id* path property to the given value.
9209 ///
9210 /// Even though the property as already been set when instantiating this call,
9211 /// we provide this method for API completeness.
9212 pub fn comment_id(mut self, new_value: &str) -> CommentDeleteCall<'a, C> {
9213 self._comment_id = new_value.to_string();
9214 self
9215 }
9216 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9217 /// while executing the actual API request.
9218 ///
9219 /// ````text
9220 /// It should be used to handle progress information, and to implement a certain level of resilience.
9221 /// ````
9222 ///
9223 /// Sets the *delegate* property to the given value.
9224 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentDeleteCall<'a, C> {
9225 self._delegate = Some(new_value);
9226 self
9227 }
9228
9229 /// Set any additional parameter of the query string used in the request.
9230 /// It should be used to set parameters which are not yet available through their own
9231 /// setters.
9232 ///
9233 /// Please note that this method must not be used to set any of the known parameters
9234 /// which have their own setter method. If done anyway, the request will fail.
9235 ///
9236 /// # Additional Parameters
9237 ///
9238 /// * *$.xgafv* (query-string) - V1 error format.
9239 /// * *access_token* (query-string) - OAuth access token.
9240 /// * *alt* (query-string) - Data format for response.
9241 /// * *callback* (query-string) - JSONP
9242 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9243 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9244 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9245 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9246 /// * *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.
9247 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9248 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9249 pub fn param<T>(mut self, name: T, value: T) -> CommentDeleteCall<'a, C>
9250 where
9251 T: AsRef<str>,
9252 {
9253 self._additional_params
9254 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9255 self
9256 }
9257
9258 /// Identifies the authorization scope for the method you are building.
9259 ///
9260 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9261 /// [`Scope::Full`].
9262 ///
9263 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9264 /// tokens for more than one scope.
9265 ///
9266 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9267 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9268 /// sufficient, a read-write scope will do as well.
9269 pub fn add_scope<St>(mut self, scope: St) -> CommentDeleteCall<'a, C>
9270 where
9271 St: AsRef<str>,
9272 {
9273 self._scopes.insert(String::from(scope.as_ref()));
9274 self
9275 }
9276 /// Identifies the authorization scope(s) for the method you are building.
9277 ///
9278 /// See [`Self::add_scope()`] for details.
9279 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentDeleteCall<'a, C>
9280 where
9281 I: IntoIterator<Item = St>,
9282 St: AsRef<str>,
9283 {
9284 self._scopes
9285 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9286 self
9287 }
9288
9289 /// Removes all scopes, and no default scope will be used either.
9290 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9291 /// for details).
9292 pub fn clear_scopes(mut self) -> CommentDeleteCall<'a, C> {
9293 self._scopes.clear();
9294 self
9295 }
9296}
9297
9298/// Gets a comment by ID. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments). Required: The `fields` parameter must be set. To return the exact fields you need, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter).
9299///
9300/// A builder for the *get* method supported by a *comment* resource.
9301/// It is not used directly, but through a [`CommentMethods`] instance.
9302///
9303/// # Example
9304///
9305/// Instantiate a resource method builder
9306///
9307/// ```test_harness,no_run
9308/// # extern crate hyper;
9309/// # extern crate hyper_rustls;
9310/// # extern crate google_drive3 as drive3;
9311/// # async fn dox() {
9312/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9313///
9314/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9315/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9316/// # .with_native_roots()
9317/// # .unwrap()
9318/// # .https_only()
9319/// # .enable_http2()
9320/// # .build();
9321///
9322/// # let executor = hyper_util::rt::TokioExecutor::new();
9323/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9324/// # secret,
9325/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9326/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9327/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9328/// # ),
9329/// # ).build().await.unwrap();
9330///
9331/// # let client = hyper_util::client::legacy::Client::builder(
9332/// # hyper_util::rt::TokioExecutor::new()
9333/// # )
9334/// # .build(
9335/// # hyper_rustls::HttpsConnectorBuilder::new()
9336/// # .with_native_roots()
9337/// # .unwrap()
9338/// # .https_or_http()
9339/// # .enable_http2()
9340/// # .build()
9341/// # );
9342/// # let mut hub = DriveHub::new(client, auth);
9343/// // You can configure optional parameters by calling the respective setters at will, and
9344/// // execute the final call using `doit()`.
9345/// // Values shown here are possibly random and not representative !
9346/// let result = hub.comments().get("fileId", "commentId")
9347/// .include_deleted(true)
9348/// .doit().await;
9349/// # }
9350/// ```
9351pub struct CommentGetCall<'a, C>
9352where
9353 C: 'a,
9354{
9355 hub: &'a DriveHub<C>,
9356 _file_id: String,
9357 _comment_id: String,
9358 _include_deleted: Option<bool>,
9359 _delegate: Option<&'a mut dyn common::Delegate>,
9360 _additional_params: HashMap<String, String>,
9361 _scopes: BTreeSet<String>,
9362}
9363
9364impl<'a, C> common::CallBuilder for CommentGetCall<'a, C> {}
9365
9366impl<'a, C> CommentGetCall<'a, C>
9367where
9368 C: common::Connector,
9369{
9370 /// Perform the operation you have build so far.
9371 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
9372 use std::borrow::Cow;
9373 use std::io::{Read, Seek};
9374
9375 use common::{url::Params, ToParts};
9376 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9377
9378 let mut dd = common::DefaultDelegate;
9379 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9380 dlg.begin(common::MethodInfo {
9381 id: "drive.comments.get",
9382 http_method: hyper::Method::GET,
9383 });
9384
9385 for &field in ["alt", "fileId", "commentId", "includeDeleted"].iter() {
9386 if self._additional_params.contains_key(field) {
9387 dlg.finished(false);
9388 return Err(common::Error::FieldClash(field));
9389 }
9390 }
9391
9392 let mut params = Params::with_capacity(5 + self._additional_params.len());
9393 params.push("fileId", self._file_id);
9394 params.push("commentId", self._comment_id);
9395 if let Some(value) = self._include_deleted.as_ref() {
9396 params.push("includeDeleted", value.to_string());
9397 }
9398
9399 params.extend(self._additional_params.iter());
9400
9401 params.push("alt", "json");
9402 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}";
9403 if self._scopes.is_empty() {
9404 self._scopes
9405 .insert(Scope::MeetReadonly.as_ref().to_string());
9406 }
9407
9408 #[allow(clippy::single_element_loop)]
9409 for &(find_this, param_name) in
9410 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
9411 {
9412 url = params.uri_replacement(url, param_name, find_this, false);
9413 }
9414 {
9415 let to_remove = ["commentId", "fileId"];
9416 params.remove_params(&to_remove);
9417 }
9418
9419 let url = params.parse_with_url(&url);
9420
9421 loop {
9422 let token = match self
9423 .hub
9424 .auth
9425 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9426 .await
9427 {
9428 Ok(token) => token,
9429 Err(e) => match dlg.token(e) {
9430 Ok(token) => token,
9431 Err(e) => {
9432 dlg.finished(false);
9433 return Err(common::Error::MissingToken(e));
9434 }
9435 },
9436 };
9437 let mut req_result = {
9438 let client = &self.hub.client;
9439 dlg.pre_request();
9440 let mut req_builder = hyper::Request::builder()
9441 .method(hyper::Method::GET)
9442 .uri(url.as_str())
9443 .header(USER_AGENT, self.hub._user_agent.clone());
9444
9445 if let Some(token) = token.as_ref() {
9446 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9447 }
9448
9449 let request = req_builder
9450 .header(CONTENT_LENGTH, 0_u64)
9451 .body(common::to_body::<String>(None));
9452
9453 client.request(request.unwrap()).await
9454 };
9455
9456 match req_result {
9457 Err(err) => {
9458 if let common::Retry::After(d) = dlg.http_error(&err) {
9459 sleep(d).await;
9460 continue;
9461 }
9462 dlg.finished(false);
9463 return Err(common::Error::HttpError(err));
9464 }
9465 Ok(res) => {
9466 let (mut parts, body) = res.into_parts();
9467 let mut body = common::Body::new(body);
9468 if !parts.status.is_success() {
9469 let bytes = common::to_bytes(body).await.unwrap_or_default();
9470 let error = serde_json::from_str(&common::to_string(&bytes));
9471 let response = common::to_response(parts, bytes.into());
9472
9473 if let common::Retry::After(d) =
9474 dlg.http_failure(&response, error.as_ref().ok())
9475 {
9476 sleep(d).await;
9477 continue;
9478 }
9479
9480 dlg.finished(false);
9481
9482 return Err(match error {
9483 Ok(value) => common::Error::BadRequest(value),
9484 _ => common::Error::Failure(response),
9485 });
9486 }
9487 let response = {
9488 let bytes = common::to_bytes(body).await.unwrap_or_default();
9489 let encoded = common::to_string(&bytes);
9490 match serde_json::from_str(&encoded) {
9491 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9492 Err(error) => {
9493 dlg.response_json_decode_error(&encoded, &error);
9494 return Err(common::Error::JsonDecodeError(
9495 encoded.to_string(),
9496 error,
9497 ));
9498 }
9499 }
9500 };
9501
9502 dlg.finished(true);
9503 return Ok(response);
9504 }
9505 }
9506 }
9507 }
9508
9509 /// The ID of the file.
9510 ///
9511 /// Sets the *file id* path property to the given value.
9512 ///
9513 /// Even though the property as already been set when instantiating this call,
9514 /// we provide this method for API completeness.
9515 pub fn file_id(mut self, new_value: &str) -> CommentGetCall<'a, C> {
9516 self._file_id = new_value.to_string();
9517 self
9518 }
9519 /// The ID of the comment.
9520 ///
9521 /// Sets the *comment id* path property to the given value.
9522 ///
9523 /// Even though the property as already been set when instantiating this call,
9524 /// we provide this method for API completeness.
9525 pub fn comment_id(mut self, new_value: &str) -> CommentGetCall<'a, C> {
9526 self._comment_id = new_value.to_string();
9527 self
9528 }
9529 /// Whether to return deleted comments. Deleted comments will not include their original content.
9530 ///
9531 /// Sets the *include deleted* query property to the given value.
9532 pub fn include_deleted(mut self, new_value: bool) -> CommentGetCall<'a, C> {
9533 self._include_deleted = Some(new_value);
9534 self
9535 }
9536 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9537 /// while executing the actual API request.
9538 ///
9539 /// ````text
9540 /// It should be used to handle progress information, and to implement a certain level of resilience.
9541 /// ````
9542 ///
9543 /// Sets the *delegate* property to the given value.
9544 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentGetCall<'a, C> {
9545 self._delegate = Some(new_value);
9546 self
9547 }
9548
9549 /// Set any additional parameter of the query string used in the request.
9550 /// It should be used to set parameters which are not yet available through their own
9551 /// setters.
9552 ///
9553 /// Please note that this method must not be used to set any of the known parameters
9554 /// which have their own setter method. If done anyway, the request will fail.
9555 ///
9556 /// # Additional Parameters
9557 ///
9558 /// * *$.xgafv* (query-string) - V1 error format.
9559 /// * *access_token* (query-string) - OAuth access token.
9560 /// * *alt* (query-string) - Data format for response.
9561 /// * *callback* (query-string) - JSONP
9562 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9563 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9564 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9565 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9566 /// * *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.
9567 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9568 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9569 pub fn param<T>(mut self, name: T, value: T) -> CommentGetCall<'a, C>
9570 where
9571 T: AsRef<str>,
9572 {
9573 self._additional_params
9574 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9575 self
9576 }
9577
9578 /// Identifies the authorization scope for the method you are building.
9579 ///
9580 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9581 /// [`Scope::MeetReadonly`].
9582 ///
9583 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9584 /// tokens for more than one scope.
9585 ///
9586 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9587 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9588 /// sufficient, a read-write scope will do as well.
9589 pub fn add_scope<St>(mut self, scope: St) -> CommentGetCall<'a, C>
9590 where
9591 St: AsRef<str>,
9592 {
9593 self._scopes.insert(String::from(scope.as_ref()));
9594 self
9595 }
9596 /// Identifies the authorization scope(s) for the method you are building.
9597 ///
9598 /// See [`Self::add_scope()`] for details.
9599 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentGetCall<'a, C>
9600 where
9601 I: IntoIterator<Item = St>,
9602 St: AsRef<str>,
9603 {
9604 self._scopes
9605 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9606 self
9607 }
9608
9609 /// Removes all scopes, and no default scope will be used either.
9610 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9611 /// for details).
9612 pub fn clear_scopes(mut self) -> CommentGetCall<'a, C> {
9613 self._scopes.clear();
9614 self
9615 }
9616}
9617
9618/// Lists a file's comments. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments). Required: The `fields` parameter must be set. To return the exact fields you need, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter).
9619///
9620/// A builder for the *list* method supported by a *comment* resource.
9621/// It is not used directly, but through a [`CommentMethods`] instance.
9622///
9623/// # Example
9624///
9625/// Instantiate a resource method builder
9626///
9627/// ```test_harness,no_run
9628/// # extern crate hyper;
9629/// # extern crate hyper_rustls;
9630/// # extern crate google_drive3 as drive3;
9631/// # async fn dox() {
9632/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9633///
9634/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9635/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9636/// # .with_native_roots()
9637/// # .unwrap()
9638/// # .https_only()
9639/// # .enable_http2()
9640/// # .build();
9641///
9642/// # let executor = hyper_util::rt::TokioExecutor::new();
9643/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9644/// # secret,
9645/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9646/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9647/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9648/// # ),
9649/// # ).build().await.unwrap();
9650///
9651/// # let client = hyper_util::client::legacy::Client::builder(
9652/// # hyper_util::rt::TokioExecutor::new()
9653/// # )
9654/// # .build(
9655/// # hyper_rustls::HttpsConnectorBuilder::new()
9656/// # .with_native_roots()
9657/// # .unwrap()
9658/// # .https_or_http()
9659/// # .enable_http2()
9660/// # .build()
9661/// # );
9662/// # let mut hub = DriveHub::new(client, auth);
9663/// // You can configure optional parameters by calling the respective setters at will, and
9664/// // execute the final call using `doit()`.
9665/// // Values shown here are possibly random and not representative !
9666/// let result = hub.comments().list("fileId")
9667/// .start_modified_time("erat")
9668/// .page_token("aliquyam")
9669/// .page_size(-47)
9670/// .include_deleted(true)
9671/// .doit().await;
9672/// # }
9673/// ```
9674pub struct CommentListCall<'a, C>
9675where
9676 C: 'a,
9677{
9678 hub: &'a DriveHub<C>,
9679 _file_id: String,
9680 _start_modified_time: Option<String>,
9681 _page_token: Option<String>,
9682 _page_size: Option<i32>,
9683 _include_deleted: Option<bool>,
9684 _delegate: Option<&'a mut dyn common::Delegate>,
9685 _additional_params: HashMap<String, String>,
9686 _scopes: BTreeSet<String>,
9687}
9688
9689impl<'a, C> common::CallBuilder for CommentListCall<'a, C> {}
9690
9691impl<'a, C> CommentListCall<'a, C>
9692where
9693 C: common::Connector,
9694{
9695 /// Perform the operation you have build so far.
9696 pub async fn doit(mut self) -> common::Result<(common::Response, CommentList)> {
9697 use std::borrow::Cow;
9698 use std::io::{Read, Seek};
9699
9700 use common::{url::Params, ToParts};
9701 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9702
9703 let mut dd = common::DefaultDelegate;
9704 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9705 dlg.begin(common::MethodInfo {
9706 id: "drive.comments.list",
9707 http_method: hyper::Method::GET,
9708 });
9709
9710 for &field in [
9711 "alt",
9712 "fileId",
9713 "startModifiedTime",
9714 "pageToken",
9715 "pageSize",
9716 "includeDeleted",
9717 ]
9718 .iter()
9719 {
9720 if self._additional_params.contains_key(field) {
9721 dlg.finished(false);
9722 return Err(common::Error::FieldClash(field));
9723 }
9724 }
9725
9726 let mut params = Params::with_capacity(7 + self._additional_params.len());
9727 params.push("fileId", self._file_id);
9728 if let Some(value) = self._start_modified_time.as_ref() {
9729 params.push("startModifiedTime", value);
9730 }
9731 if let Some(value) = self._page_token.as_ref() {
9732 params.push("pageToken", value);
9733 }
9734 if let Some(value) = self._page_size.as_ref() {
9735 params.push("pageSize", value.to_string());
9736 }
9737 if let Some(value) = self._include_deleted.as_ref() {
9738 params.push("includeDeleted", value.to_string());
9739 }
9740
9741 params.extend(self._additional_params.iter());
9742
9743 params.push("alt", "json");
9744 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments";
9745 if self._scopes.is_empty() {
9746 self._scopes
9747 .insert(Scope::MeetReadonly.as_ref().to_string());
9748 }
9749
9750 #[allow(clippy::single_element_loop)]
9751 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
9752 url = params.uri_replacement(url, param_name, find_this, false);
9753 }
9754 {
9755 let to_remove = ["fileId"];
9756 params.remove_params(&to_remove);
9757 }
9758
9759 let url = params.parse_with_url(&url);
9760
9761 loop {
9762 let token = match self
9763 .hub
9764 .auth
9765 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9766 .await
9767 {
9768 Ok(token) => token,
9769 Err(e) => match dlg.token(e) {
9770 Ok(token) => token,
9771 Err(e) => {
9772 dlg.finished(false);
9773 return Err(common::Error::MissingToken(e));
9774 }
9775 },
9776 };
9777 let mut req_result = {
9778 let client = &self.hub.client;
9779 dlg.pre_request();
9780 let mut req_builder = hyper::Request::builder()
9781 .method(hyper::Method::GET)
9782 .uri(url.as_str())
9783 .header(USER_AGENT, self.hub._user_agent.clone());
9784
9785 if let Some(token) = token.as_ref() {
9786 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9787 }
9788
9789 let request = req_builder
9790 .header(CONTENT_LENGTH, 0_u64)
9791 .body(common::to_body::<String>(None));
9792
9793 client.request(request.unwrap()).await
9794 };
9795
9796 match req_result {
9797 Err(err) => {
9798 if let common::Retry::After(d) = dlg.http_error(&err) {
9799 sleep(d).await;
9800 continue;
9801 }
9802 dlg.finished(false);
9803 return Err(common::Error::HttpError(err));
9804 }
9805 Ok(res) => {
9806 let (mut parts, body) = res.into_parts();
9807 let mut body = common::Body::new(body);
9808 if !parts.status.is_success() {
9809 let bytes = common::to_bytes(body).await.unwrap_or_default();
9810 let error = serde_json::from_str(&common::to_string(&bytes));
9811 let response = common::to_response(parts, bytes.into());
9812
9813 if let common::Retry::After(d) =
9814 dlg.http_failure(&response, error.as_ref().ok())
9815 {
9816 sleep(d).await;
9817 continue;
9818 }
9819
9820 dlg.finished(false);
9821
9822 return Err(match error {
9823 Ok(value) => common::Error::BadRequest(value),
9824 _ => common::Error::Failure(response),
9825 });
9826 }
9827 let response = {
9828 let bytes = common::to_bytes(body).await.unwrap_or_default();
9829 let encoded = common::to_string(&bytes);
9830 match serde_json::from_str(&encoded) {
9831 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9832 Err(error) => {
9833 dlg.response_json_decode_error(&encoded, &error);
9834 return Err(common::Error::JsonDecodeError(
9835 encoded.to_string(),
9836 error,
9837 ));
9838 }
9839 }
9840 };
9841
9842 dlg.finished(true);
9843 return Ok(response);
9844 }
9845 }
9846 }
9847 }
9848
9849 /// The ID of the file.
9850 ///
9851 /// Sets the *file id* path property to the given value.
9852 ///
9853 /// Even though the property as already been set when instantiating this call,
9854 /// we provide this method for API completeness.
9855 pub fn file_id(mut self, new_value: &str) -> CommentListCall<'a, C> {
9856 self._file_id = new_value.to_string();
9857 self
9858 }
9859 /// The minimum value of 'modifiedTime' for the result comments (RFC 3339 date-time).
9860 ///
9861 /// Sets the *start modified time* query property to the given value.
9862 pub fn start_modified_time(mut self, new_value: &str) -> CommentListCall<'a, C> {
9863 self._start_modified_time = Some(new_value.to_string());
9864 self
9865 }
9866 /// 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.
9867 ///
9868 /// Sets the *page token* query property to the given value.
9869 pub fn page_token(mut self, new_value: &str) -> CommentListCall<'a, C> {
9870 self._page_token = Some(new_value.to_string());
9871 self
9872 }
9873 /// The maximum number of comments to return per page.
9874 ///
9875 /// Sets the *page size* query property to the given value.
9876 pub fn page_size(mut self, new_value: i32) -> CommentListCall<'a, C> {
9877 self._page_size = Some(new_value);
9878 self
9879 }
9880 /// Whether to include deleted comments. Deleted comments will not include their original content.
9881 ///
9882 /// Sets the *include deleted* query property to the given value.
9883 pub fn include_deleted(mut self, new_value: bool) -> CommentListCall<'a, C> {
9884 self._include_deleted = Some(new_value);
9885 self
9886 }
9887 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9888 /// while executing the actual API request.
9889 ///
9890 /// ````text
9891 /// It should be used to handle progress information, and to implement a certain level of resilience.
9892 /// ````
9893 ///
9894 /// Sets the *delegate* property to the given value.
9895 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentListCall<'a, C> {
9896 self._delegate = Some(new_value);
9897 self
9898 }
9899
9900 /// Set any additional parameter of the query string used in the request.
9901 /// It should be used to set parameters which are not yet available through their own
9902 /// setters.
9903 ///
9904 /// Please note that this method must not be used to set any of the known parameters
9905 /// which have their own setter method. If done anyway, the request will fail.
9906 ///
9907 /// # Additional Parameters
9908 ///
9909 /// * *$.xgafv* (query-string) - V1 error format.
9910 /// * *access_token* (query-string) - OAuth access token.
9911 /// * *alt* (query-string) - Data format for response.
9912 /// * *callback* (query-string) - JSONP
9913 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9914 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9915 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9916 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9917 /// * *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.
9918 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9919 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9920 pub fn param<T>(mut self, name: T, value: T) -> CommentListCall<'a, C>
9921 where
9922 T: AsRef<str>,
9923 {
9924 self._additional_params
9925 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9926 self
9927 }
9928
9929 /// Identifies the authorization scope for the method you are building.
9930 ///
9931 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9932 /// [`Scope::MeetReadonly`].
9933 ///
9934 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9935 /// tokens for more than one scope.
9936 ///
9937 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9938 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9939 /// sufficient, a read-write scope will do as well.
9940 pub fn add_scope<St>(mut self, scope: St) -> CommentListCall<'a, C>
9941 where
9942 St: AsRef<str>,
9943 {
9944 self._scopes.insert(String::from(scope.as_ref()));
9945 self
9946 }
9947 /// Identifies the authorization scope(s) for the method you are building.
9948 ///
9949 /// See [`Self::add_scope()`] for details.
9950 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentListCall<'a, C>
9951 where
9952 I: IntoIterator<Item = St>,
9953 St: AsRef<str>,
9954 {
9955 self._scopes
9956 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9957 self
9958 }
9959
9960 /// Removes all scopes, and no default scope will be used either.
9961 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9962 /// for details).
9963 pub fn clear_scopes(mut self) -> CommentListCall<'a, C> {
9964 self._scopes.clear();
9965 self
9966 }
9967}
9968
9969/// Updates a comment with patch semantics. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments). Required: The `fields` parameter must be set. To return the exact fields you need, see [Return specific fields](https://developers.google.com/workspace/drive/api/guides/fields-parameter).
9970///
9971/// A builder for the *update* method supported by a *comment* resource.
9972/// It is not used directly, but through a [`CommentMethods`] instance.
9973///
9974/// # Example
9975///
9976/// Instantiate a resource method builder
9977///
9978/// ```test_harness,no_run
9979/// # extern crate hyper;
9980/// # extern crate hyper_rustls;
9981/// # extern crate google_drive3 as drive3;
9982/// use drive3::api::Comment;
9983/// # async fn dox() {
9984/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9985///
9986/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9987/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9988/// # .with_native_roots()
9989/// # .unwrap()
9990/// # .https_only()
9991/// # .enable_http2()
9992/// # .build();
9993///
9994/// # let executor = hyper_util::rt::TokioExecutor::new();
9995/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9996/// # secret,
9997/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9998/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9999/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10000/// # ),
10001/// # ).build().await.unwrap();
10002///
10003/// # let client = hyper_util::client::legacy::Client::builder(
10004/// # hyper_util::rt::TokioExecutor::new()
10005/// # )
10006/// # .build(
10007/// # hyper_rustls::HttpsConnectorBuilder::new()
10008/// # .with_native_roots()
10009/// # .unwrap()
10010/// # .https_or_http()
10011/// # .enable_http2()
10012/// # .build()
10013/// # );
10014/// # let mut hub = DriveHub::new(client, auth);
10015/// // As the method needs a request, you would usually fill it with the desired information
10016/// // into the respective structure. Some of the parts shown here might not be applicable !
10017/// // Values shown here are possibly random and not representative !
10018/// let mut req = Comment::default();
10019///
10020/// // You can configure optional parameters by calling the respective setters at will, and
10021/// // execute the final call using `doit()`.
10022/// // Values shown here are possibly random and not representative !
10023/// let result = hub.comments().update(req, "fileId", "commentId")
10024/// .doit().await;
10025/// # }
10026/// ```
10027pub struct CommentUpdateCall<'a, C>
10028where
10029 C: 'a,
10030{
10031 hub: &'a DriveHub<C>,
10032 _request: Comment,
10033 _file_id: String,
10034 _comment_id: String,
10035 _delegate: Option<&'a mut dyn common::Delegate>,
10036 _additional_params: HashMap<String, String>,
10037 _scopes: BTreeSet<String>,
10038}
10039
10040impl<'a, C> common::CallBuilder for CommentUpdateCall<'a, C> {}
10041
10042impl<'a, C> CommentUpdateCall<'a, C>
10043where
10044 C: common::Connector,
10045{
10046 /// Perform the operation you have build so far.
10047 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
10048 use std::borrow::Cow;
10049 use std::io::{Read, Seek};
10050
10051 use common::{url::Params, ToParts};
10052 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10053
10054 let mut dd = common::DefaultDelegate;
10055 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10056 dlg.begin(common::MethodInfo {
10057 id: "drive.comments.update",
10058 http_method: hyper::Method::PATCH,
10059 });
10060
10061 for &field in ["alt", "fileId", "commentId"].iter() {
10062 if self._additional_params.contains_key(field) {
10063 dlg.finished(false);
10064 return Err(common::Error::FieldClash(field));
10065 }
10066 }
10067
10068 let mut params = Params::with_capacity(5 + self._additional_params.len());
10069 params.push("fileId", self._file_id);
10070 params.push("commentId", self._comment_id);
10071
10072 params.extend(self._additional_params.iter());
10073
10074 params.push("alt", "json");
10075 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}";
10076 if self._scopes.is_empty() {
10077 self._scopes.insert(Scope::Full.as_ref().to_string());
10078 }
10079
10080 #[allow(clippy::single_element_loop)]
10081 for &(find_this, param_name) in
10082 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
10083 {
10084 url = params.uri_replacement(url, param_name, find_this, false);
10085 }
10086 {
10087 let to_remove = ["commentId", "fileId"];
10088 params.remove_params(&to_remove);
10089 }
10090
10091 let url = params.parse_with_url(&url);
10092
10093 let mut json_mime_type = mime::APPLICATION_JSON;
10094 let mut request_value_reader = {
10095 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10096 common::remove_json_null_values(&mut value);
10097 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10098 serde_json::to_writer(&mut dst, &value).unwrap();
10099 dst
10100 };
10101 let request_size = request_value_reader
10102 .seek(std::io::SeekFrom::End(0))
10103 .unwrap();
10104 request_value_reader
10105 .seek(std::io::SeekFrom::Start(0))
10106 .unwrap();
10107
10108 loop {
10109 let token = match self
10110 .hub
10111 .auth
10112 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10113 .await
10114 {
10115 Ok(token) => token,
10116 Err(e) => match dlg.token(e) {
10117 Ok(token) => token,
10118 Err(e) => {
10119 dlg.finished(false);
10120 return Err(common::Error::MissingToken(e));
10121 }
10122 },
10123 };
10124 request_value_reader
10125 .seek(std::io::SeekFrom::Start(0))
10126 .unwrap();
10127 let mut req_result = {
10128 let client = &self.hub.client;
10129 dlg.pre_request();
10130 let mut req_builder = hyper::Request::builder()
10131 .method(hyper::Method::PATCH)
10132 .uri(url.as_str())
10133 .header(USER_AGENT, self.hub._user_agent.clone());
10134
10135 if let Some(token) = token.as_ref() {
10136 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10137 }
10138
10139 let request = req_builder
10140 .header(CONTENT_TYPE, json_mime_type.to_string())
10141 .header(CONTENT_LENGTH, request_size as u64)
10142 .body(common::to_body(
10143 request_value_reader.get_ref().clone().into(),
10144 ));
10145
10146 client.request(request.unwrap()).await
10147 };
10148
10149 match req_result {
10150 Err(err) => {
10151 if let common::Retry::After(d) = dlg.http_error(&err) {
10152 sleep(d).await;
10153 continue;
10154 }
10155 dlg.finished(false);
10156 return Err(common::Error::HttpError(err));
10157 }
10158 Ok(res) => {
10159 let (mut parts, body) = res.into_parts();
10160 let mut body = common::Body::new(body);
10161 if !parts.status.is_success() {
10162 let bytes = common::to_bytes(body).await.unwrap_or_default();
10163 let error = serde_json::from_str(&common::to_string(&bytes));
10164 let response = common::to_response(parts, bytes.into());
10165
10166 if let common::Retry::After(d) =
10167 dlg.http_failure(&response, error.as_ref().ok())
10168 {
10169 sleep(d).await;
10170 continue;
10171 }
10172
10173 dlg.finished(false);
10174
10175 return Err(match error {
10176 Ok(value) => common::Error::BadRequest(value),
10177 _ => common::Error::Failure(response),
10178 });
10179 }
10180 let response = {
10181 let bytes = common::to_bytes(body).await.unwrap_or_default();
10182 let encoded = common::to_string(&bytes);
10183 match serde_json::from_str(&encoded) {
10184 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10185 Err(error) => {
10186 dlg.response_json_decode_error(&encoded, &error);
10187 return Err(common::Error::JsonDecodeError(
10188 encoded.to_string(),
10189 error,
10190 ));
10191 }
10192 }
10193 };
10194
10195 dlg.finished(true);
10196 return Ok(response);
10197 }
10198 }
10199 }
10200 }
10201
10202 ///
10203 /// Sets the *request* property to the given value.
10204 ///
10205 /// Even though the property as already been set when instantiating this call,
10206 /// we provide this method for API completeness.
10207 pub fn request(mut self, new_value: Comment) -> CommentUpdateCall<'a, C> {
10208 self._request = new_value;
10209 self
10210 }
10211 /// The ID of the file.
10212 ///
10213 /// Sets the *file id* path property to the given value.
10214 ///
10215 /// Even though the property as already been set when instantiating this call,
10216 /// we provide this method for API completeness.
10217 pub fn file_id(mut self, new_value: &str) -> CommentUpdateCall<'a, C> {
10218 self._file_id = new_value.to_string();
10219 self
10220 }
10221 /// The ID of the comment.
10222 ///
10223 /// Sets the *comment id* path property to the given value.
10224 ///
10225 /// Even though the property as already been set when instantiating this call,
10226 /// we provide this method for API completeness.
10227 pub fn comment_id(mut self, new_value: &str) -> CommentUpdateCall<'a, C> {
10228 self._comment_id = new_value.to_string();
10229 self
10230 }
10231 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10232 /// while executing the actual API request.
10233 ///
10234 /// ````text
10235 /// It should be used to handle progress information, and to implement a certain level of resilience.
10236 /// ````
10237 ///
10238 /// Sets the *delegate* property to the given value.
10239 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentUpdateCall<'a, C> {
10240 self._delegate = Some(new_value);
10241 self
10242 }
10243
10244 /// Set any additional parameter of the query string used in the request.
10245 /// It should be used to set parameters which are not yet available through their own
10246 /// setters.
10247 ///
10248 /// Please note that this method must not be used to set any of the known parameters
10249 /// which have their own setter method. If done anyway, the request will fail.
10250 ///
10251 /// # Additional Parameters
10252 ///
10253 /// * *$.xgafv* (query-string) - V1 error format.
10254 /// * *access_token* (query-string) - OAuth access token.
10255 /// * *alt* (query-string) - Data format for response.
10256 /// * *callback* (query-string) - JSONP
10257 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10258 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10259 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10260 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10261 /// * *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.
10262 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10263 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10264 pub fn param<T>(mut self, name: T, value: T) -> CommentUpdateCall<'a, C>
10265 where
10266 T: AsRef<str>,
10267 {
10268 self._additional_params
10269 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10270 self
10271 }
10272
10273 /// Identifies the authorization scope for the method you are building.
10274 ///
10275 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10276 /// [`Scope::Full`].
10277 ///
10278 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10279 /// tokens for more than one scope.
10280 ///
10281 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10282 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10283 /// sufficient, a read-write scope will do as well.
10284 pub fn add_scope<St>(mut self, scope: St) -> CommentUpdateCall<'a, C>
10285 where
10286 St: AsRef<str>,
10287 {
10288 self._scopes.insert(String::from(scope.as_ref()));
10289 self
10290 }
10291 /// Identifies the authorization scope(s) for the method you are building.
10292 ///
10293 /// See [`Self::add_scope()`] for details.
10294 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentUpdateCall<'a, C>
10295 where
10296 I: IntoIterator<Item = St>,
10297 St: AsRef<str>,
10298 {
10299 self._scopes
10300 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10301 self
10302 }
10303
10304 /// Removes all scopes, and no default scope will be used either.
10305 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10306 /// for details).
10307 pub fn clear_scopes(mut self) -> CommentUpdateCall<'a, C> {
10308 self._scopes.clear();
10309 self
10310 }
10311}
10312
10313/// Creates a shared drive. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
10314///
10315/// A builder for the *create* method supported by a *drive* resource.
10316/// It is not used directly, but through a [`DriveMethods`] instance.
10317///
10318/// # Example
10319///
10320/// Instantiate a resource method builder
10321///
10322/// ```test_harness,no_run
10323/// # extern crate hyper;
10324/// # extern crate hyper_rustls;
10325/// # extern crate google_drive3 as drive3;
10326/// use drive3::api::Drive;
10327/// # async fn dox() {
10328/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10329///
10330/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10331/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10332/// # .with_native_roots()
10333/// # .unwrap()
10334/// # .https_only()
10335/// # .enable_http2()
10336/// # .build();
10337///
10338/// # let executor = hyper_util::rt::TokioExecutor::new();
10339/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10340/// # secret,
10341/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10342/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10343/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10344/// # ),
10345/// # ).build().await.unwrap();
10346///
10347/// # let client = hyper_util::client::legacy::Client::builder(
10348/// # hyper_util::rt::TokioExecutor::new()
10349/// # )
10350/// # .build(
10351/// # hyper_rustls::HttpsConnectorBuilder::new()
10352/// # .with_native_roots()
10353/// # .unwrap()
10354/// # .https_or_http()
10355/// # .enable_http2()
10356/// # .build()
10357/// # );
10358/// # let mut hub = DriveHub::new(client, auth);
10359/// // As the method needs a request, you would usually fill it with the desired information
10360/// // into the respective structure. Some of the parts shown here might not be applicable !
10361/// // Values shown here are possibly random and not representative !
10362/// let mut req = Drive::default();
10363///
10364/// // You can configure optional parameters by calling the respective setters at will, and
10365/// // execute the final call using `doit()`.
10366/// // Values shown here are possibly random and not representative !
10367/// let result = hub.drives().create(req, "requestId")
10368/// .doit().await;
10369/// # }
10370/// ```
10371pub struct DriveCreateCall<'a, C>
10372where
10373 C: 'a,
10374{
10375 hub: &'a DriveHub<C>,
10376 _request: Drive,
10377 _request_id: String,
10378 _delegate: Option<&'a mut dyn common::Delegate>,
10379 _additional_params: HashMap<String, String>,
10380 _scopes: BTreeSet<String>,
10381}
10382
10383impl<'a, C> common::CallBuilder for DriveCreateCall<'a, C> {}
10384
10385impl<'a, C> DriveCreateCall<'a, C>
10386where
10387 C: common::Connector,
10388{
10389 /// Perform the operation you have build so far.
10390 pub async fn doit(mut self) -> common::Result<(common::Response, Drive)> {
10391 use std::borrow::Cow;
10392 use std::io::{Read, Seek};
10393
10394 use common::{url::Params, ToParts};
10395 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10396
10397 let mut dd = common::DefaultDelegate;
10398 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10399 dlg.begin(common::MethodInfo {
10400 id: "drive.drives.create",
10401 http_method: hyper::Method::POST,
10402 });
10403
10404 for &field in ["alt", "requestId"].iter() {
10405 if self._additional_params.contains_key(field) {
10406 dlg.finished(false);
10407 return Err(common::Error::FieldClash(field));
10408 }
10409 }
10410
10411 let mut params = Params::with_capacity(4 + self._additional_params.len());
10412 params.push("requestId", self._request_id);
10413
10414 params.extend(self._additional_params.iter());
10415
10416 params.push("alt", "json");
10417 let mut url = self.hub._base_url.clone() + "drives";
10418 if self._scopes.is_empty() {
10419 self._scopes.insert(Scope::Full.as_ref().to_string());
10420 }
10421
10422 let url = params.parse_with_url(&url);
10423
10424 let mut json_mime_type = mime::APPLICATION_JSON;
10425 let mut request_value_reader = {
10426 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10427 common::remove_json_null_values(&mut value);
10428 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10429 serde_json::to_writer(&mut dst, &value).unwrap();
10430 dst
10431 };
10432 let request_size = request_value_reader
10433 .seek(std::io::SeekFrom::End(0))
10434 .unwrap();
10435 request_value_reader
10436 .seek(std::io::SeekFrom::Start(0))
10437 .unwrap();
10438
10439 loop {
10440 let token = match self
10441 .hub
10442 .auth
10443 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10444 .await
10445 {
10446 Ok(token) => token,
10447 Err(e) => match dlg.token(e) {
10448 Ok(token) => token,
10449 Err(e) => {
10450 dlg.finished(false);
10451 return Err(common::Error::MissingToken(e));
10452 }
10453 },
10454 };
10455 request_value_reader
10456 .seek(std::io::SeekFrom::Start(0))
10457 .unwrap();
10458 let mut req_result = {
10459 let client = &self.hub.client;
10460 dlg.pre_request();
10461 let mut req_builder = hyper::Request::builder()
10462 .method(hyper::Method::POST)
10463 .uri(url.as_str())
10464 .header(USER_AGENT, self.hub._user_agent.clone());
10465
10466 if let Some(token) = token.as_ref() {
10467 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10468 }
10469
10470 let request = req_builder
10471 .header(CONTENT_TYPE, json_mime_type.to_string())
10472 .header(CONTENT_LENGTH, request_size as u64)
10473 .body(common::to_body(
10474 request_value_reader.get_ref().clone().into(),
10475 ));
10476
10477 client.request(request.unwrap()).await
10478 };
10479
10480 match req_result {
10481 Err(err) => {
10482 if let common::Retry::After(d) = dlg.http_error(&err) {
10483 sleep(d).await;
10484 continue;
10485 }
10486 dlg.finished(false);
10487 return Err(common::Error::HttpError(err));
10488 }
10489 Ok(res) => {
10490 let (mut parts, body) = res.into_parts();
10491 let mut body = common::Body::new(body);
10492 if !parts.status.is_success() {
10493 let bytes = common::to_bytes(body).await.unwrap_or_default();
10494 let error = serde_json::from_str(&common::to_string(&bytes));
10495 let response = common::to_response(parts, bytes.into());
10496
10497 if let common::Retry::After(d) =
10498 dlg.http_failure(&response, error.as_ref().ok())
10499 {
10500 sleep(d).await;
10501 continue;
10502 }
10503
10504 dlg.finished(false);
10505
10506 return Err(match error {
10507 Ok(value) => common::Error::BadRequest(value),
10508 _ => common::Error::Failure(response),
10509 });
10510 }
10511 let response = {
10512 let bytes = common::to_bytes(body).await.unwrap_or_default();
10513 let encoded = common::to_string(&bytes);
10514 match serde_json::from_str(&encoded) {
10515 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10516 Err(error) => {
10517 dlg.response_json_decode_error(&encoded, &error);
10518 return Err(common::Error::JsonDecodeError(
10519 encoded.to_string(),
10520 error,
10521 ));
10522 }
10523 }
10524 };
10525
10526 dlg.finished(true);
10527 return Ok(response);
10528 }
10529 }
10530 }
10531 }
10532
10533 ///
10534 /// Sets the *request* property to the given value.
10535 ///
10536 /// Even though the property as already been set when instantiating this call,
10537 /// we provide this method for API completeness.
10538 pub fn request(mut self, new_value: Drive) -> DriveCreateCall<'a, C> {
10539 self._request = new_value;
10540 self
10541 }
10542 /// 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.
10543 ///
10544 /// Sets the *request id* query property to the given value.
10545 ///
10546 /// Even though the property as already been set when instantiating this call,
10547 /// we provide this method for API completeness.
10548 pub fn request_id(mut self, new_value: &str) -> DriveCreateCall<'a, C> {
10549 self._request_id = new_value.to_string();
10550 self
10551 }
10552 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10553 /// while executing the actual API request.
10554 ///
10555 /// ````text
10556 /// It should be used to handle progress information, and to implement a certain level of resilience.
10557 /// ````
10558 ///
10559 /// Sets the *delegate* property to the given value.
10560 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveCreateCall<'a, C> {
10561 self._delegate = Some(new_value);
10562 self
10563 }
10564
10565 /// Set any additional parameter of the query string used in the request.
10566 /// It should be used to set parameters which are not yet available through their own
10567 /// setters.
10568 ///
10569 /// Please note that this method must not be used to set any of the known parameters
10570 /// which have their own setter method. If done anyway, the request will fail.
10571 ///
10572 /// # Additional Parameters
10573 ///
10574 /// * *$.xgafv* (query-string) - V1 error format.
10575 /// * *access_token* (query-string) - OAuth access token.
10576 /// * *alt* (query-string) - Data format for response.
10577 /// * *callback* (query-string) - JSONP
10578 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10579 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10580 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10581 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10582 /// * *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.
10583 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10584 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10585 pub fn param<T>(mut self, name: T, value: T) -> DriveCreateCall<'a, C>
10586 where
10587 T: AsRef<str>,
10588 {
10589 self._additional_params
10590 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10591 self
10592 }
10593
10594 /// Identifies the authorization scope for the method you are building.
10595 ///
10596 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10597 /// [`Scope::Full`].
10598 ///
10599 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10600 /// tokens for more than one scope.
10601 ///
10602 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10603 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10604 /// sufficient, a read-write scope will do as well.
10605 pub fn add_scope<St>(mut self, scope: St) -> DriveCreateCall<'a, C>
10606 where
10607 St: AsRef<str>,
10608 {
10609 self._scopes.insert(String::from(scope.as_ref()));
10610 self
10611 }
10612 /// Identifies the authorization scope(s) for the method you are building.
10613 ///
10614 /// See [`Self::add_scope()`] for details.
10615 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveCreateCall<'a, C>
10616 where
10617 I: IntoIterator<Item = St>,
10618 St: AsRef<str>,
10619 {
10620 self._scopes
10621 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10622 self
10623 }
10624
10625 /// Removes all scopes, and no default scope will be used either.
10626 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10627 /// for details).
10628 pub fn clear_scopes(mut self) -> DriveCreateCall<'a, C> {
10629 self._scopes.clear();
10630 self
10631 }
10632}
10633
10634/// Permanently deletes a shared drive for which the user is an `organizer`. The shared drive cannot contain any untrashed items. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
10635///
10636/// A builder for the *delete* method supported by a *drive* resource.
10637/// It is not used directly, but through a [`DriveMethods`] instance.
10638///
10639/// # Example
10640///
10641/// Instantiate a resource method builder
10642///
10643/// ```test_harness,no_run
10644/// # extern crate hyper;
10645/// # extern crate hyper_rustls;
10646/// # extern crate google_drive3 as drive3;
10647/// # async fn dox() {
10648/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10649///
10650/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10651/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10652/// # .with_native_roots()
10653/// # .unwrap()
10654/// # .https_only()
10655/// # .enable_http2()
10656/// # .build();
10657///
10658/// # let executor = hyper_util::rt::TokioExecutor::new();
10659/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10660/// # secret,
10661/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10662/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10663/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10664/// # ),
10665/// # ).build().await.unwrap();
10666///
10667/// # let client = hyper_util::client::legacy::Client::builder(
10668/// # hyper_util::rt::TokioExecutor::new()
10669/// # )
10670/// # .build(
10671/// # hyper_rustls::HttpsConnectorBuilder::new()
10672/// # .with_native_roots()
10673/// # .unwrap()
10674/// # .https_or_http()
10675/// # .enable_http2()
10676/// # .build()
10677/// # );
10678/// # let mut hub = DriveHub::new(client, auth);
10679/// // You can configure optional parameters by calling the respective setters at will, and
10680/// // execute the final call using `doit()`.
10681/// // Values shown here are possibly random and not representative !
10682/// let result = hub.drives().delete("driveId")
10683/// .use_domain_admin_access(true)
10684/// .allow_item_deletion(false)
10685/// .doit().await;
10686/// # }
10687/// ```
10688pub struct DriveDeleteCall<'a, C>
10689where
10690 C: 'a,
10691{
10692 hub: &'a DriveHub<C>,
10693 _drive_id: String,
10694 _use_domain_admin_access: Option<bool>,
10695 _allow_item_deletion: Option<bool>,
10696 _delegate: Option<&'a mut dyn common::Delegate>,
10697 _additional_params: HashMap<String, String>,
10698 _scopes: BTreeSet<String>,
10699}
10700
10701impl<'a, C> common::CallBuilder for DriveDeleteCall<'a, C> {}
10702
10703impl<'a, C> DriveDeleteCall<'a, C>
10704where
10705 C: common::Connector,
10706{
10707 /// Perform the operation you have build so far.
10708 pub async fn doit(mut self) -> common::Result<common::Response> {
10709 use std::borrow::Cow;
10710 use std::io::{Read, Seek};
10711
10712 use common::{url::Params, ToParts};
10713 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10714
10715 let mut dd = common::DefaultDelegate;
10716 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10717 dlg.begin(common::MethodInfo {
10718 id: "drive.drives.delete",
10719 http_method: hyper::Method::DELETE,
10720 });
10721
10722 for &field in ["driveId", "useDomainAdminAccess", "allowItemDeletion"].iter() {
10723 if self._additional_params.contains_key(field) {
10724 dlg.finished(false);
10725 return Err(common::Error::FieldClash(field));
10726 }
10727 }
10728
10729 let mut params = Params::with_capacity(4 + self._additional_params.len());
10730 params.push("driveId", self._drive_id);
10731 if let Some(value) = self._use_domain_admin_access.as_ref() {
10732 params.push("useDomainAdminAccess", value.to_string());
10733 }
10734 if let Some(value) = self._allow_item_deletion.as_ref() {
10735 params.push("allowItemDeletion", value.to_string());
10736 }
10737
10738 params.extend(self._additional_params.iter());
10739
10740 let mut url = self.hub._base_url.clone() + "drives/{driveId}";
10741 if self._scopes.is_empty() {
10742 self._scopes.insert(Scope::Full.as_ref().to_string());
10743 }
10744
10745 #[allow(clippy::single_element_loop)]
10746 for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
10747 url = params.uri_replacement(url, param_name, find_this, false);
10748 }
10749 {
10750 let to_remove = ["driveId"];
10751 params.remove_params(&to_remove);
10752 }
10753
10754 let url = params.parse_with_url(&url);
10755
10756 loop {
10757 let token = match self
10758 .hub
10759 .auth
10760 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10761 .await
10762 {
10763 Ok(token) => token,
10764 Err(e) => match dlg.token(e) {
10765 Ok(token) => token,
10766 Err(e) => {
10767 dlg.finished(false);
10768 return Err(common::Error::MissingToken(e));
10769 }
10770 },
10771 };
10772 let mut req_result = {
10773 let client = &self.hub.client;
10774 dlg.pre_request();
10775 let mut req_builder = hyper::Request::builder()
10776 .method(hyper::Method::DELETE)
10777 .uri(url.as_str())
10778 .header(USER_AGENT, self.hub._user_agent.clone());
10779
10780 if let Some(token) = token.as_ref() {
10781 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10782 }
10783
10784 let request = req_builder
10785 .header(CONTENT_LENGTH, 0_u64)
10786 .body(common::to_body::<String>(None));
10787
10788 client.request(request.unwrap()).await
10789 };
10790
10791 match req_result {
10792 Err(err) => {
10793 if let common::Retry::After(d) = dlg.http_error(&err) {
10794 sleep(d).await;
10795 continue;
10796 }
10797 dlg.finished(false);
10798 return Err(common::Error::HttpError(err));
10799 }
10800 Ok(res) => {
10801 let (mut parts, body) = res.into_parts();
10802 let mut body = common::Body::new(body);
10803 if !parts.status.is_success() {
10804 let bytes = common::to_bytes(body).await.unwrap_or_default();
10805 let error = serde_json::from_str(&common::to_string(&bytes));
10806 let response = common::to_response(parts, bytes.into());
10807
10808 if let common::Retry::After(d) =
10809 dlg.http_failure(&response, error.as_ref().ok())
10810 {
10811 sleep(d).await;
10812 continue;
10813 }
10814
10815 dlg.finished(false);
10816
10817 return Err(match error {
10818 Ok(value) => common::Error::BadRequest(value),
10819 _ => common::Error::Failure(response),
10820 });
10821 }
10822 let response = common::Response::from_parts(parts, body);
10823
10824 dlg.finished(true);
10825 return Ok(response);
10826 }
10827 }
10828 }
10829 }
10830
10831 /// The ID of the shared drive.
10832 ///
10833 /// Sets the *drive id* path property to the given value.
10834 ///
10835 /// Even though the property as already been set when instantiating this call,
10836 /// we provide this method for API completeness.
10837 pub fn drive_id(mut self, new_value: &str) -> DriveDeleteCall<'a, C> {
10838 self._drive_id = new_value.to_string();
10839 self
10840 }
10841 /// 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.
10842 ///
10843 /// Sets the *use domain admin access* query property to the given value.
10844 pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveDeleteCall<'a, C> {
10845 self._use_domain_admin_access = Some(new_value);
10846 self
10847 }
10848 /// Whether any items inside the shared drive should also be deleted. This option is only supported when `useDomainAdminAccess` is also set to `true`.
10849 ///
10850 /// Sets the *allow item deletion* query property to the given value.
10851 pub fn allow_item_deletion(mut self, new_value: bool) -> DriveDeleteCall<'a, C> {
10852 self._allow_item_deletion = Some(new_value);
10853 self
10854 }
10855 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10856 /// while executing the actual API request.
10857 ///
10858 /// ````text
10859 /// It should be used to handle progress information, and to implement a certain level of resilience.
10860 /// ````
10861 ///
10862 /// Sets the *delegate* property to the given value.
10863 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveDeleteCall<'a, C> {
10864 self._delegate = Some(new_value);
10865 self
10866 }
10867
10868 /// Set any additional parameter of the query string used in the request.
10869 /// It should be used to set parameters which are not yet available through their own
10870 /// setters.
10871 ///
10872 /// Please note that this method must not be used to set any of the known parameters
10873 /// which have their own setter method. If done anyway, the request will fail.
10874 ///
10875 /// # Additional Parameters
10876 ///
10877 /// * *$.xgafv* (query-string) - V1 error format.
10878 /// * *access_token* (query-string) - OAuth access token.
10879 /// * *alt* (query-string) - Data format for response.
10880 /// * *callback* (query-string) - JSONP
10881 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10882 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10883 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10884 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10885 /// * *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.
10886 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10887 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10888 pub fn param<T>(mut self, name: T, value: T) -> DriveDeleteCall<'a, C>
10889 where
10890 T: AsRef<str>,
10891 {
10892 self._additional_params
10893 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10894 self
10895 }
10896
10897 /// Identifies the authorization scope for the method you are building.
10898 ///
10899 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10900 /// [`Scope::Full`].
10901 ///
10902 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10903 /// tokens for more than one scope.
10904 ///
10905 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10906 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10907 /// sufficient, a read-write scope will do as well.
10908 pub fn add_scope<St>(mut self, scope: St) -> DriveDeleteCall<'a, C>
10909 where
10910 St: AsRef<str>,
10911 {
10912 self._scopes.insert(String::from(scope.as_ref()));
10913 self
10914 }
10915 /// Identifies the authorization scope(s) for the method you are building.
10916 ///
10917 /// See [`Self::add_scope()`] for details.
10918 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveDeleteCall<'a, C>
10919 where
10920 I: IntoIterator<Item = St>,
10921 St: AsRef<str>,
10922 {
10923 self._scopes
10924 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10925 self
10926 }
10927
10928 /// Removes all scopes, and no default scope will be used either.
10929 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10930 /// for details).
10931 pub fn clear_scopes(mut self) -> DriveDeleteCall<'a, C> {
10932 self._scopes.clear();
10933 self
10934 }
10935}
10936
10937/// Gets a shared drive's metadata by ID. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
10938///
10939/// A builder for the *get* method supported by a *drive* resource.
10940/// It is not used directly, but through a [`DriveMethods`] instance.
10941///
10942/// # Example
10943///
10944/// Instantiate a resource method builder
10945///
10946/// ```test_harness,no_run
10947/// # extern crate hyper;
10948/// # extern crate hyper_rustls;
10949/// # extern crate google_drive3 as drive3;
10950/// # async fn dox() {
10951/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10952///
10953/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10954/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10955/// # .with_native_roots()
10956/// # .unwrap()
10957/// # .https_only()
10958/// # .enable_http2()
10959/// # .build();
10960///
10961/// # let executor = hyper_util::rt::TokioExecutor::new();
10962/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10963/// # secret,
10964/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10965/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10966/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10967/// # ),
10968/// # ).build().await.unwrap();
10969///
10970/// # let client = hyper_util::client::legacy::Client::builder(
10971/// # hyper_util::rt::TokioExecutor::new()
10972/// # )
10973/// # .build(
10974/// # hyper_rustls::HttpsConnectorBuilder::new()
10975/// # .with_native_roots()
10976/// # .unwrap()
10977/// # .https_or_http()
10978/// # .enable_http2()
10979/// # .build()
10980/// # );
10981/// # let mut hub = DriveHub::new(client, auth);
10982/// // You can configure optional parameters by calling the respective setters at will, and
10983/// // execute the final call using `doit()`.
10984/// // Values shown here are possibly random and not representative !
10985/// let result = hub.drives().get("driveId")
10986/// .use_domain_admin_access(true)
10987/// .doit().await;
10988/// # }
10989/// ```
10990pub struct DriveGetCall<'a, C>
10991where
10992 C: 'a,
10993{
10994 hub: &'a DriveHub<C>,
10995 _drive_id: String,
10996 _use_domain_admin_access: Option<bool>,
10997 _delegate: Option<&'a mut dyn common::Delegate>,
10998 _additional_params: HashMap<String, String>,
10999 _scopes: BTreeSet<String>,
11000}
11001
11002impl<'a, C> common::CallBuilder for DriveGetCall<'a, C> {}
11003
11004impl<'a, C> DriveGetCall<'a, C>
11005where
11006 C: common::Connector,
11007{
11008 /// Perform the operation you have build so far.
11009 pub async fn doit(mut self) -> common::Result<(common::Response, Drive)> {
11010 use std::borrow::Cow;
11011 use std::io::{Read, Seek};
11012
11013 use common::{url::Params, ToParts};
11014 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11015
11016 let mut dd = common::DefaultDelegate;
11017 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11018 dlg.begin(common::MethodInfo {
11019 id: "drive.drives.get",
11020 http_method: hyper::Method::GET,
11021 });
11022
11023 for &field in ["alt", "driveId", "useDomainAdminAccess"].iter() {
11024 if self._additional_params.contains_key(field) {
11025 dlg.finished(false);
11026 return Err(common::Error::FieldClash(field));
11027 }
11028 }
11029
11030 let mut params = Params::with_capacity(4 + self._additional_params.len());
11031 params.push("driveId", self._drive_id);
11032 if let Some(value) = self._use_domain_admin_access.as_ref() {
11033 params.push("useDomainAdminAccess", value.to_string());
11034 }
11035
11036 params.extend(self._additional_params.iter());
11037
11038 params.push("alt", "json");
11039 let mut url = self.hub._base_url.clone() + "drives/{driveId}";
11040 if self._scopes.is_empty() {
11041 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11042 }
11043
11044 #[allow(clippy::single_element_loop)]
11045 for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
11046 url = params.uri_replacement(url, param_name, find_this, false);
11047 }
11048 {
11049 let to_remove = ["driveId"];
11050 params.remove_params(&to_remove);
11051 }
11052
11053 let url = params.parse_with_url(&url);
11054
11055 loop {
11056 let token = match self
11057 .hub
11058 .auth
11059 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11060 .await
11061 {
11062 Ok(token) => token,
11063 Err(e) => match dlg.token(e) {
11064 Ok(token) => token,
11065 Err(e) => {
11066 dlg.finished(false);
11067 return Err(common::Error::MissingToken(e));
11068 }
11069 },
11070 };
11071 let mut req_result = {
11072 let client = &self.hub.client;
11073 dlg.pre_request();
11074 let mut req_builder = hyper::Request::builder()
11075 .method(hyper::Method::GET)
11076 .uri(url.as_str())
11077 .header(USER_AGENT, self.hub._user_agent.clone());
11078
11079 if let Some(token) = token.as_ref() {
11080 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11081 }
11082
11083 let request = req_builder
11084 .header(CONTENT_LENGTH, 0_u64)
11085 .body(common::to_body::<String>(None));
11086
11087 client.request(request.unwrap()).await
11088 };
11089
11090 match req_result {
11091 Err(err) => {
11092 if let common::Retry::After(d) = dlg.http_error(&err) {
11093 sleep(d).await;
11094 continue;
11095 }
11096 dlg.finished(false);
11097 return Err(common::Error::HttpError(err));
11098 }
11099 Ok(res) => {
11100 let (mut parts, body) = res.into_parts();
11101 let mut body = common::Body::new(body);
11102 if !parts.status.is_success() {
11103 let bytes = common::to_bytes(body).await.unwrap_or_default();
11104 let error = serde_json::from_str(&common::to_string(&bytes));
11105 let response = common::to_response(parts, bytes.into());
11106
11107 if let common::Retry::After(d) =
11108 dlg.http_failure(&response, error.as_ref().ok())
11109 {
11110 sleep(d).await;
11111 continue;
11112 }
11113
11114 dlg.finished(false);
11115
11116 return Err(match error {
11117 Ok(value) => common::Error::BadRequest(value),
11118 _ => common::Error::Failure(response),
11119 });
11120 }
11121 let response = {
11122 let bytes = common::to_bytes(body).await.unwrap_or_default();
11123 let encoded = common::to_string(&bytes);
11124 match serde_json::from_str(&encoded) {
11125 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11126 Err(error) => {
11127 dlg.response_json_decode_error(&encoded, &error);
11128 return Err(common::Error::JsonDecodeError(
11129 encoded.to_string(),
11130 error,
11131 ));
11132 }
11133 }
11134 };
11135
11136 dlg.finished(true);
11137 return Ok(response);
11138 }
11139 }
11140 }
11141 }
11142
11143 /// The ID of the shared drive.
11144 ///
11145 /// Sets the *drive id* path property to the given value.
11146 ///
11147 /// Even though the property as already been set when instantiating this call,
11148 /// we provide this method for API completeness.
11149 pub fn drive_id(mut self, new_value: &str) -> DriveGetCall<'a, C> {
11150 self._drive_id = new_value.to_string();
11151 self
11152 }
11153 /// 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.
11154 ///
11155 /// Sets the *use domain admin access* query property to the given value.
11156 pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveGetCall<'a, C> {
11157 self._use_domain_admin_access = Some(new_value);
11158 self
11159 }
11160 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11161 /// while executing the actual API request.
11162 ///
11163 /// ````text
11164 /// It should be used to handle progress information, and to implement a certain level of resilience.
11165 /// ````
11166 ///
11167 /// Sets the *delegate* property to the given value.
11168 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveGetCall<'a, C> {
11169 self._delegate = Some(new_value);
11170 self
11171 }
11172
11173 /// Set any additional parameter of the query string used in the request.
11174 /// It should be used to set parameters which are not yet available through their own
11175 /// setters.
11176 ///
11177 /// Please note that this method must not be used to set any of the known parameters
11178 /// which have their own setter method. If done anyway, the request will fail.
11179 ///
11180 /// # Additional Parameters
11181 ///
11182 /// * *$.xgafv* (query-string) - V1 error format.
11183 /// * *access_token* (query-string) - OAuth access token.
11184 /// * *alt* (query-string) - Data format for response.
11185 /// * *callback* (query-string) - JSONP
11186 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11187 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11188 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11189 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11190 /// * *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.
11191 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11192 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11193 pub fn param<T>(mut self, name: T, value: T) -> DriveGetCall<'a, C>
11194 where
11195 T: AsRef<str>,
11196 {
11197 self._additional_params
11198 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11199 self
11200 }
11201
11202 /// Identifies the authorization scope for the method you are building.
11203 ///
11204 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11205 /// [`Scope::Readonly`].
11206 ///
11207 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11208 /// tokens for more than one scope.
11209 ///
11210 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11211 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11212 /// sufficient, a read-write scope will do as well.
11213 pub fn add_scope<St>(mut self, scope: St) -> DriveGetCall<'a, C>
11214 where
11215 St: AsRef<str>,
11216 {
11217 self._scopes.insert(String::from(scope.as_ref()));
11218 self
11219 }
11220 /// Identifies the authorization scope(s) for the method you are building.
11221 ///
11222 /// See [`Self::add_scope()`] for details.
11223 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveGetCall<'a, C>
11224 where
11225 I: IntoIterator<Item = St>,
11226 St: AsRef<str>,
11227 {
11228 self._scopes
11229 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11230 self
11231 }
11232
11233 /// Removes all scopes, and no default scope will be used either.
11234 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11235 /// for details).
11236 pub fn clear_scopes(mut self) -> DriveGetCall<'a, C> {
11237 self._scopes.clear();
11238 self
11239 }
11240}
11241
11242/// Hides a shared drive from the default view. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
11243///
11244/// A builder for the *hide* method supported by a *drive* resource.
11245/// It is not used directly, but through a [`DriveMethods`] instance.
11246///
11247/// # Example
11248///
11249/// Instantiate a resource method builder
11250///
11251/// ```test_harness,no_run
11252/// # extern crate hyper;
11253/// # extern crate hyper_rustls;
11254/// # extern crate google_drive3 as drive3;
11255/// # async fn dox() {
11256/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11257///
11258/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11259/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11260/// # .with_native_roots()
11261/// # .unwrap()
11262/// # .https_only()
11263/// # .enable_http2()
11264/// # .build();
11265///
11266/// # let executor = hyper_util::rt::TokioExecutor::new();
11267/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11268/// # secret,
11269/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11270/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11271/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11272/// # ),
11273/// # ).build().await.unwrap();
11274///
11275/// # let client = hyper_util::client::legacy::Client::builder(
11276/// # hyper_util::rt::TokioExecutor::new()
11277/// # )
11278/// # .build(
11279/// # hyper_rustls::HttpsConnectorBuilder::new()
11280/// # .with_native_roots()
11281/// # .unwrap()
11282/// # .https_or_http()
11283/// # .enable_http2()
11284/// # .build()
11285/// # );
11286/// # let mut hub = DriveHub::new(client, auth);
11287/// // You can configure optional parameters by calling the respective setters at will, and
11288/// // execute the final call using `doit()`.
11289/// // Values shown here are possibly random and not representative !
11290/// let result = hub.drives().hide("driveId")
11291/// .doit().await;
11292/// # }
11293/// ```
11294pub struct DriveHideCall<'a, C>
11295where
11296 C: 'a,
11297{
11298 hub: &'a DriveHub<C>,
11299 _drive_id: String,
11300 _delegate: Option<&'a mut dyn common::Delegate>,
11301 _additional_params: HashMap<String, String>,
11302 _scopes: BTreeSet<String>,
11303}
11304
11305impl<'a, C> common::CallBuilder for DriveHideCall<'a, C> {}
11306
11307impl<'a, C> DriveHideCall<'a, C>
11308where
11309 C: common::Connector,
11310{
11311 /// Perform the operation you have build so far.
11312 pub async fn doit(mut self) -> common::Result<(common::Response, Drive)> {
11313 use std::borrow::Cow;
11314 use std::io::{Read, Seek};
11315
11316 use common::{url::Params, ToParts};
11317 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11318
11319 let mut dd = common::DefaultDelegate;
11320 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11321 dlg.begin(common::MethodInfo {
11322 id: "drive.drives.hide",
11323 http_method: hyper::Method::POST,
11324 });
11325
11326 for &field in ["alt", "driveId"].iter() {
11327 if self._additional_params.contains_key(field) {
11328 dlg.finished(false);
11329 return Err(common::Error::FieldClash(field));
11330 }
11331 }
11332
11333 let mut params = Params::with_capacity(3 + self._additional_params.len());
11334 params.push("driveId", self._drive_id);
11335
11336 params.extend(self._additional_params.iter());
11337
11338 params.push("alt", "json");
11339 let mut url = self.hub._base_url.clone() + "drives/{driveId}/hide";
11340 if self._scopes.is_empty() {
11341 self._scopes.insert(Scope::Full.as_ref().to_string());
11342 }
11343
11344 #[allow(clippy::single_element_loop)]
11345 for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
11346 url = params.uri_replacement(url, param_name, find_this, false);
11347 }
11348 {
11349 let to_remove = ["driveId"];
11350 params.remove_params(&to_remove);
11351 }
11352
11353 let url = params.parse_with_url(&url);
11354
11355 loop {
11356 let token = match self
11357 .hub
11358 .auth
11359 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11360 .await
11361 {
11362 Ok(token) => token,
11363 Err(e) => match dlg.token(e) {
11364 Ok(token) => token,
11365 Err(e) => {
11366 dlg.finished(false);
11367 return Err(common::Error::MissingToken(e));
11368 }
11369 },
11370 };
11371 let mut req_result = {
11372 let client = &self.hub.client;
11373 dlg.pre_request();
11374 let mut req_builder = hyper::Request::builder()
11375 .method(hyper::Method::POST)
11376 .uri(url.as_str())
11377 .header(USER_AGENT, self.hub._user_agent.clone());
11378
11379 if let Some(token) = token.as_ref() {
11380 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11381 }
11382
11383 let request = req_builder
11384 .header(CONTENT_LENGTH, 0_u64)
11385 .body(common::to_body::<String>(None));
11386
11387 client.request(request.unwrap()).await
11388 };
11389
11390 match req_result {
11391 Err(err) => {
11392 if let common::Retry::After(d) = dlg.http_error(&err) {
11393 sleep(d).await;
11394 continue;
11395 }
11396 dlg.finished(false);
11397 return Err(common::Error::HttpError(err));
11398 }
11399 Ok(res) => {
11400 let (mut parts, body) = res.into_parts();
11401 let mut body = common::Body::new(body);
11402 if !parts.status.is_success() {
11403 let bytes = common::to_bytes(body).await.unwrap_or_default();
11404 let error = serde_json::from_str(&common::to_string(&bytes));
11405 let response = common::to_response(parts, bytes.into());
11406
11407 if let common::Retry::After(d) =
11408 dlg.http_failure(&response, error.as_ref().ok())
11409 {
11410 sleep(d).await;
11411 continue;
11412 }
11413
11414 dlg.finished(false);
11415
11416 return Err(match error {
11417 Ok(value) => common::Error::BadRequest(value),
11418 _ => common::Error::Failure(response),
11419 });
11420 }
11421 let response = {
11422 let bytes = common::to_bytes(body).await.unwrap_or_default();
11423 let encoded = common::to_string(&bytes);
11424 match serde_json::from_str(&encoded) {
11425 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11426 Err(error) => {
11427 dlg.response_json_decode_error(&encoded, &error);
11428 return Err(common::Error::JsonDecodeError(
11429 encoded.to_string(),
11430 error,
11431 ));
11432 }
11433 }
11434 };
11435
11436 dlg.finished(true);
11437 return Ok(response);
11438 }
11439 }
11440 }
11441 }
11442
11443 /// The ID of the shared drive.
11444 ///
11445 /// Sets the *drive id* path property to the given value.
11446 ///
11447 /// Even though the property as already been set when instantiating this call,
11448 /// we provide this method for API completeness.
11449 pub fn drive_id(mut self, new_value: &str) -> DriveHideCall<'a, C> {
11450 self._drive_id = new_value.to_string();
11451 self
11452 }
11453 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11454 /// while executing the actual API request.
11455 ///
11456 /// ````text
11457 /// It should be used to handle progress information, and to implement a certain level of resilience.
11458 /// ````
11459 ///
11460 /// Sets the *delegate* property to the given value.
11461 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveHideCall<'a, C> {
11462 self._delegate = Some(new_value);
11463 self
11464 }
11465
11466 /// Set any additional parameter of the query string used in the request.
11467 /// It should be used to set parameters which are not yet available through their own
11468 /// setters.
11469 ///
11470 /// Please note that this method must not be used to set any of the known parameters
11471 /// which have their own setter method. If done anyway, the request will fail.
11472 ///
11473 /// # Additional Parameters
11474 ///
11475 /// * *$.xgafv* (query-string) - V1 error format.
11476 /// * *access_token* (query-string) - OAuth access token.
11477 /// * *alt* (query-string) - Data format for response.
11478 /// * *callback* (query-string) - JSONP
11479 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11480 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11481 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11482 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11483 /// * *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.
11484 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11485 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11486 pub fn param<T>(mut self, name: T, value: T) -> DriveHideCall<'a, C>
11487 where
11488 T: AsRef<str>,
11489 {
11490 self._additional_params
11491 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11492 self
11493 }
11494
11495 /// Identifies the authorization scope for the method you are building.
11496 ///
11497 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11498 /// [`Scope::Full`].
11499 ///
11500 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11501 /// tokens for more than one scope.
11502 ///
11503 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11504 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11505 /// sufficient, a read-write scope will do as well.
11506 pub fn add_scope<St>(mut self, scope: St) -> DriveHideCall<'a, C>
11507 where
11508 St: AsRef<str>,
11509 {
11510 self._scopes.insert(String::from(scope.as_ref()));
11511 self
11512 }
11513 /// Identifies the authorization scope(s) for the method you are building.
11514 ///
11515 /// See [`Self::add_scope()`] for details.
11516 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveHideCall<'a, C>
11517 where
11518 I: IntoIterator<Item = St>,
11519 St: AsRef<str>,
11520 {
11521 self._scopes
11522 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11523 self
11524 }
11525
11526 /// Removes all scopes, and no default scope will be used either.
11527 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11528 /// for details).
11529 pub fn clear_scopes(mut self) -> DriveHideCall<'a, C> {
11530 self._scopes.clear();
11531 self
11532 }
11533}
11534
11535/// 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.
11536///
11537/// A builder for the *list* method supported by a *drive* resource.
11538/// It is not used directly, but through a [`DriveMethods`] instance.
11539///
11540/// # Example
11541///
11542/// Instantiate a resource method builder
11543///
11544/// ```test_harness,no_run
11545/// # extern crate hyper;
11546/// # extern crate hyper_rustls;
11547/// # extern crate google_drive3 as drive3;
11548/// # async fn dox() {
11549/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11550///
11551/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11552/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11553/// # .with_native_roots()
11554/// # .unwrap()
11555/// # .https_only()
11556/// # .enable_http2()
11557/// # .build();
11558///
11559/// # let executor = hyper_util::rt::TokioExecutor::new();
11560/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11561/// # secret,
11562/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11563/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11564/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11565/// # ),
11566/// # ).build().await.unwrap();
11567///
11568/// # let client = hyper_util::client::legacy::Client::builder(
11569/// # hyper_util::rt::TokioExecutor::new()
11570/// # )
11571/// # .build(
11572/// # hyper_rustls::HttpsConnectorBuilder::new()
11573/// # .with_native_roots()
11574/// # .unwrap()
11575/// # .https_or_http()
11576/// # .enable_http2()
11577/// # .build()
11578/// # );
11579/// # let mut hub = DriveHub::new(client, auth);
11580/// // You can configure optional parameters by calling the respective setters at will, and
11581/// // execute the final call using `doit()`.
11582/// // Values shown here are possibly random and not representative !
11583/// let result = hub.drives().list()
11584/// .use_domain_admin_access(true)
11585/// .q("sed")
11586/// .page_token("eos")
11587/// .page_size(-56)
11588/// .doit().await;
11589/// # }
11590/// ```
11591pub struct DriveListCall<'a, C>
11592where
11593 C: 'a,
11594{
11595 hub: &'a DriveHub<C>,
11596 _use_domain_admin_access: Option<bool>,
11597 _q: Option<String>,
11598 _page_token: Option<String>,
11599 _page_size: Option<i32>,
11600 _delegate: Option<&'a mut dyn common::Delegate>,
11601 _additional_params: HashMap<String, String>,
11602 _scopes: BTreeSet<String>,
11603}
11604
11605impl<'a, C> common::CallBuilder for DriveListCall<'a, C> {}
11606
11607impl<'a, C> DriveListCall<'a, C>
11608where
11609 C: common::Connector,
11610{
11611 /// Perform the operation you have build so far.
11612 pub async fn doit(mut self) -> common::Result<(common::Response, DriveList)> {
11613 use std::borrow::Cow;
11614 use std::io::{Read, Seek};
11615
11616 use common::{url::Params, ToParts};
11617 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11618
11619 let mut dd = common::DefaultDelegate;
11620 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11621 dlg.begin(common::MethodInfo {
11622 id: "drive.drives.list",
11623 http_method: hyper::Method::GET,
11624 });
11625
11626 for &field in ["alt", "useDomainAdminAccess", "q", "pageToken", "pageSize"].iter() {
11627 if self._additional_params.contains_key(field) {
11628 dlg.finished(false);
11629 return Err(common::Error::FieldClash(field));
11630 }
11631 }
11632
11633 let mut params = Params::with_capacity(6 + self._additional_params.len());
11634 if let Some(value) = self._use_domain_admin_access.as_ref() {
11635 params.push("useDomainAdminAccess", value.to_string());
11636 }
11637 if let Some(value) = self._q.as_ref() {
11638 params.push("q", value);
11639 }
11640 if let Some(value) = self._page_token.as_ref() {
11641 params.push("pageToken", value);
11642 }
11643 if let Some(value) = self._page_size.as_ref() {
11644 params.push("pageSize", value.to_string());
11645 }
11646
11647 params.extend(self._additional_params.iter());
11648
11649 params.push("alt", "json");
11650 let mut url = self.hub._base_url.clone() + "drives";
11651 if self._scopes.is_empty() {
11652 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11653 }
11654
11655 let url = params.parse_with_url(&url);
11656
11657 loop {
11658 let token = match self
11659 .hub
11660 .auth
11661 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11662 .await
11663 {
11664 Ok(token) => token,
11665 Err(e) => match dlg.token(e) {
11666 Ok(token) => token,
11667 Err(e) => {
11668 dlg.finished(false);
11669 return Err(common::Error::MissingToken(e));
11670 }
11671 },
11672 };
11673 let mut req_result = {
11674 let client = &self.hub.client;
11675 dlg.pre_request();
11676 let mut req_builder = hyper::Request::builder()
11677 .method(hyper::Method::GET)
11678 .uri(url.as_str())
11679 .header(USER_AGENT, self.hub._user_agent.clone());
11680
11681 if let Some(token) = token.as_ref() {
11682 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11683 }
11684
11685 let request = req_builder
11686 .header(CONTENT_LENGTH, 0_u64)
11687 .body(common::to_body::<String>(None));
11688
11689 client.request(request.unwrap()).await
11690 };
11691
11692 match req_result {
11693 Err(err) => {
11694 if let common::Retry::After(d) = dlg.http_error(&err) {
11695 sleep(d).await;
11696 continue;
11697 }
11698 dlg.finished(false);
11699 return Err(common::Error::HttpError(err));
11700 }
11701 Ok(res) => {
11702 let (mut parts, body) = res.into_parts();
11703 let mut body = common::Body::new(body);
11704 if !parts.status.is_success() {
11705 let bytes = common::to_bytes(body).await.unwrap_or_default();
11706 let error = serde_json::from_str(&common::to_string(&bytes));
11707 let response = common::to_response(parts, bytes.into());
11708
11709 if let common::Retry::After(d) =
11710 dlg.http_failure(&response, error.as_ref().ok())
11711 {
11712 sleep(d).await;
11713 continue;
11714 }
11715
11716 dlg.finished(false);
11717
11718 return Err(match error {
11719 Ok(value) => common::Error::BadRequest(value),
11720 _ => common::Error::Failure(response),
11721 });
11722 }
11723 let response = {
11724 let bytes = common::to_bytes(body).await.unwrap_or_default();
11725 let encoded = common::to_string(&bytes);
11726 match serde_json::from_str(&encoded) {
11727 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11728 Err(error) => {
11729 dlg.response_json_decode_error(&encoded, &error);
11730 return Err(common::Error::JsonDecodeError(
11731 encoded.to_string(),
11732 error,
11733 ));
11734 }
11735 }
11736 };
11737
11738 dlg.finished(true);
11739 return Ok(response);
11740 }
11741 }
11742 }
11743 }
11744
11745 /// 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.
11746 ///
11747 /// Sets the *use domain admin access* query property to the given value.
11748 pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveListCall<'a, C> {
11749 self._use_domain_admin_access = Some(new_value);
11750 self
11751 }
11752 /// Query string for searching shared drives.
11753 ///
11754 /// Sets the *q* query property to the given value.
11755 pub fn q(mut self, new_value: &str) -> DriveListCall<'a, C> {
11756 self._q = Some(new_value.to_string());
11757 self
11758 }
11759 /// Page token for shared drives.
11760 ///
11761 /// Sets the *page token* query property to the given value.
11762 pub fn page_token(mut self, new_value: &str) -> DriveListCall<'a, C> {
11763 self._page_token = Some(new_value.to_string());
11764 self
11765 }
11766 /// Maximum number of shared drives to return per page.
11767 ///
11768 /// Sets the *page size* query property to the given value.
11769 pub fn page_size(mut self, new_value: i32) -> DriveListCall<'a, C> {
11770 self._page_size = Some(new_value);
11771 self
11772 }
11773 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11774 /// while executing the actual API request.
11775 ///
11776 /// ````text
11777 /// It should be used to handle progress information, and to implement a certain level of resilience.
11778 /// ````
11779 ///
11780 /// Sets the *delegate* property to the given value.
11781 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveListCall<'a, C> {
11782 self._delegate = Some(new_value);
11783 self
11784 }
11785
11786 /// Set any additional parameter of the query string used in the request.
11787 /// It should be used to set parameters which are not yet available through their own
11788 /// setters.
11789 ///
11790 /// Please note that this method must not be used to set any of the known parameters
11791 /// which have their own setter method. If done anyway, the request will fail.
11792 ///
11793 /// # Additional Parameters
11794 ///
11795 /// * *$.xgafv* (query-string) - V1 error format.
11796 /// * *access_token* (query-string) - OAuth access token.
11797 /// * *alt* (query-string) - Data format for response.
11798 /// * *callback* (query-string) - JSONP
11799 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11800 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11801 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11802 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11803 /// * *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.
11804 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11805 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11806 pub fn param<T>(mut self, name: T, value: T) -> DriveListCall<'a, C>
11807 where
11808 T: AsRef<str>,
11809 {
11810 self._additional_params
11811 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11812 self
11813 }
11814
11815 /// Identifies the authorization scope for the method you are building.
11816 ///
11817 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11818 /// [`Scope::Readonly`].
11819 ///
11820 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11821 /// tokens for more than one scope.
11822 ///
11823 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11824 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11825 /// sufficient, a read-write scope will do as well.
11826 pub fn add_scope<St>(mut self, scope: St) -> DriveListCall<'a, C>
11827 where
11828 St: AsRef<str>,
11829 {
11830 self._scopes.insert(String::from(scope.as_ref()));
11831 self
11832 }
11833 /// Identifies the authorization scope(s) for the method you are building.
11834 ///
11835 /// See [`Self::add_scope()`] for details.
11836 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveListCall<'a, C>
11837 where
11838 I: IntoIterator<Item = St>,
11839 St: AsRef<str>,
11840 {
11841 self._scopes
11842 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11843 self
11844 }
11845
11846 /// Removes all scopes, and no default scope will be used either.
11847 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11848 /// for details).
11849 pub fn clear_scopes(mut self) -> DriveListCall<'a, C> {
11850 self._scopes.clear();
11851 self
11852 }
11853}
11854
11855/// Restores a shared drive to the default view. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
11856///
11857/// A builder for the *unhide* method supported by a *drive* resource.
11858/// It is not used directly, but through a [`DriveMethods`] instance.
11859///
11860/// # Example
11861///
11862/// Instantiate a resource method builder
11863///
11864/// ```test_harness,no_run
11865/// # extern crate hyper;
11866/// # extern crate hyper_rustls;
11867/// # extern crate google_drive3 as drive3;
11868/// # async fn dox() {
11869/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11870///
11871/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11872/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11873/// # .with_native_roots()
11874/// # .unwrap()
11875/// # .https_only()
11876/// # .enable_http2()
11877/// # .build();
11878///
11879/// # let executor = hyper_util::rt::TokioExecutor::new();
11880/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11881/// # secret,
11882/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11883/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11884/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11885/// # ),
11886/// # ).build().await.unwrap();
11887///
11888/// # let client = hyper_util::client::legacy::Client::builder(
11889/// # hyper_util::rt::TokioExecutor::new()
11890/// # )
11891/// # .build(
11892/// # hyper_rustls::HttpsConnectorBuilder::new()
11893/// # .with_native_roots()
11894/// # .unwrap()
11895/// # .https_or_http()
11896/// # .enable_http2()
11897/// # .build()
11898/// # );
11899/// # let mut hub = DriveHub::new(client, auth);
11900/// // You can configure optional parameters by calling the respective setters at will, and
11901/// // execute the final call using `doit()`.
11902/// // Values shown here are possibly random and not representative !
11903/// let result = hub.drives().unhide("driveId")
11904/// .doit().await;
11905/// # }
11906/// ```
11907pub struct DriveUnhideCall<'a, C>
11908where
11909 C: 'a,
11910{
11911 hub: &'a DriveHub<C>,
11912 _drive_id: String,
11913 _delegate: Option<&'a mut dyn common::Delegate>,
11914 _additional_params: HashMap<String, String>,
11915 _scopes: BTreeSet<String>,
11916}
11917
11918impl<'a, C> common::CallBuilder for DriveUnhideCall<'a, C> {}
11919
11920impl<'a, C> DriveUnhideCall<'a, C>
11921where
11922 C: common::Connector,
11923{
11924 /// Perform the operation you have build so far.
11925 pub async fn doit(mut self) -> common::Result<(common::Response, Drive)> {
11926 use std::borrow::Cow;
11927 use std::io::{Read, Seek};
11928
11929 use common::{url::Params, ToParts};
11930 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11931
11932 let mut dd = common::DefaultDelegate;
11933 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11934 dlg.begin(common::MethodInfo {
11935 id: "drive.drives.unhide",
11936 http_method: hyper::Method::POST,
11937 });
11938
11939 for &field in ["alt", "driveId"].iter() {
11940 if self._additional_params.contains_key(field) {
11941 dlg.finished(false);
11942 return Err(common::Error::FieldClash(field));
11943 }
11944 }
11945
11946 let mut params = Params::with_capacity(3 + self._additional_params.len());
11947 params.push("driveId", self._drive_id);
11948
11949 params.extend(self._additional_params.iter());
11950
11951 params.push("alt", "json");
11952 let mut url = self.hub._base_url.clone() + "drives/{driveId}/unhide";
11953 if self._scopes.is_empty() {
11954 self._scopes.insert(Scope::Full.as_ref().to_string());
11955 }
11956
11957 #[allow(clippy::single_element_loop)]
11958 for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
11959 url = params.uri_replacement(url, param_name, find_this, false);
11960 }
11961 {
11962 let to_remove = ["driveId"];
11963 params.remove_params(&to_remove);
11964 }
11965
11966 let url = params.parse_with_url(&url);
11967
11968 loop {
11969 let token = match self
11970 .hub
11971 .auth
11972 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11973 .await
11974 {
11975 Ok(token) => token,
11976 Err(e) => match dlg.token(e) {
11977 Ok(token) => token,
11978 Err(e) => {
11979 dlg.finished(false);
11980 return Err(common::Error::MissingToken(e));
11981 }
11982 },
11983 };
11984 let mut req_result = {
11985 let client = &self.hub.client;
11986 dlg.pre_request();
11987 let mut req_builder = hyper::Request::builder()
11988 .method(hyper::Method::POST)
11989 .uri(url.as_str())
11990 .header(USER_AGENT, self.hub._user_agent.clone());
11991
11992 if let Some(token) = token.as_ref() {
11993 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11994 }
11995
11996 let request = req_builder
11997 .header(CONTENT_LENGTH, 0_u64)
11998 .body(common::to_body::<String>(None));
11999
12000 client.request(request.unwrap()).await
12001 };
12002
12003 match req_result {
12004 Err(err) => {
12005 if let common::Retry::After(d) = dlg.http_error(&err) {
12006 sleep(d).await;
12007 continue;
12008 }
12009 dlg.finished(false);
12010 return Err(common::Error::HttpError(err));
12011 }
12012 Ok(res) => {
12013 let (mut parts, body) = res.into_parts();
12014 let mut body = common::Body::new(body);
12015 if !parts.status.is_success() {
12016 let bytes = common::to_bytes(body).await.unwrap_or_default();
12017 let error = serde_json::from_str(&common::to_string(&bytes));
12018 let response = common::to_response(parts, bytes.into());
12019
12020 if let common::Retry::After(d) =
12021 dlg.http_failure(&response, error.as_ref().ok())
12022 {
12023 sleep(d).await;
12024 continue;
12025 }
12026
12027 dlg.finished(false);
12028
12029 return Err(match error {
12030 Ok(value) => common::Error::BadRequest(value),
12031 _ => common::Error::Failure(response),
12032 });
12033 }
12034 let response = {
12035 let bytes = common::to_bytes(body).await.unwrap_or_default();
12036 let encoded = common::to_string(&bytes);
12037 match serde_json::from_str(&encoded) {
12038 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12039 Err(error) => {
12040 dlg.response_json_decode_error(&encoded, &error);
12041 return Err(common::Error::JsonDecodeError(
12042 encoded.to_string(),
12043 error,
12044 ));
12045 }
12046 }
12047 };
12048
12049 dlg.finished(true);
12050 return Ok(response);
12051 }
12052 }
12053 }
12054 }
12055
12056 /// The ID of the shared drive.
12057 ///
12058 /// Sets the *drive id* path property to the given value.
12059 ///
12060 /// Even though the property as already been set when instantiating this call,
12061 /// we provide this method for API completeness.
12062 pub fn drive_id(mut self, new_value: &str) -> DriveUnhideCall<'a, C> {
12063 self._drive_id = new_value.to_string();
12064 self
12065 }
12066 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12067 /// while executing the actual API request.
12068 ///
12069 /// ````text
12070 /// It should be used to handle progress information, and to implement a certain level of resilience.
12071 /// ````
12072 ///
12073 /// Sets the *delegate* property to the given value.
12074 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveUnhideCall<'a, C> {
12075 self._delegate = Some(new_value);
12076 self
12077 }
12078
12079 /// Set any additional parameter of the query string used in the request.
12080 /// It should be used to set parameters which are not yet available through their own
12081 /// setters.
12082 ///
12083 /// Please note that this method must not be used to set any of the known parameters
12084 /// which have their own setter method. If done anyway, the request will fail.
12085 ///
12086 /// # Additional Parameters
12087 ///
12088 /// * *$.xgafv* (query-string) - V1 error format.
12089 /// * *access_token* (query-string) - OAuth access token.
12090 /// * *alt* (query-string) - Data format for response.
12091 /// * *callback* (query-string) - JSONP
12092 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12093 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12094 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12095 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12096 /// * *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.
12097 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12098 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12099 pub fn param<T>(mut self, name: T, value: T) -> DriveUnhideCall<'a, C>
12100 where
12101 T: AsRef<str>,
12102 {
12103 self._additional_params
12104 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12105 self
12106 }
12107
12108 /// Identifies the authorization scope for the method you are building.
12109 ///
12110 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12111 /// [`Scope::Full`].
12112 ///
12113 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12114 /// tokens for more than one scope.
12115 ///
12116 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12117 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12118 /// sufficient, a read-write scope will do as well.
12119 pub fn add_scope<St>(mut self, scope: St) -> DriveUnhideCall<'a, C>
12120 where
12121 St: AsRef<str>,
12122 {
12123 self._scopes.insert(String::from(scope.as_ref()));
12124 self
12125 }
12126 /// Identifies the authorization scope(s) for the method you are building.
12127 ///
12128 /// See [`Self::add_scope()`] for details.
12129 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveUnhideCall<'a, C>
12130 where
12131 I: IntoIterator<Item = St>,
12132 St: AsRef<str>,
12133 {
12134 self._scopes
12135 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12136 self
12137 }
12138
12139 /// Removes all scopes, and no default scope will be used either.
12140 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12141 /// for details).
12142 pub fn clear_scopes(mut self) -> DriveUnhideCall<'a, C> {
12143 self._scopes.clear();
12144 self
12145 }
12146}
12147
12148/// Updates the metadata for a shared drive. For more information, see [Manage shared drives](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives).
12149///
12150/// A builder for the *update* method supported by a *drive* resource.
12151/// It is not used directly, but through a [`DriveMethods`] instance.
12152///
12153/// # Example
12154///
12155/// Instantiate a resource method builder
12156///
12157/// ```test_harness,no_run
12158/// # extern crate hyper;
12159/// # extern crate hyper_rustls;
12160/// # extern crate google_drive3 as drive3;
12161/// use drive3::api::Drive;
12162/// # async fn dox() {
12163/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12164///
12165/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12166/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12167/// # .with_native_roots()
12168/// # .unwrap()
12169/// # .https_only()
12170/// # .enable_http2()
12171/// # .build();
12172///
12173/// # let executor = hyper_util::rt::TokioExecutor::new();
12174/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12175/// # secret,
12176/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12177/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12178/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12179/// # ),
12180/// # ).build().await.unwrap();
12181///
12182/// # let client = hyper_util::client::legacy::Client::builder(
12183/// # hyper_util::rt::TokioExecutor::new()
12184/// # )
12185/// # .build(
12186/// # hyper_rustls::HttpsConnectorBuilder::new()
12187/// # .with_native_roots()
12188/// # .unwrap()
12189/// # .https_or_http()
12190/// # .enable_http2()
12191/// # .build()
12192/// # );
12193/// # let mut hub = DriveHub::new(client, auth);
12194/// // As the method needs a request, you would usually fill it with the desired information
12195/// // into the respective structure. Some of the parts shown here might not be applicable !
12196/// // Values shown here are possibly random and not representative !
12197/// let mut req = Drive::default();
12198///
12199/// // You can configure optional parameters by calling the respective setters at will, and
12200/// // execute the final call using `doit()`.
12201/// // Values shown here are possibly random and not representative !
12202/// let result = hub.drives().update(req, "driveId")
12203/// .use_domain_admin_access(true)
12204/// .doit().await;
12205/// # }
12206/// ```
12207pub struct DriveUpdateCall<'a, C>
12208where
12209 C: 'a,
12210{
12211 hub: &'a DriveHub<C>,
12212 _request: Drive,
12213 _drive_id: String,
12214 _use_domain_admin_access: Option<bool>,
12215 _delegate: Option<&'a mut dyn common::Delegate>,
12216 _additional_params: HashMap<String, String>,
12217 _scopes: BTreeSet<String>,
12218}
12219
12220impl<'a, C> common::CallBuilder for DriveUpdateCall<'a, C> {}
12221
12222impl<'a, C> DriveUpdateCall<'a, C>
12223where
12224 C: common::Connector,
12225{
12226 /// Perform the operation you have build so far.
12227 pub async fn doit(mut self) -> common::Result<(common::Response, Drive)> {
12228 use std::borrow::Cow;
12229 use std::io::{Read, Seek};
12230
12231 use common::{url::Params, ToParts};
12232 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12233
12234 let mut dd = common::DefaultDelegate;
12235 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12236 dlg.begin(common::MethodInfo {
12237 id: "drive.drives.update",
12238 http_method: hyper::Method::PATCH,
12239 });
12240
12241 for &field in ["alt", "driveId", "useDomainAdminAccess"].iter() {
12242 if self._additional_params.contains_key(field) {
12243 dlg.finished(false);
12244 return Err(common::Error::FieldClash(field));
12245 }
12246 }
12247
12248 let mut params = Params::with_capacity(5 + self._additional_params.len());
12249 params.push("driveId", self._drive_id);
12250 if let Some(value) = self._use_domain_admin_access.as_ref() {
12251 params.push("useDomainAdminAccess", value.to_string());
12252 }
12253
12254 params.extend(self._additional_params.iter());
12255
12256 params.push("alt", "json");
12257 let mut url = self.hub._base_url.clone() + "drives/{driveId}";
12258 if self._scopes.is_empty() {
12259 self._scopes.insert(Scope::Full.as_ref().to_string());
12260 }
12261
12262 #[allow(clippy::single_element_loop)]
12263 for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
12264 url = params.uri_replacement(url, param_name, find_this, false);
12265 }
12266 {
12267 let to_remove = ["driveId"];
12268 params.remove_params(&to_remove);
12269 }
12270
12271 let url = params.parse_with_url(&url);
12272
12273 let mut json_mime_type = mime::APPLICATION_JSON;
12274 let mut request_value_reader = {
12275 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12276 common::remove_json_null_values(&mut value);
12277 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12278 serde_json::to_writer(&mut dst, &value).unwrap();
12279 dst
12280 };
12281 let request_size = request_value_reader
12282 .seek(std::io::SeekFrom::End(0))
12283 .unwrap();
12284 request_value_reader
12285 .seek(std::io::SeekFrom::Start(0))
12286 .unwrap();
12287
12288 loop {
12289 let token = match self
12290 .hub
12291 .auth
12292 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12293 .await
12294 {
12295 Ok(token) => token,
12296 Err(e) => match dlg.token(e) {
12297 Ok(token) => token,
12298 Err(e) => {
12299 dlg.finished(false);
12300 return Err(common::Error::MissingToken(e));
12301 }
12302 },
12303 };
12304 request_value_reader
12305 .seek(std::io::SeekFrom::Start(0))
12306 .unwrap();
12307 let mut req_result = {
12308 let client = &self.hub.client;
12309 dlg.pre_request();
12310 let mut req_builder = hyper::Request::builder()
12311 .method(hyper::Method::PATCH)
12312 .uri(url.as_str())
12313 .header(USER_AGENT, self.hub._user_agent.clone());
12314
12315 if let Some(token) = token.as_ref() {
12316 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12317 }
12318
12319 let request = req_builder
12320 .header(CONTENT_TYPE, json_mime_type.to_string())
12321 .header(CONTENT_LENGTH, request_size as u64)
12322 .body(common::to_body(
12323 request_value_reader.get_ref().clone().into(),
12324 ));
12325
12326 client.request(request.unwrap()).await
12327 };
12328
12329 match req_result {
12330 Err(err) => {
12331 if let common::Retry::After(d) = dlg.http_error(&err) {
12332 sleep(d).await;
12333 continue;
12334 }
12335 dlg.finished(false);
12336 return Err(common::Error::HttpError(err));
12337 }
12338 Ok(res) => {
12339 let (mut parts, body) = res.into_parts();
12340 let mut body = common::Body::new(body);
12341 if !parts.status.is_success() {
12342 let bytes = common::to_bytes(body).await.unwrap_or_default();
12343 let error = serde_json::from_str(&common::to_string(&bytes));
12344 let response = common::to_response(parts, bytes.into());
12345
12346 if let common::Retry::After(d) =
12347 dlg.http_failure(&response, error.as_ref().ok())
12348 {
12349 sleep(d).await;
12350 continue;
12351 }
12352
12353 dlg.finished(false);
12354
12355 return Err(match error {
12356 Ok(value) => common::Error::BadRequest(value),
12357 _ => common::Error::Failure(response),
12358 });
12359 }
12360 let response = {
12361 let bytes = common::to_bytes(body).await.unwrap_or_default();
12362 let encoded = common::to_string(&bytes);
12363 match serde_json::from_str(&encoded) {
12364 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12365 Err(error) => {
12366 dlg.response_json_decode_error(&encoded, &error);
12367 return Err(common::Error::JsonDecodeError(
12368 encoded.to_string(),
12369 error,
12370 ));
12371 }
12372 }
12373 };
12374
12375 dlg.finished(true);
12376 return Ok(response);
12377 }
12378 }
12379 }
12380 }
12381
12382 ///
12383 /// Sets the *request* property to the given value.
12384 ///
12385 /// Even though the property as already been set when instantiating this call,
12386 /// we provide this method for API completeness.
12387 pub fn request(mut self, new_value: Drive) -> DriveUpdateCall<'a, C> {
12388 self._request = new_value;
12389 self
12390 }
12391 /// The ID of the shared drive.
12392 ///
12393 /// Sets the *drive id* path property to the given value.
12394 ///
12395 /// Even though the property as already been set when instantiating this call,
12396 /// we provide this method for API completeness.
12397 pub fn drive_id(mut self, new_value: &str) -> DriveUpdateCall<'a, C> {
12398 self._drive_id = new_value.to_string();
12399 self
12400 }
12401 /// 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.
12402 ///
12403 /// Sets the *use domain admin access* query property to the given value.
12404 pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveUpdateCall<'a, C> {
12405 self._use_domain_admin_access = Some(new_value);
12406 self
12407 }
12408 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12409 /// while executing the actual API request.
12410 ///
12411 /// ````text
12412 /// It should be used to handle progress information, and to implement a certain level of resilience.
12413 /// ````
12414 ///
12415 /// Sets the *delegate* property to the given value.
12416 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DriveUpdateCall<'a, C> {
12417 self._delegate = Some(new_value);
12418 self
12419 }
12420
12421 /// Set any additional parameter of the query string used in the request.
12422 /// It should be used to set parameters which are not yet available through their own
12423 /// setters.
12424 ///
12425 /// Please note that this method must not be used to set any of the known parameters
12426 /// which have their own setter method. If done anyway, the request will fail.
12427 ///
12428 /// # Additional Parameters
12429 ///
12430 /// * *$.xgafv* (query-string) - V1 error format.
12431 /// * *access_token* (query-string) - OAuth access token.
12432 /// * *alt* (query-string) - Data format for response.
12433 /// * *callback* (query-string) - JSONP
12434 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12435 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12436 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12437 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12438 /// * *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.
12439 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12440 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12441 pub fn param<T>(mut self, name: T, value: T) -> DriveUpdateCall<'a, C>
12442 where
12443 T: AsRef<str>,
12444 {
12445 self._additional_params
12446 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12447 self
12448 }
12449
12450 /// Identifies the authorization scope for the method you are building.
12451 ///
12452 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12453 /// [`Scope::Full`].
12454 ///
12455 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12456 /// tokens for more than one scope.
12457 ///
12458 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12459 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12460 /// sufficient, a read-write scope will do as well.
12461 pub fn add_scope<St>(mut self, scope: St) -> DriveUpdateCall<'a, C>
12462 where
12463 St: AsRef<str>,
12464 {
12465 self._scopes.insert(String::from(scope.as_ref()));
12466 self
12467 }
12468 /// Identifies the authorization scope(s) for the method you are building.
12469 ///
12470 /// See [`Self::add_scope()`] for details.
12471 pub fn add_scopes<I, St>(mut self, scopes: I) -> DriveUpdateCall<'a, C>
12472 where
12473 I: IntoIterator<Item = St>,
12474 St: AsRef<str>,
12475 {
12476 self._scopes
12477 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12478 self
12479 }
12480
12481 /// Removes all scopes, and no default scope will be used either.
12482 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12483 /// for details).
12484 pub fn clear_scopes(mut self) -> DriveUpdateCall<'a, C> {
12485 self._scopes.clear();
12486 self
12487 }
12488}
12489
12490/// Creates a copy of a file and applies any requested updates with patch semantics. For more information, see [Create and manage files](https://developers.google.com/workspace/drive/api/guides/create-file).
12491///
12492/// A builder for the *copy* method supported by a *file* resource.
12493/// It is not used directly, but through a [`FileMethods`] instance.
12494///
12495/// # Example
12496///
12497/// Instantiate a resource method builder
12498///
12499/// ```test_harness,no_run
12500/// # extern crate hyper;
12501/// # extern crate hyper_rustls;
12502/// # extern crate google_drive3 as drive3;
12503/// use drive3::api::File;
12504/// # async fn dox() {
12505/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12506///
12507/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12508/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12509/// # .with_native_roots()
12510/// # .unwrap()
12511/// # .https_only()
12512/// # .enable_http2()
12513/// # .build();
12514///
12515/// # let executor = hyper_util::rt::TokioExecutor::new();
12516/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12517/// # secret,
12518/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12519/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12520/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12521/// # ),
12522/// # ).build().await.unwrap();
12523///
12524/// # let client = hyper_util::client::legacy::Client::builder(
12525/// # hyper_util::rt::TokioExecutor::new()
12526/// # )
12527/// # .build(
12528/// # hyper_rustls::HttpsConnectorBuilder::new()
12529/// # .with_native_roots()
12530/// # .unwrap()
12531/// # .https_or_http()
12532/// # .enable_http2()
12533/// # .build()
12534/// # );
12535/// # let mut hub = DriveHub::new(client, auth);
12536/// // As the method needs a request, you would usually fill it with the desired information
12537/// // into the respective structure. Some of the parts shown here might not be applicable !
12538/// // Values shown here are possibly random and not representative !
12539/// let mut req = File::default();
12540///
12541/// // You can configure optional parameters by calling the respective setters at will, and
12542/// // execute the final call using `doit()`.
12543/// // Values shown here are possibly random and not representative !
12544/// let result = hub.files().copy(req, "fileId")
12545/// .supports_team_drives(false)
12546/// .supports_all_drives(false)
12547/// .ocr_language("dolore")
12548/// .keep_revision_forever(true)
12549/// .include_permissions_for_view("Lorem")
12550/// .include_labels("accusam")
12551/// .ignore_default_visibility(true)
12552/// .enforce_single_parent(true)
12553/// .doit().await;
12554/// # }
12555/// ```
12556pub struct FileCopyCall<'a, C>
12557where
12558 C: 'a,
12559{
12560 hub: &'a DriveHub<C>,
12561 _request: File,
12562 _file_id: String,
12563 _supports_team_drives: Option<bool>,
12564 _supports_all_drives: Option<bool>,
12565 _ocr_language: Option<String>,
12566 _keep_revision_forever: Option<bool>,
12567 _include_permissions_for_view: Option<String>,
12568 _include_labels: Option<String>,
12569 _ignore_default_visibility: Option<bool>,
12570 _enforce_single_parent: Option<bool>,
12571 _delegate: Option<&'a mut dyn common::Delegate>,
12572 _additional_params: HashMap<String, String>,
12573 _scopes: BTreeSet<String>,
12574}
12575
12576impl<'a, C> common::CallBuilder for FileCopyCall<'a, C> {}
12577
12578impl<'a, C> FileCopyCall<'a, C>
12579where
12580 C: common::Connector,
12581{
12582 /// Perform the operation you have build so far.
12583 pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
12584 use std::borrow::Cow;
12585 use std::io::{Read, Seek};
12586
12587 use common::{url::Params, ToParts};
12588 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12589
12590 let mut dd = common::DefaultDelegate;
12591 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12592 dlg.begin(common::MethodInfo {
12593 id: "drive.files.copy",
12594 http_method: hyper::Method::POST,
12595 });
12596
12597 for &field in [
12598 "alt",
12599 "fileId",
12600 "supportsTeamDrives",
12601 "supportsAllDrives",
12602 "ocrLanguage",
12603 "keepRevisionForever",
12604 "includePermissionsForView",
12605 "includeLabels",
12606 "ignoreDefaultVisibility",
12607 "enforceSingleParent",
12608 ]
12609 .iter()
12610 {
12611 if self._additional_params.contains_key(field) {
12612 dlg.finished(false);
12613 return Err(common::Error::FieldClash(field));
12614 }
12615 }
12616
12617 let mut params = Params::with_capacity(12 + self._additional_params.len());
12618 params.push("fileId", self._file_id);
12619 if let Some(value) = self._supports_team_drives.as_ref() {
12620 params.push("supportsTeamDrives", value.to_string());
12621 }
12622 if let Some(value) = self._supports_all_drives.as_ref() {
12623 params.push("supportsAllDrives", value.to_string());
12624 }
12625 if let Some(value) = self._ocr_language.as_ref() {
12626 params.push("ocrLanguage", value);
12627 }
12628 if let Some(value) = self._keep_revision_forever.as_ref() {
12629 params.push("keepRevisionForever", value.to_string());
12630 }
12631 if let Some(value) = self._include_permissions_for_view.as_ref() {
12632 params.push("includePermissionsForView", value);
12633 }
12634 if let Some(value) = self._include_labels.as_ref() {
12635 params.push("includeLabels", value);
12636 }
12637 if let Some(value) = self._ignore_default_visibility.as_ref() {
12638 params.push("ignoreDefaultVisibility", value.to_string());
12639 }
12640 if let Some(value) = self._enforce_single_parent.as_ref() {
12641 params.push("enforceSingleParent", value.to_string());
12642 }
12643
12644 params.extend(self._additional_params.iter());
12645
12646 params.push("alt", "json");
12647 let mut url = self.hub._base_url.clone() + "files/{fileId}/copy";
12648 if self._scopes.is_empty() {
12649 self._scopes
12650 .insert(Scope::PhotoReadonly.as_ref().to_string());
12651 }
12652
12653 #[allow(clippy::single_element_loop)]
12654 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
12655 url = params.uri_replacement(url, param_name, find_this, false);
12656 }
12657 {
12658 let to_remove = ["fileId"];
12659 params.remove_params(&to_remove);
12660 }
12661
12662 let url = params.parse_with_url(&url);
12663
12664 let mut json_mime_type = mime::APPLICATION_JSON;
12665 let mut request_value_reader = {
12666 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12667 common::remove_json_null_values(&mut value);
12668 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12669 serde_json::to_writer(&mut dst, &value).unwrap();
12670 dst
12671 };
12672 let request_size = request_value_reader
12673 .seek(std::io::SeekFrom::End(0))
12674 .unwrap();
12675 request_value_reader
12676 .seek(std::io::SeekFrom::Start(0))
12677 .unwrap();
12678
12679 loop {
12680 let token = match self
12681 .hub
12682 .auth
12683 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12684 .await
12685 {
12686 Ok(token) => token,
12687 Err(e) => match dlg.token(e) {
12688 Ok(token) => token,
12689 Err(e) => {
12690 dlg.finished(false);
12691 return Err(common::Error::MissingToken(e));
12692 }
12693 },
12694 };
12695 request_value_reader
12696 .seek(std::io::SeekFrom::Start(0))
12697 .unwrap();
12698 let mut req_result = {
12699 let client = &self.hub.client;
12700 dlg.pre_request();
12701 let mut req_builder = hyper::Request::builder()
12702 .method(hyper::Method::POST)
12703 .uri(url.as_str())
12704 .header(USER_AGENT, self.hub._user_agent.clone());
12705
12706 if let Some(token) = token.as_ref() {
12707 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12708 }
12709
12710 let request = req_builder
12711 .header(CONTENT_TYPE, json_mime_type.to_string())
12712 .header(CONTENT_LENGTH, request_size as u64)
12713 .body(common::to_body(
12714 request_value_reader.get_ref().clone().into(),
12715 ));
12716
12717 client.request(request.unwrap()).await
12718 };
12719
12720 match req_result {
12721 Err(err) => {
12722 if let common::Retry::After(d) = dlg.http_error(&err) {
12723 sleep(d).await;
12724 continue;
12725 }
12726 dlg.finished(false);
12727 return Err(common::Error::HttpError(err));
12728 }
12729 Ok(res) => {
12730 let (mut parts, body) = res.into_parts();
12731 let mut body = common::Body::new(body);
12732 if !parts.status.is_success() {
12733 let bytes = common::to_bytes(body).await.unwrap_or_default();
12734 let error = serde_json::from_str(&common::to_string(&bytes));
12735 let response = common::to_response(parts, bytes.into());
12736
12737 if let common::Retry::After(d) =
12738 dlg.http_failure(&response, error.as_ref().ok())
12739 {
12740 sleep(d).await;
12741 continue;
12742 }
12743
12744 dlg.finished(false);
12745
12746 return Err(match error {
12747 Ok(value) => common::Error::BadRequest(value),
12748 _ => common::Error::Failure(response),
12749 });
12750 }
12751 let response = {
12752 let bytes = common::to_bytes(body).await.unwrap_or_default();
12753 let encoded = common::to_string(&bytes);
12754 match serde_json::from_str(&encoded) {
12755 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12756 Err(error) => {
12757 dlg.response_json_decode_error(&encoded, &error);
12758 return Err(common::Error::JsonDecodeError(
12759 encoded.to_string(),
12760 error,
12761 ));
12762 }
12763 }
12764 };
12765
12766 dlg.finished(true);
12767 return Ok(response);
12768 }
12769 }
12770 }
12771 }
12772
12773 ///
12774 /// Sets the *request* property to the given value.
12775 ///
12776 /// Even though the property as already been set when instantiating this call,
12777 /// we provide this method for API completeness.
12778 pub fn request(mut self, new_value: File) -> FileCopyCall<'a, C> {
12779 self._request = new_value;
12780 self
12781 }
12782 /// The ID of the file.
12783 ///
12784 /// Sets the *file id* path property to the given value.
12785 ///
12786 /// Even though the property as already been set when instantiating this call,
12787 /// we provide this method for API completeness.
12788 pub fn file_id(mut self, new_value: &str) -> FileCopyCall<'a, C> {
12789 self._file_id = new_value.to_string();
12790 self
12791 }
12792 /// Deprecated: Use `supportsAllDrives` instead.
12793 ///
12794 /// Sets the *supports team drives* query property to the given value.
12795 pub fn supports_team_drives(mut self, new_value: bool) -> FileCopyCall<'a, C> {
12796 self._supports_team_drives = Some(new_value);
12797 self
12798 }
12799 /// Whether the requesting application supports both My Drives and shared drives.
12800 ///
12801 /// Sets the *supports all drives* query property to the given value.
12802 pub fn supports_all_drives(mut self, new_value: bool) -> FileCopyCall<'a, C> {
12803 self._supports_all_drives = Some(new_value);
12804 self
12805 }
12806 /// A language hint for OCR processing during image import (ISO 639-1 code).
12807 ///
12808 /// Sets the *ocr language* query property to the given value.
12809 pub fn ocr_language(mut self, new_value: &str) -> FileCopyCall<'a, C> {
12810 self._ocr_language = Some(new_value.to_string());
12811 self
12812 }
12813 /// Whether to set the `keepForever` field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions.
12814 ///
12815 /// Sets the *keep revision forever* query property to the given value.
12816 pub fn keep_revision_forever(mut self, new_value: bool) -> FileCopyCall<'a, C> {
12817 self._keep_revision_forever = Some(new_value);
12818 self
12819 }
12820 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
12821 ///
12822 /// Sets the *include permissions for view* query property to the given value.
12823 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileCopyCall<'a, C> {
12824 self._include_permissions_for_view = Some(new_value.to_string());
12825 self
12826 }
12827 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
12828 ///
12829 /// Sets the *include labels* query property to the given value.
12830 pub fn include_labels(mut self, new_value: &str) -> FileCopyCall<'a, C> {
12831 self._include_labels = Some(new_value.to_string());
12832 self
12833 }
12834 /// Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.
12835 ///
12836 /// Sets the *ignore default visibility* query property to the given value.
12837 pub fn ignore_default_visibility(mut self, new_value: bool) -> FileCopyCall<'a, C> {
12838 self._ignore_default_visibility = Some(new_value);
12839 self
12840 }
12841 /// Deprecated: Copying files into multiple folders is no longer supported. Use shortcuts instead.
12842 ///
12843 /// Sets the *enforce single parent* query property to the given value.
12844 pub fn enforce_single_parent(mut self, new_value: bool) -> FileCopyCall<'a, C> {
12845 self._enforce_single_parent = Some(new_value);
12846 self
12847 }
12848 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12849 /// while executing the actual API request.
12850 ///
12851 /// ````text
12852 /// It should be used to handle progress information, and to implement a certain level of resilience.
12853 /// ````
12854 ///
12855 /// Sets the *delegate* property to the given value.
12856 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileCopyCall<'a, C> {
12857 self._delegate = Some(new_value);
12858 self
12859 }
12860
12861 /// Set any additional parameter of the query string used in the request.
12862 /// It should be used to set parameters which are not yet available through their own
12863 /// setters.
12864 ///
12865 /// Please note that this method must not be used to set any of the known parameters
12866 /// which have their own setter method. If done anyway, the request will fail.
12867 ///
12868 /// # Additional Parameters
12869 ///
12870 /// * *$.xgafv* (query-string) - V1 error format.
12871 /// * *access_token* (query-string) - OAuth access token.
12872 /// * *alt* (query-string) - Data format for response.
12873 /// * *callback* (query-string) - JSONP
12874 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12875 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12876 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12877 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12878 /// * *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.
12879 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12880 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12881 pub fn param<T>(mut self, name: T, value: T) -> FileCopyCall<'a, C>
12882 where
12883 T: AsRef<str>,
12884 {
12885 self._additional_params
12886 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12887 self
12888 }
12889
12890 /// Identifies the authorization scope for the method you are building.
12891 ///
12892 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12893 /// [`Scope::PhotoReadonly`].
12894 ///
12895 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12896 /// tokens for more than one scope.
12897 ///
12898 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12899 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12900 /// sufficient, a read-write scope will do as well.
12901 pub fn add_scope<St>(mut self, scope: St) -> FileCopyCall<'a, C>
12902 where
12903 St: AsRef<str>,
12904 {
12905 self._scopes.insert(String::from(scope.as_ref()));
12906 self
12907 }
12908 /// Identifies the authorization scope(s) for the method you are building.
12909 ///
12910 /// See [`Self::add_scope()`] for details.
12911 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileCopyCall<'a, C>
12912 where
12913 I: IntoIterator<Item = St>,
12914 St: AsRef<str>,
12915 {
12916 self._scopes
12917 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12918 self
12919 }
12920
12921 /// Removes all scopes, and no default scope will be used either.
12922 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12923 /// for details).
12924 pub fn clear_scopes(mut self) -> FileCopyCall<'a, C> {
12925 self._scopes.clear();
12926 self
12927 }
12928}
12929
12930/// Creates a file. For more information, see [Create and manage files](https://developers.google.com/workspace/drive/api/guides/create-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:* `*/*` (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). Apps creating shortcuts with the `create` method must specify the MIME type `application/vnd.google-apps.shortcut`. Apps should specify a file extension in the `name` property when inserting files with the API. For example, an operation to insert a JPEG file should specify something like `"name": "cat.jpg"` in the metadata. Subsequent `GET` requests include the read-only `fileExtension` property populated with the extension originally specified in the `name` 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 name. In cases where the extension is missing, Drive attempts to determine the extension based on the file’s MIME type.
12931///
12932/// A builder for the *create* method supported by a *file* resource.
12933/// It is not used directly, but through a [`FileMethods`] instance.
12934///
12935/// # Example
12936///
12937/// Instantiate a resource method builder
12938///
12939/// ```test_harness,no_run
12940/// # extern crate hyper;
12941/// # extern crate hyper_rustls;
12942/// # extern crate google_drive3 as drive3;
12943/// use drive3::api::File;
12944/// use std::fs;
12945/// # async fn dox() {
12946/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12947///
12948/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12949/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12950/// # .with_native_roots()
12951/// # .unwrap()
12952/// # .https_only()
12953/// # .enable_http2()
12954/// # .build();
12955///
12956/// # let executor = hyper_util::rt::TokioExecutor::new();
12957/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12958/// # secret,
12959/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12960/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12961/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12962/// # ),
12963/// # ).build().await.unwrap();
12964///
12965/// # let client = hyper_util::client::legacy::Client::builder(
12966/// # hyper_util::rt::TokioExecutor::new()
12967/// # )
12968/// # .build(
12969/// # hyper_rustls::HttpsConnectorBuilder::new()
12970/// # .with_native_roots()
12971/// # .unwrap()
12972/// # .https_or_http()
12973/// # .enable_http2()
12974/// # .build()
12975/// # );
12976/// # let mut hub = DriveHub::new(client, auth);
12977/// // As the method needs a request, you would usually fill it with the desired information
12978/// // into the respective structure. Some of the parts shown here might not be applicable !
12979/// // Values shown here are possibly random and not representative !
12980/// let mut req = File::default();
12981///
12982/// // You can configure optional parameters by calling the respective setters at will, and
12983/// // execute the final call using `upload(...)`.
12984/// // Values shown here are possibly random and not representative !
12985/// let result = hub.files().create(req)
12986/// .use_content_as_indexable_text(false)
12987/// .supports_team_drives(false)
12988/// .supports_all_drives(true)
12989/// .ocr_language("Lorem")
12990/// .keep_revision_forever(false)
12991/// .include_permissions_for_view("dolor")
12992/// .include_labels("et")
12993/// .ignore_default_visibility(true)
12994/// .enforce_single_parent(false)
12995/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
12996/// # }
12997/// ```
12998pub struct FileCreateCall<'a, C>
12999where
13000 C: 'a,
13001{
13002 hub: &'a DriveHub<C>,
13003 _request: File,
13004 _use_content_as_indexable_text: Option<bool>,
13005 _supports_team_drives: Option<bool>,
13006 _supports_all_drives: Option<bool>,
13007 _ocr_language: Option<String>,
13008 _keep_revision_forever: Option<bool>,
13009 _include_permissions_for_view: Option<String>,
13010 _include_labels: Option<String>,
13011 _ignore_default_visibility: Option<bool>,
13012 _enforce_single_parent: Option<bool>,
13013 _delegate: Option<&'a mut dyn common::Delegate>,
13014 _additional_params: HashMap<String, String>,
13015 _scopes: BTreeSet<String>,
13016}
13017
13018impl<'a, C> common::CallBuilder for FileCreateCall<'a, C> {}
13019
13020impl<'a, C> FileCreateCall<'a, C>
13021where
13022 C: common::Connector,
13023{
13024 /// Perform the operation you have build so far.
13025 async fn doit<RS>(
13026 mut self,
13027 mut reader: RS,
13028 reader_mime_type: mime::Mime,
13029 protocol: common::UploadProtocol,
13030 ) -> common::Result<(common::Response, File)>
13031 where
13032 RS: common::ReadSeek,
13033 {
13034 use std::borrow::Cow;
13035 use std::io::{Read, Seek};
13036
13037 use common::{url::Params, ToParts};
13038 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13039
13040 let mut dd = common::DefaultDelegate;
13041 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13042 dlg.begin(common::MethodInfo {
13043 id: "drive.files.create",
13044 http_method: hyper::Method::POST,
13045 });
13046
13047 for &field in [
13048 "alt",
13049 "useContentAsIndexableText",
13050 "supportsTeamDrives",
13051 "supportsAllDrives",
13052 "ocrLanguage",
13053 "keepRevisionForever",
13054 "includePermissionsForView",
13055 "includeLabels",
13056 "ignoreDefaultVisibility",
13057 "enforceSingleParent",
13058 ]
13059 .iter()
13060 {
13061 if self._additional_params.contains_key(field) {
13062 dlg.finished(false);
13063 return Err(common::Error::FieldClash(field));
13064 }
13065 }
13066
13067 let mut params = Params::with_capacity(12 + self._additional_params.len());
13068 if let Some(value) = self._use_content_as_indexable_text.as_ref() {
13069 params.push("useContentAsIndexableText", value.to_string());
13070 }
13071 if let Some(value) = self._supports_team_drives.as_ref() {
13072 params.push("supportsTeamDrives", value.to_string());
13073 }
13074 if let Some(value) = self._supports_all_drives.as_ref() {
13075 params.push("supportsAllDrives", value.to_string());
13076 }
13077 if let Some(value) = self._ocr_language.as_ref() {
13078 params.push("ocrLanguage", value);
13079 }
13080 if let Some(value) = self._keep_revision_forever.as_ref() {
13081 params.push("keepRevisionForever", value.to_string());
13082 }
13083 if let Some(value) = self._include_permissions_for_view.as_ref() {
13084 params.push("includePermissionsForView", value);
13085 }
13086 if let Some(value) = self._include_labels.as_ref() {
13087 params.push("includeLabels", value);
13088 }
13089 if let Some(value) = self._ignore_default_visibility.as_ref() {
13090 params.push("ignoreDefaultVisibility", value.to_string());
13091 }
13092 if let Some(value) = self._enforce_single_parent.as_ref() {
13093 params.push("enforceSingleParent", value.to_string());
13094 }
13095
13096 params.extend(self._additional_params.iter());
13097
13098 params.push("alt", "json");
13099 let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
13100 (
13101 self.hub._root_url.clone() + "resumable/upload/drive/v3/files",
13102 "resumable",
13103 )
13104 } else if protocol == common::UploadProtocol::Simple {
13105 (
13106 self.hub._root_url.clone() + "upload/drive/v3/files",
13107 "multipart",
13108 )
13109 } else {
13110 unreachable!()
13111 };
13112 params.push("uploadType", upload_type);
13113 if self._scopes.is_empty() {
13114 self._scopes.insert(Scope::Full.as_ref().to_string());
13115 }
13116
13117 let url = params.parse_with_url(&url);
13118
13119 let mut json_mime_type = mime::APPLICATION_JSON;
13120 let mut request_value_reader = {
13121 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13122 common::remove_json_null_values(&mut value);
13123 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13124 serde_json::to_writer(&mut dst, &value).unwrap();
13125 dst
13126 };
13127 let request_size = request_value_reader
13128 .seek(std::io::SeekFrom::End(0))
13129 .unwrap();
13130 request_value_reader
13131 .seek(std::io::SeekFrom::Start(0))
13132 .unwrap();
13133
13134 let mut upload_url_from_server;
13135
13136 loop {
13137 let token = match self
13138 .hub
13139 .auth
13140 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13141 .await
13142 {
13143 Ok(token) => token,
13144 Err(e) => match dlg.token(e) {
13145 Ok(token) => token,
13146 Err(e) => {
13147 dlg.finished(false);
13148 return Err(common::Error::MissingToken(e));
13149 }
13150 },
13151 };
13152 request_value_reader
13153 .seek(std::io::SeekFrom::Start(0))
13154 .unwrap();
13155 let mut req_result = {
13156 let mut mp_reader: common::MultiPartReader = Default::default();
13157 let (mut body_reader, content_type) = match protocol {
13158 common::UploadProtocol::Simple => {
13159 mp_reader.reserve_exact(2);
13160 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
13161 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
13162 if size > 5497558138880 {
13163 return Err(common::Error::UploadSizeLimitExceeded(size, 5497558138880));
13164 }
13165 mp_reader
13166 .add_part(
13167 &mut request_value_reader,
13168 request_size,
13169 json_mime_type.clone(),
13170 )
13171 .add_part(&mut reader, size, reader_mime_type.clone());
13172 (
13173 &mut mp_reader as &mut (dyn std::io::Read + Send),
13174 common::MultiPartReader::mime_type(),
13175 )
13176 }
13177 _ => (
13178 &mut request_value_reader as &mut (dyn std::io::Read + Send),
13179 json_mime_type.clone(),
13180 ),
13181 };
13182 let client = &self.hub.client;
13183 dlg.pre_request();
13184 let mut req_builder = hyper::Request::builder()
13185 .method(hyper::Method::POST)
13186 .uri(url.as_str())
13187 .header(USER_AGENT, self.hub._user_agent.clone());
13188
13189 if let Some(token) = token.as_ref() {
13190 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13191 }
13192
13193 upload_url_from_server = true;
13194 if protocol == common::UploadProtocol::Resumable {
13195 req_builder = req_builder
13196 .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
13197 }
13198
13199 let mut body_reader_bytes = vec![];
13200 body_reader.read_to_end(&mut body_reader_bytes).unwrap();
13201 let request = req_builder
13202 .header(CONTENT_TYPE, content_type.to_string())
13203 .body(common::to_body(body_reader_bytes.into()));
13204
13205 client.request(request.unwrap()).await
13206 };
13207
13208 match req_result {
13209 Err(err) => {
13210 if let common::Retry::After(d) = dlg.http_error(&err) {
13211 sleep(d).await;
13212 continue;
13213 }
13214 dlg.finished(false);
13215 return Err(common::Error::HttpError(err));
13216 }
13217 Ok(res) => {
13218 let (mut parts, body) = res.into_parts();
13219 let mut body = common::Body::new(body);
13220 if !parts.status.is_success() {
13221 let bytes = common::to_bytes(body).await.unwrap_or_default();
13222 let error = serde_json::from_str(&common::to_string(&bytes));
13223 let response = common::to_response(parts, bytes.into());
13224
13225 if let common::Retry::After(d) =
13226 dlg.http_failure(&response, error.as_ref().ok())
13227 {
13228 sleep(d).await;
13229 continue;
13230 }
13231
13232 dlg.finished(false);
13233
13234 return Err(match error {
13235 Ok(value) => common::Error::BadRequest(value),
13236 _ => common::Error::Failure(response),
13237 });
13238 }
13239 if protocol == common::UploadProtocol::Resumable {
13240 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
13241 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
13242 if size > 5497558138880 {
13243 return Err(common::Error::UploadSizeLimitExceeded(size, 5497558138880));
13244 }
13245 let upload_result = {
13246 let url_str = &parts
13247 .headers
13248 .get("Location")
13249 .expect("LOCATION header is part of protocol")
13250 .to_str()
13251 .unwrap();
13252 if upload_url_from_server {
13253 dlg.store_upload_url(Some(url_str));
13254 }
13255
13256 common::ResumableUploadHelper {
13257 client: &self.hub.client,
13258 delegate: dlg,
13259 start_at: if upload_url_from_server {
13260 Some(0)
13261 } else {
13262 None
13263 },
13264 auth: &self.hub.auth,
13265 user_agent: &self.hub._user_agent,
13266 // TODO: Check this assumption
13267 auth_header: format!(
13268 "Bearer {}",
13269 token
13270 .ok_or_else(|| common::Error::MissingToken(
13271 "resumable upload requires token".into()
13272 ))?
13273 .as_str()
13274 ),
13275 url: url_str,
13276 reader: &mut reader,
13277 media_type: reader_mime_type.clone(),
13278 content_length: size,
13279 }
13280 .upload()
13281 .await
13282 };
13283 match upload_result {
13284 None => {
13285 dlg.finished(false);
13286 return Err(common::Error::Cancelled);
13287 }
13288 Some(Err(err)) => {
13289 dlg.finished(false);
13290 return Err(common::Error::HttpError(err));
13291 }
13292 Some(Ok(response)) => {
13293 (parts, body) = response.into_parts();
13294 if !parts.status.is_success() {
13295 dlg.store_upload_url(None);
13296 dlg.finished(false);
13297 return Err(common::Error::Failure(
13298 common::Response::from_parts(parts, body),
13299 ));
13300 }
13301 }
13302 }
13303 }
13304 let response = {
13305 let bytes = common::to_bytes(body).await.unwrap_or_default();
13306 let encoded = common::to_string(&bytes);
13307 match serde_json::from_str(&encoded) {
13308 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13309 Err(error) => {
13310 dlg.response_json_decode_error(&encoded, &error);
13311 return Err(common::Error::JsonDecodeError(
13312 encoded.to_string(),
13313 error,
13314 ));
13315 }
13316 }
13317 };
13318
13319 dlg.finished(true);
13320 return Ok(response);
13321 }
13322 }
13323 }
13324 }
13325
13326 /// Upload media in a resumable fashion.
13327 /// Even if the upload fails or is interrupted, it can be resumed for a
13328 /// certain amount of time as the server maintains state temporarily.
13329 ///
13330 /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
13331 /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
13332 /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
13333 /// `cancel_chunk_upload(...)`.
13334 ///
13335 /// * *multipart*: yes
13336 /// * *max size*: 5497558138880
13337 /// * *valid mime types*: '*/*'
13338 pub async fn upload_resumable<RS>(
13339 self,
13340 resumeable_stream: RS,
13341 mime_type: mime::Mime,
13342 ) -> common::Result<(common::Response, File)>
13343 where
13344 RS: common::ReadSeek,
13345 {
13346 self.doit(
13347 resumeable_stream,
13348 mime_type,
13349 common::UploadProtocol::Resumable,
13350 )
13351 .await
13352 }
13353 /// Upload media all at once.
13354 /// If the upload fails for whichever reason, all progress is lost.
13355 ///
13356 /// * *multipart*: yes
13357 /// * *max size*: 5497558138880
13358 /// * *valid mime types*: '*/*'
13359 pub async fn upload<RS>(
13360 self,
13361 stream: RS,
13362 mime_type: mime::Mime,
13363 ) -> common::Result<(common::Response, File)>
13364 where
13365 RS: common::ReadSeek,
13366 {
13367 self.doit(stream, mime_type, common::UploadProtocol::Simple)
13368 .await
13369 }
13370
13371 ///
13372 /// Sets the *request* property to the given value.
13373 ///
13374 /// Even though the property as already been set when instantiating this call,
13375 /// we provide this method for API completeness.
13376 pub fn request(mut self, new_value: File) -> FileCreateCall<'a, C> {
13377 self._request = new_value;
13378 self
13379 }
13380 /// Whether to use the uploaded content as indexable text.
13381 ///
13382 /// Sets the *use content as indexable text* query property to the given value.
13383 pub fn use_content_as_indexable_text(mut self, new_value: bool) -> FileCreateCall<'a, C> {
13384 self._use_content_as_indexable_text = Some(new_value);
13385 self
13386 }
13387 /// Deprecated: Use `supportsAllDrives` instead.
13388 ///
13389 /// Sets the *supports team drives* query property to the given value.
13390 pub fn supports_team_drives(mut self, new_value: bool) -> FileCreateCall<'a, C> {
13391 self._supports_team_drives = Some(new_value);
13392 self
13393 }
13394 /// Whether the requesting application supports both My Drives and shared drives.
13395 ///
13396 /// Sets the *supports all drives* query property to the given value.
13397 pub fn supports_all_drives(mut self, new_value: bool) -> FileCreateCall<'a, C> {
13398 self._supports_all_drives = Some(new_value);
13399 self
13400 }
13401 /// A language hint for OCR processing during image import (ISO 639-1 code).
13402 ///
13403 /// Sets the *ocr language* query property to the given value.
13404 pub fn ocr_language(mut self, new_value: &str) -> FileCreateCall<'a, C> {
13405 self._ocr_language = Some(new_value.to_string());
13406 self
13407 }
13408 /// Whether to set the `keepForever` field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions.
13409 ///
13410 /// Sets the *keep revision forever* query property to the given value.
13411 pub fn keep_revision_forever(mut self, new_value: bool) -> FileCreateCall<'a, C> {
13412 self._keep_revision_forever = Some(new_value);
13413 self
13414 }
13415 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
13416 ///
13417 /// Sets the *include permissions for view* query property to the given value.
13418 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileCreateCall<'a, C> {
13419 self._include_permissions_for_view = Some(new_value.to_string());
13420 self
13421 }
13422 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
13423 ///
13424 /// Sets the *include labels* query property to the given value.
13425 pub fn include_labels(mut self, new_value: &str) -> FileCreateCall<'a, C> {
13426 self._include_labels = Some(new_value.to_string());
13427 self
13428 }
13429 /// Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.
13430 ///
13431 /// Sets the *ignore default visibility* query property to the given value.
13432 pub fn ignore_default_visibility(mut self, new_value: bool) -> FileCreateCall<'a, C> {
13433 self._ignore_default_visibility = Some(new_value);
13434 self
13435 }
13436 /// Deprecated: Creating files in multiple folders is no longer supported.
13437 ///
13438 /// Sets the *enforce single parent* query property to the given value.
13439 pub fn enforce_single_parent(mut self, new_value: bool) -> FileCreateCall<'a, C> {
13440 self._enforce_single_parent = Some(new_value);
13441 self
13442 }
13443 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13444 /// while executing the actual API request.
13445 ///
13446 /// ````text
13447 /// It should be used to handle progress information, and to implement a certain level of resilience.
13448 /// ````
13449 ///
13450 /// Sets the *delegate* property to the given value.
13451 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileCreateCall<'a, C> {
13452 self._delegate = Some(new_value);
13453 self
13454 }
13455
13456 /// Set any additional parameter of the query string used in the request.
13457 /// It should be used to set parameters which are not yet available through their own
13458 /// setters.
13459 ///
13460 /// Please note that this method must not be used to set any of the known parameters
13461 /// which have their own setter method. If done anyway, the request will fail.
13462 ///
13463 /// # Additional Parameters
13464 ///
13465 /// * *$.xgafv* (query-string) - V1 error format.
13466 /// * *access_token* (query-string) - OAuth access token.
13467 /// * *alt* (query-string) - Data format for response.
13468 /// * *callback* (query-string) - JSONP
13469 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13470 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13471 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13472 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13473 /// * *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.
13474 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13475 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13476 pub fn param<T>(mut self, name: T, value: T) -> FileCreateCall<'a, C>
13477 where
13478 T: AsRef<str>,
13479 {
13480 self._additional_params
13481 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13482 self
13483 }
13484
13485 /// Identifies the authorization scope for the method you are building.
13486 ///
13487 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13488 /// [`Scope::Full`].
13489 ///
13490 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13491 /// tokens for more than one scope.
13492 ///
13493 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13494 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13495 /// sufficient, a read-write scope will do as well.
13496 pub fn add_scope<St>(mut self, scope: St) -> FileCreateCall<'a, C>
13497 where
13498 St: AsRef<str>,
13499 {
13500 self._scopes.insert(String::from(scope.as_ref()));
13501 self
13502 }
13503 /// Identifies the authorization scope(s) for the method you are building.
13504 ///
13505 /// See [`Self::add_scope()`] for details.
13506 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileCreateCall<'a, C>
13507 where
13508 I: IntoIterator<Item = St>,
13509 St: AsRef<str>,
13510 {
13511 self._scopes
13512 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13513 self
13514 }
13515
13516 /// Removes all scopes, and no default scope will be used either.
13517 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13518 /// for details).
13519 pub fn clear_scopes(mut self) -> FileCreateCall<'a, C> {
13520 self._scopes.clear();
13521 self
13522 }
13523}
13524
13525/// Permanently deletes a file owned by the user without moving it to the trash. For more information, see [Trash or delete files and folders](https://developers.google.com/workspace/drive/api/guides/delete). 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.
13526///
13527/// A builder for the *delete* method supported by a *file* resource.
13528/// It is not used directly, but through a [`FileMethods`] instance.
13529///
13530/// # Example
13531///
13532/// Instantiate a resource method builder
13533///
13534/// ```test_harness,no_run
13535/// # extern crate hyper;
13536/// # extern crate hyper_rustls;
13537/// # extern crate google_drive3 as drive3;
13538/// # async fn dox() {
13539/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13540///
13541/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13542/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13543/// # .with_native_roots()
13544/// # .unwrap()
13545/// # .https_only()
13546/// # .enable_http2()
13547/// # .build();
13548///
13549/// # let executor = hyper_util::rt::TokioExecutor::new();
13550/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13551/// # secret,
13552/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13553/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13554/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13555/// # ),
13556/// # ).build().await.unwrap();
13557///
13558/// # let client = hyper_util::client::legacy::Client::builder(
13559/// # hyper_util::rt::TokioExecutor::new()
13560/// # )
13561/// # .build(
13562/// # hyper_rustls::HttpsConnectorBuilder::new()
13563/// # .with_native_roots()
13564/// # .unwrap()
13565/// # .https_or_http()
13566/// # .enable_http2()
13567/// # .build()
13568/// # );
13569/// # let mut hub = DriveHub::new(client, auth);
13570/// // You can configure optional parameters by calling the respective setters at will, and
13571/// // execute the final call using `doit()`.
13572/// // Values shown here are possibly random and not representative !
13573/// let result = hub.files().delete("fileId")
13574/// .supports_team_drives(true)
13575/// .supports_all_drives(true)
13576/// .enforce_single_parent(false)
13577/// .doit().await;
13578/// # }
13579/// ```
13580pub struct FileDeleteCall<'a, C>
13581where
13582 C: 'a,
13583{
13584 hub: &'a DriveHub<C>,
13585 _file_id: String,
13586 _supports_team_drives: Option<bool>,
13587 _supports_all_drives: Option<bool>,
13588 _enforce_single_parent: Option<bool>,
13589 _delegate: Option<&'a mut dyn common::Delegate>,
13590 _additional_params: HashMap<String, String>,
13591 _scopes: BTreeSet<String>,
13592}
13593
13594impl<'a, C> common::CallBuilder for FileDeleteCall<'a, C> {}
13595
13596impl<'a, C> FileDeleteCall<'a, C>
13597where
13598 C: common::Connector,
13599{
13600 /// Perform the operation you have build so far.
13601 pub async fn doit(mut self) -> common::Result<common::Response> {
13602 use std::borrow::Cow;
13603 use std::io::{Read, Seek};
13604
13605 use common::{url::Params, ToParts};
13606 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13607
13608 let mut dd = common::DefaultDelegate;
13609 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13610 dlg.begin(common::MethodInfo {
13611 id: "drive.files.delete",
13612 http_method: hyper::Method::DELETE,
13613 });
13614
13615 for &field in [
13616 "fileId",
13617 "supportsTeamDrives",
13618 "supportsAllDrives",
13619 "enforceSingleParent",
13620 ]
13621 .iter()
13622 {
13623 if self._additional_params.contains_key(field) {
13624 dlg.finished(false);
13625 return Err(common::Error::FieldClash(field));
13626 }
13627 }
13628
13629 let mut params = Params::with_capacity(5 + self._additional_params.len());
13630 params.push("fileId", self._file_id);
13631 if let Some(value) = self._supports_team_drives.as_ref() {
13632 params.push("supportsTeamDrives", value.to_string());
13633 }
13634 if let Some(value) = self._supports_all_drives.as_ref() {
13635 params.push("supportsAllDrives", value.to_string());
13636 }
13637 if let Some(value) = self._enforce_single_parent.as_ref() {
13638 params.push("enforceSingleParent", value.to_string());
13639 }
13640
13641 params.extend(self._additional_params.iter());
13642
13643 let mut url = self.hub._base_url.clone() + "files/{fileId}";
13644 if self._scopes.is_empty() {
13645 self._scopes.insert(Scope::Full.as_ref().to_string());
13646 }
13647
13648 #[allow(clippy::single_element_loop)]
13649 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
13650 url = params.uri_replacement(url, param_name, find_this, false);
13651 }
13652 {
13653 let to_remove = ["fileId"];
13654 params.remove_params(&to_remove);
13655 }
13656
13657 let url = params.parse_with_url(&url);
13658
13659 loop {
13660 let token = match self
13661 .hub
13662 .auth
13663 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13664 .await
13665 {
13666 Ok(token) => token,
13667 Err(e) => match dlg.token(e) {
13668 Ok(token) => token,
13669 Err(e) => {
13670 dlg.finished(false);
13671 return Err(common::Error::MissingToken(e));
13672 }
13673 },
13674 };
13675 let mut req_result = {
13676 let client = &self.hub.client;
13677 dlg.pre_request();
13678 let mut req_builder = hyper::Request::builder()
13679 .method(hyper::Method::DELETE)
13680 .uri(url.as_str())
13681 .header(USER_AGENT, self.hub._user_agent.clone());
13682
13683 if let Some(token) = token.as_ref() {
13684 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13685 }
13686
13687 let request = req_builder
13688 .header(CONTENT_LENGTH, 0_u64)
13689 .body(common::to_body::<String>(None));
13690
13691 client.request(request.unwrap()).await
13692 };
13693
13694 match req_result {
13695 Err(err) => {
13696 if let common::Retry::After(d) = dlg.http_error(&err) {
13697 sleep(d).await;
13698 continue;
13699 }
13700 dlg.finished(false);
13701 return Err(common::Error::HttpError(err));
13702 }
13703 Ok(res) => {
13704 let (mut parts, body) = res.into_parts();
13705 let mut body = common::Body::new(body);
13706 if !parts.status.is_success() {
13707 let bytes = common::to_bytes(body).await.unwrap_or_default();
13708 let error = serde_json::from_str(&common::to_string(&bytes));
13709 let response = common::to_response(parts, bytes.into());
13710
13711 if let common::Retry::After(d) =
13712 dlg.http_failure(&response, error.as_ref().ok())
13713 {
13714 sleep(d).await;
13715 continue;
13716 }
13717
13718 dlg.finished(false);
13719
13720 return Err(match error {
13721 Ok(value) => common::Error::BadRequest(value),
13722 _ => common::Error::Failure(response),
13723 });
13724 }
13725 let response = common::Response::from_parts(parts, body);
13726
13727 dlg.finished(true);
13728 return Ok(response);
13729 }
13730 }
13731 }
13732 }
13733
13734 /// The ID of the file.
13735 ///
13736 /// Sets the *file id* path property to the given value.
13737 ///
13738 /// Even though the property as already been set when instantiating this call,
13739 /// we provide this method for API completeness.
13740 pub fn file_id(mut self, new_value: &str) -> FileDeleteCall<'a, C> {
13741 self._file_id = new_value.to_string();
13742 self
13743 }
13744 /// Deprecated: Use `supportsAllDrives` instead.
13745 ///
13746 /// Sets the *supports team drives* query property to the given value.
13747 pub fn supports_team_drives(mut self, new_value: bool) -> FileDeleteCall<'a, C> {
13748 self._supports_team_drives = Some(new_value);
13749 self
13750 }
13751 /// Whether the requesting application supports both My Drives and shared drives.
13752 ///
13753 /// Sets the *supports all drives* query property to the given value.
13754 pub fn supports_all_drives(mut self, new_value: bool) -> FileDeleteCall<'a, C> {
13755 self._supports_all_drives = Some(new_value);
13756 self
13757 }
13758 /// Deprecated: If an item isn't in a shared drive and its last parent is deleted but the item itself isn't, the item will be placed under its owner's root.
13759 ///
13760 /// Sets the *enforce single parent* query property to the given value.
13761 pub fn enforce_single_parent(mut self, new_value: bool) -> FileDeleteCall<'a, C> {
13762 self._enforce_single_parent = Some(new_value);
13763 self
13764 }
13765 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13766 /// while executing the actual API request.
13767 ///
13768 /// ````text
13769 /// It should be used to handle progress information, and to implement a certain level of resilience.
13770 /// ````
13771 ///
13772 /// Sets the *delegate* property to the given value.
13773 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileDeleteCall<'a, C> {
13774 self._delegate = Some(new_value);
13775 self
13776 }
13777
13778 /// Set any additional parameter of the query string used in the request.
13779 /// It should be used to set parameters which are not yet available through their own
13780 /// setters.
13781 ///
13782 /// Please note that this method must not be used to set any of the known parameters
13783 /// which have their own setter method. If done anyway, the request will fail.
13784 ///
13785 /// # Additional Parameters
13786 ///
13787 /// * *$.xgafv* (query-string) - V1 error format.
13788 /// * *access_token* (query-string) - OAuth access token.
13789 /// * *alt* (query-string) - Data format for response.
13790 /// * *callback* (query-string) - JSONP
13791 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13792 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13793 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13794 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13795 /// * *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.
13796 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13797 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13798 pub fn param<T>(mut self, name: T, value: T) -> FileDeleteCall<'a, C>
13799 where
13800 T: AsRef<str>,
13801 {
13802 self._additional_params
13803 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13804 self
13805 }
13806
13807 /// Identifies the authorization scope for the method you are building.
13808 ///
13809 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13810 /// [`Scope::Full`].
13811 ///
13812 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13813 /// tokens for more than one scope.
13814 ///
13815 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13816 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13817 /// sufficient, a read-write scope will do as well.
13818 pub fn add_scope<St>(mut self, scope: St) -> FileDeleteCall<'a, C>
13819 where
13820 St: AsRef<str>,
13821 {
13822 self._scopes.insert(String::from(scope.as_ref()));
13823 self
13824 }
13825 /// Identifies the authorization scope(s) for the method you are building.
13826 ///
13827 /// See [`Self::add_scope()`] for details.
13828 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileDeleteCall<'a, C>
13829 where
13830 I: IntoIterator<Item = St>,
13831 St: AsRef<str>,
13832 {
13833 self._scopes
13834 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13835 self
13836 }
13837
13838 /// Removes all scopes, and no default scope will be used either.
13839 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13840 /// for details).
13841 pub fn clear_scopes(mut self) -> FileDeleteCall<'a, C> {
13842 self._scopes.clear();
13843 self
13844 }
13845}
13846
13847/// Downloads the content of a file. For more information, see [Download and export files](https://developers.google.com/workspace/drive/api/guides/manage-downloads). Operations are valid for 24 hours from the time of creation.
13848///
13849/// A builder for the *download* method supported by a *file* resource.
13850/// It is not used directly, but through a [`FileMethods`] instance.
13851///
13852/// # Example
13853///
13854/// Instantiate a resource method builder
13855///
13856/// ```test_harness,no_run
13857/// # extern crate hyper;
13858/// # extern crate hyper_rustls;
13859/// # extern crate google_drive3 as drive3;
13860/// # async fn dox() {
13861/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13862///
13863/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13864/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13865/// # .with_native_roots()
13866/// # .unwrap()
13867/// # .https_only()
13868/// # .enable_http2()
13869/// # .build();
13870///
13871/// # let executor = hyper_util::rt::TokioExecutor::new();
13872/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13873/// # secret,
13874/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13875/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13876/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13877/// # ),
13878/// # ).build().await.unwrap();
13879///
13880/// # let client = hyper_util::client::legacy::Client::builder(
13881/// # hyper_util::rt::TokioExecutor::new()
13882/// # )
13883/// # .build(
13884/// # hyper_rustls::HttpsConnectorBuilder::new()
13885/// # .with_native_roots()
13886/// # .unwrap()
13887/// # .https_or_http()
13888/// # .enable_http2()
13889/// # .build()
13890/// # );
13891/// # let mut hub = DriveHub::new(client, auth);
13892/// // You can configure optional parameters by calling the respective setters at will, and
13893/// // execute the final call using `doit()`.
13894/// // Values shown here are possibly random and not representative !
13895/// let result = hub.files().download("fileId")
13896/// .revision_id("aliquyam")
13897/// .mime_type("eos")
13898/// .doit().await;
13899/// # }
13900/// ```
13901pub struct FileDownloadCall<'a, C>
13902where
13903 C: 'a,
13904{
13905 hub: &'a DriveHub<C>,
13906 _file_id: String,
13907 _revision_id: Option<String>,
13908 _mime_type: Option<String>,
13909 _delegate: Option<&'a mut dyn common::Delegate>,
13910 _additional_params: HashMap<String, String>,
13911 _scopes: BTreeSet<String>,
13912}
13913
13914impl<'a, C> common::CallBuilder for FileDownloadCall<'a, C> {}
13915
13916impl<'a, C> FileDownloadCall<'a, C>
13917where
13918 C: common::Connector,
13919{
13920 /// Perform the operation you have build so far.
13921 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13922 use std::borrow::Cow;
13923 use std::io::{Read, Seek};
13924
13925 use common::{url::Params, ToParts};
13926 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13927
13928 let mut dd = common::DefaultDelegate;
13929 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13930 dlg.begin(common::MethodInfo {
13931 id: "drive.files.download",
13932 http_method: hyper::Method::POST,
13933 });
13934
13935 for &field in ["alt", "fileId", "revisionId", "mimeType"].iter() {
13936 if self._additional_params.contains_key(field) {
13937 dlg.finished(false);
13938 return Err(common::Error::FieldClash(field));
13939 }
13940 }
13941
13942 let mut params = Params::with_capacity(5 + self._additional_params.len());
13943 params.push("fileId", self._file_id);
13944 if let Some(value) = self._revision_id.as_ref() {
13945 params.push("revisionId", value);
13946 }
13947 if let Some(value) = self._mime_type.as_ref() {
13948 params.push("mimeType", value);
13949 }
13950
13951 params.extend(self._additional_params.iter());
13952
13953 params.push("alt", "json");
13954 let mut url = self.hub._base_url.clone() + "files/{fileId}/download";
13955 if self._scopes.is_empty() {
13956 self._scopes.insert(Scope::Readonly.as_ref().to_string());
13957 }
13958
13959 #[allow(clippy::single_element_loop)]
13960 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
13961 url = params.uri_replacement(url, param_name, find_this, false);
13962 }
13963 {
13964 let to_remove = ["fileId"];
13965 params.remove_params(&to_remove);
13966 }
13967
13968 let url = params.parse_with_url(&url);
13969
13970 loop {
13971 let token = match self
13972 .hub
13973 .auth
13974 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13975 .await
13976 {
13977 Ok(token) => token,
13978 Err(e) => match dlg.token(e) {
13979 Ok(token) => token,
13980 Err(e) => {
13981 dlg.finished(false);
13982 return Err(common::Error::MissingToken(e));
13983 }
13984 },
13985 };
13986 let mut req_result = {
13987 let client = &self.hub.client;
13988 dlg.pre_request();
13989 let mut req_builder = hyper::Request::builder()
13990 .method(hyper::Method::POST)
13991 .uri(url.as_str())
13992 .header(USER_AGENT, self.hub._user_agent.clone());
13993
13994 if let Some(token) = token.as_ref() {
13995 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13996 }
13997
13998 let request = req_builder
13999 .header(CONTENT_LENGTH, 0_u64)
14000 .body(common::to_body::<String>(None));
14001
14002 client.request(request.unwrap()).await
14003 };
14004
14005 match req_result {
14006 Err(err) => {
14007 if let common::Retry::After(d) = dlg.http_error(&err) {
14008 sleep(d).await;
14009 continue;
14010 }
14011 dlg.finished(false);
14012 return Err(common::Error::HttpError(err));
14013 }
14014 Ok(res) => {
14015 let (mut parts, body) = res.into_parts();
14016 let mut body = common::Body::new(body);
14017 if !parts.status.is_success() {
14018 let bytes = common::to_bytes(body).await.unwrap_or_default();
14019 let error = serde_json::from_str(&common::to_string(&bytes));
14020 let response = common::to_response(parts, bytes.into());
14021
14022 if let common::Retry::After(d) =
14023 dlg.http_failure(&response, error.as_ref().ok())
14024 {
14025 sleep(d).await;
14026 continue;
14027 }
14028
14029 dlg.finished(false);
14030
14031 return Err(match error {
14032 Ok(value) => common::Error::BadRequest(value),
14033 _ => common::Error::Failure(response),
14034 });
14035 }
14036 let response = {
14037 let bytes = common::to_bytes(body).await.unwrap_or_default();
14038 let encoded = common::to_string(&bytes);
14039 match serde_json::from_str(&encoded) {
14040 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14041 Err(error) => {
14042 dlg.response_json_decode_error(&encoded, &error);
14043 return Err(common::Error::JsonDecodeError(
14044 encoded.to_string(),
14045 error,
14046 ));
14047 }
14048 }
14049 };
14050
14051 dlg.finished(true);
14052 return Ok(response);
14053 }
14054 }
14055 }
14056 }
14057
14058 /// Required. The ID of the file to download.
14059 ///
14060 /// Sets the *file id* path property to the given value.
14061 ///
14062 /// Even though the property as already been set when instantiating this call,
14063 /// we provide this method for API completeness.
14064 pub fn file_id(mut self, new_value: &str) -> FileDownloadCall<'a, C> {
14065 self._file_id = new_value.to_string();
14066 self
14067 }
14068 /// Optional. The revision ID of the file to download. This field can only be set when downloading blob files, Google Docs, and Google Sheets. Returns `INVALID_ARGUMENT` if downloading a specific revision on the file is unsupported.
14069 ///
14070 /// Sets the *revision id* query property to the given value.
14071 pub fn revision_id(mut self, new_value: &str) -> FileDownloadCall<'a, C> {
14072 self._revision_id = Some(new_value.to_string());
14073 self
14074 }
14075 /// Optional. The MIME type the file should be downloaded as. This field can only be set when downloading Google Workspace documents. For a list of supported MIME types, see [Export MIME types for Google Workspace documents](https://developers.google.com/workspace/drive/api/guides/ref-export-formats). If not set, a Google Workspace document is downloaded with a default MIME type. The default MIME type might change in the future.
14076 ///
14077 /// Sets the *mime type* query property to the given value.
14078 pub fn mime_type(mut self, new_value: &str) -> FileDownloadCall<'a, C> {
14079 self._mime_type = Some(new_value.to_string());
14080 self
14081 }
14082 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14083 /// while executing the actual API request.
14084 ///
14085 /// ````text
14086 /// It should be used to handle progress information, and to implement a certain level of resilience.
14087 /// ````
14088 ///
14089 /// Sets the *delegate* property to the given value.
14090 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileDownloadCall<'a, C> {
14091 self._delegate = Some(new_value);
14092 self
14093 }
14094
14095 /// Set any additional parameter of the query string used in the request.
14096 /// It should be used to set parameters which are not yet available through their own
14097 /// setters.
14098 ///
14099 /// Please note that this method must not be used to set any of the known parameters
14100 /// which have their own setter method. If done anyway, the request will fail.
14101 ///
14102 /// # Additional Parameters
14103 ///
14104 /// * *$.xgafv* (query-string) - V1 error format.
14105 /// * *access_token* (query-string) - OAuth access token.
14106 /// * *alt* (query-string) - Data format for response.
14107 /// * *callback* (query-string) - JSONP
14108 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14109 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14110 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14111 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14112 /// * *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.
14113 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14114 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14115 pub fn param<T>(mut self, name: T, value: T) -> FileDownloadCall<'a, C>
14116 where
14117 T: AsRef<str>,
14118 {
14119 self._additional_params
14120 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14121 self
14122 }
14123
14124 /// Identifies the authorization scope for the method you are building.
14125 ///
14126 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14127 /// [`Scope::Readonly`].
14128 ///
14129 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14130 /// tokens for more than one scope.
14131 ///
14132 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14133 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14134 /// sufficient, a read-write scope will do as well.
14135 pub fn add_scope<St>(mut self, scope: St) -> FileDownloadCall<'a, C>
14136 where
14137 St: AsRef<str>,
14138 {
14139 self._scopes.insert(String::from(scope.as_ref()));
14140 self
14141 }
14142 /// Identifies the authorization scope(s) for the method you are building.
14143 ///
14144 /// See [`Self::add_scope()`] for details.
14145 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileDownloadCall<'a, C>
14146 where
14147 I: IntoIterator<Item = St>,
14148 St: AsRef<str>,
14149 {
14150 self._scopes
14151 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14152 self
14153 }
14154
14155 /// Removes all scopes, and no default scope will be used either.
14156 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14157 /// for details).
14158 pub fn clear_scopes(mut self) -> FileDownloadCall<'a, C> {
14159 self._scopes.clear();
14160 self
14161 }
14162}
14163
14164/// Permanently deletes all of the user's trashed files. For more information, see [Trash or delete files and folders](https://developers.google.com/workspace/drive/api/guides/delete).
14165///
14166/// A builder for the *emptyTrash* method supported by a *file* resource.
14167/// It is not used directly, but through a [`FileMethods`] instance.
14168///
14169/// # Example
14170///
14171/// Instantiate a resource method builder
14172///
14173/// ```test_harness,no_run
14174/// # extern crate hyper;
14175/// # extern crate hyper_rustls;
14176/// # extern crate google_drive3 as drive3;
14177/// # async fn dox() {
14178/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14179///
14180/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14181/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14182/// # .with_native_roots()
14183/// # .unwrap()
14184/// # .https_only()
14185/// # .enable_http2()
14186/// # .build();
14187///
14188/// # let executor = hyper_util::rt::TokioExecutor::new();
14189/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14190/// # secret,
14191/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14192/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14193/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14194/// # ),
14195/// # ).build().await.unwrap();
14196///
14197/// # let client = hyper_util::client::legacy::Client::builder(
14198/// # hyper_util::rt::TokioExecutor::new()
14199/// # )
14200/// # .build(
14201/// # hyper_rustls::HttpsConnectorBuilder::new()
14202/// # .with_native_roots()
14203/// # .unwrap()
14204/// # .https_or_http()
14205/// # .enable_http2()
14206/// # .build()
14207/// # );
14208/// # let mut hub = DriveHub::new(client, auth);
14209/// // You can configure optional parameters by calling the respective setters at will, and
14210/// // execute the final call using `doit()`.
14211/// // Values shown here are possibly random and not representative !
14212/// let result = hub.files().empty_trash()
14213/// .enforce_single_parent(false)
14214/// .drive_id("dolores")
14215/// .doit().await;
14216/// # }
14217/// ```
14218pub struct FileEmptyTrashCall<'a, C>
14219where
14220 C: 'a,
14221{
14222 hub: &'a DriveHub<C>,
14223 _enforce_single_parent: Option<bool>,
14224 _drive_id: Option<String>,
14225 _delegate: Option<&'a mut dyn common::Delegate>,
14226 _additional_params: HashMap<String, String>,
14227 _scopes: BTreeSet<String>,
14228}
14229
14230impl<'a, C> common::CallBuilder for FileEmptyTrashCall<'a, C> {}
14231
14232impl<'a, C> FileEmptyTrashCall<'a, C>
14233where
14234 C: common::Connector,
14235{
14236 /// Perform the operation you have build so far.
14237 pub async fn doit(mut self) -> common::Result<common::Response> {
14238 use std::borrow::Cow;
14239 use std::io::{Read, Seek};
14240
14241 use common::{url::Params, ToParts};
14242 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14243
14244 let mut dd = common::DefaultDelegate;
14245 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14246 dlg.begin(common::MethodInfo {
14247 id: "drive.files.emptyTrash",
14248 http_method: hyper::Method::DELETE,
14249 });
14250
14251 for &field in ["enforceSingleParent", "driveId"].iter() {
14252 if self._additional_params.contains_key(field) {
14253 dlg.finished(false);
14254 return Err(common::Error::FieldClash(field));
14255 }
14256 }
14257
14258 let mut params = Params::with_capacity(3 + self._additional_params.len());
14259 if let Some(value) = self._enforce_single_parent.as_ref() {
14260 params.push("enforceSingleParent", value.to_string());
14261 }
14262 if let Some(value) = self._drive_id.as_ref() {
14263 params.push("driveId", value);
14264 }
14265
14266 params.extend(self._additional_params.iter());
14267
14268 let mut url = self.hub._base_url.clone() + "files/trash";
14269 if self._scopes.is_empty() {
14270 self._scopes.insert(Scope::Full.as_ref().to_string());
14271 }
14272
14273 let url = params.parse_with_url(&url);
14274
14275 loop {
14276 let token = match self
14277 .hub
14278 .auth
14279 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14280 .await
14281 {
14282 Ok(token) => token,
14283 Err(e) => match dlg.token(e) {
14284 Ok(token) => token,
14285 Err(e) => {
14286 dlg.finished(false);
14287 return Err(common::Error::MissingToken(e));
14288 }
14289 },
14290 };
14291 let mut req_result = {
14292 let client = &self.hub.client;
14293 dlg.pre_request();
14294 let mut req_builder = hyper::Request::builder()
14295 .method(hyper::Method::DELETE)
14296 .uri(url.as_str())
14297 .header(USER_AGENT, self.hub._user_agent.clone());
14298
14299 if let Some(token) = token.as_ref() {
14300 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14301 }
14302
14303 let request = req_builder
14304 .header(CONTENT_LENGTH, 0_u64)
14305 .body(common::to_body::<String>(None));
14306
14307 client.request(request.unwrap()).await
14308 };
14309
14310 match req_result {
14311 Err(err) => {
14312 if let common::Retry::After(d) = dlg.http_error(&err) {
14313 sleep(d).await;
14314 continue;
14315 }
14316 dlg.finished(false);
14317 return Err(common::Error::HttpError(err));
14318 }
14319 Ok(res) => {
14320 let (mut parts, body) = res.into_parts();
14321 let mut body = common::Body::new(body);
14322 if !parts.status.is_success() {
14323 let bytes = common::to_bytes(body).await.unwrap_or_default();
14324 let error = serde_json::from_str(&common::to_string(&bytes));
14325 let response = common::to_response(parts, bytes.into());
14326
14327 if let common::Retry::After(d) =
14328 dlg.http_failure(&response, error.as_ref().ok())
14329 {
14330 sleep(d).await;
14331 continue;
14332 }
14333
14334 dlg.finished(false);
14335
14336 return Err(match error {
14337 Ok(value) => common::Error::BadRequest(value),
14338 _ => common::Error::Failure(response),
14339 });
14340 }
14341 let response = common::Response::from_parts(parts, body);
14342
14343 dlg.finished(true);
14344 return Ok(response);
14345 }
14346 }
14347 }
14348 }
14349
14350 /// Deprecated: If an item isn't in a shared drive and its last parent is deleted but the item itself isn't, the item will be placed under its owner's root.
14351 ///
14352 /// Sets the *enforce single parent* query property to the given value.
14353 pub fn enforce_single_parent(mut self, new_value: bool) -> FileEmptyTrashCall<'a, C> {
14354 self._enforce_single_parent = Some(new_value);
14355 self
14356 }
14357 /// If set, empties the trash of the provided shared drive.
14358 ///
14359 /// Sets the *drive id* query property to the given value.
14360 pub fn drive_id(mut self, new_value: &str) -> FileEmptyTrashCall<'a, C> {
14361 self._drive_id = Some(new_value.to_string());
14362 self
14363 }
14364 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14365 /// while executing the actual API request.
14366 ///
14367 /// ````text
14368 /// It should be used to handle progress information, and to implement a certain level of resilience.
14369 /// ````
14370 ///
14371 /// Sets the *delegate* property to the given value.
14372 pub fn delegate(
14373 mut self,
14374 new_value: &'a mut dyn common::Delegate,
14375 ) -> FileEmptyTrashCall<'a, C> {
14376 self._delegate = Some(new_value);
14377 self
14378 }
14379
14380 /// Set any additional parameter of the query string used in the request.
14381 /// It should be used to set parameters which are not yet available through their own
14382 /// setters.
14383 ///
14384 /// Please note that this method must not be used to set any of the known parameters
14385 /// which have their own setter method. If done anyway, the request will fail.
14386 ///
14387 /// # Additional Parameters
14388 ///
14389 /// * *$.xgafv* (query-string) - V1 error format.
14390 /// * *access_token* (query-string) - OAuth access token.
14391 /// * *alt* (query-string) - Data format for response.
14392 /// * *callback* (query-string) - JSONP
14393 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14394 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14395 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14396 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14397 /// * *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.
14398 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14399 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14400 pub fn param<T>(mut self, name: T, value: T) -> FileEmptyTrashCall<'a, C>
14401 where
14402 T: AsRef<str>,
14403 {
14404 self._additional_params
14405 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14406 self
14407 }
14408
14409 /// Identifies the authorization scope for the method you are building.
14410 ///
14411 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14412 /// [`Scope::Full`].
14413 ///
14414 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14415 /// tokens for more than one scope.
14416 ///
14417 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14418 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14419 /// sufficient, a read-write scope will do as well.
14420 pub fn add_scope<St>(mut self, scope: St) -> FileEmptyTrashCall<'a, C>
14421 where
14422 St: AsRef<str>,
14423 {
14424 self._scopes.insert(String::from(scope.as_ref()));
14425 self
14426 }
14427 /// Identifies the authorization scope(s) for the method you are building.
14428 ///
14429 /// See [`Self::add_scope()`] for details.
14430 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileEmptyTrashCall<'a, C>
14431 where
14432 I: IntoIterator<Item = St>,
14433 St: AsRef<str>,
14434 {
14435 self._scopes
14436 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14437 self
14438 }
14439
14440 /// Removes all scopes, and no default scope will be used either.
14441 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14442 /// for details).
14443 pub fn clear_scopes(mut self) -> FileEmptyTrashCall<'a, C> {
14444 self._scopes.clear();
14445 self
14446 }
14447}
14448
14449/// Exports a Google Workspace document to the requested MIME type and returns exported byte content. For more information, see [Download and export files](https://developers.google.com/workspace/drive/api/guides/manage-downloads). Note that the exported content is limited to 10 MB.
14450///
14451/// This method supports **media download**. To enable it, adjust the builder like this:
14452/// `.param("alt", "media")`.
14453///
14454/// A builder for the *export* method supported by a *file* resource.
14455/// It is not used directly, but through a [`FileMethods`] instance.
14456///
14457/// # Example
14458///
14459/// Instantiate a resource method builder
14460///
14461/// ```test_harness,no_run
14462/// # extern crate hyper;
14463/// # extern crate hyper_rustls;
14464/// # extern crate google_drive3 as drive3;
14465/// # async fn dox() {
14466/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14467///
14468/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14469/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14470/// # .with_native_roots()
14471/// # .unwrap()
14472/// # .https_only()
14473/// # .enable_http2()
14474/// # .build();
14475///
14476/// # let executor = hyper_util::rt::TokioExecutor::new();
14477/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14478/// # secret,
14479/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14480/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14481/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14482/// # ),
14483/// # ).build().await.unwrap();
14484///
14485/// # let client = hyper_util::client::legacy::Client::builder(
14486/// # hyper_util::rt::TokioExecutor::new()
14487/// # )
14488/// # .build(
14489/// # hyper_rustls::HttpsConnectorBuilder::new()
14490/// # .with_native_roots()
14491/// # .unwrap()
14492/// # .https_or_http()
14493/// # .enable_http2()
14494/// # .build()
14495/// # );
14496/// # let mut hub = DriveHub::new(client, auth);
14497/// // You can configure optional parameters by calling the respective setters at will, and
14498/// // execute the final call using `doit()`.
14499/// // Values shown here are possibly random and not representative !
14500/// let result = hub.files().export("fileId", "mimeType")
14501/// .doit().await;
14502/// # }
14503/// ```
14504pub struct FileExportCall<'a, C>
14505where
14506 C: 'a,
14507{
14508 hub: &'a DriveHub<C>,
14509 _file_id: String,
14510 _mime_type: String,
14511 _delegate: Option<&'a mut dyn common::Delegate>,
14512 _additional_params: HashMap<String, String>,
14513 _scopes: BTreeSet<String>,
14514}
14515
14516impl<'a, C> common::CallBuilder for FileExportCall<'a, C> {}
14517
14518impl<'a, C> FileExportCall<'a, C>
14519where
14520 C: common::Connector,
14521{
14522 /// Perform the operation you have build so far.
14523 pub async fn doit(mut self) -> common::Result<common::Response> {
14524 use std::borrow::Cow;
14525 use std::io::{Read, Seek};
14526
14527 use common::{url::Params, ToParts};
14528 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14529
14530 let mut dd = common::DefaultDelegate;
14531 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14532 dlg.begin(common::MethodInfo {
14533 id: "drive.files.export",
14534 http_method: hyper::Method::GET,
14535 });
14536
14537 for &field in ["fileId", "mimeType"].iter() {
14538 if self._additional_params.contains_key(field) {
14539 dlg.finished(false);
14540 return Err(common::Error::FieldClash(field));
14541 }
14542 }
14543
14544 let mut params = Params::with_capacity(3 + self._additional_params.len());
14545 params.push("fileId", self._file_id);
14546 params.push("mimeType", self._mime_type);
14547
14548 params.extend(self._additional_params.iter());
14549
14550 let mut url = self.hub._base_url.clone() + "files/{fileId}/export";
14551 if self._scopes.is_empty() {
14552 self._scopes
14553 .insert(Scope::MeetReadonly.as_ref().to_string());
14554 }
14555
14556 #[allow(clippy::single_element_loop)]
14557 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
14558 url = params.uri_replacement(url, param_name, find_this, false);
14559 }
14560 {
14561 let to_remove = ["fileId"];
14562 params.remove_params(&to_remove);
14563 }
14564
14565 let url = params.parse_with_url(&url);
14566
14567 loop {
14568 let token = match self
14569 .hub
14570 .auth
14571 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14572 .await
14573 {
14574 Ok(token) => token,
14575 Err(e) => match dlg.token(e) {
14576 Ok(token) => token,
14577 Err(e) => {
14578 dlg.finished(false);
14579 return Err(common::Error::MissingToken(e));
14580 }
14581 },
14582 };
14583 let mut req_result = {
14584 let client = &self.hub.client;
14585 dlg.pre_request();
14586 let mut req_builder = hyper::Request::builder()
14587 .method(hyper::Method::GET)
14588 .uri(url.as_str())
14589 .header(USER_AGENT, self.hub._user_agent.clone());
14590
14591 if let Some(token) = token.as_ref() {
14592 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14593 }
14594
14595 let request = req_builder
14596 .header(CONTENT_LENGTH, 0_u64)
14597 .body(common::to_body::<String>(None));
14598
14599 client.request(request.unwrap()).await
14600 };
14601
14602 match req_result {
14603 Err(err) => {
14604 if let common::Retry::After(d) = dlg.http_error(&err) {
14605 sleep(d).await;
14606 continue;
14607 }
14608 dlg.finished(false);
14609 return Err(common::Error::HttpError(err));
14610 }
14611 Ok(res) => {
14612 let (mut parts, body) = res.into_parts();
14613 let mut body = common::Body::new(body);
14614 if !parts.status.is_success() {
14615 let bytes = common::to_bytes(body).await.unwrap_or_default();
14616 let error = serde_json::from_str(&common::to_string(&bytes));
14617 let response = common::to_response(parts, bytes.into());
14618
14619 if let common::Retry::After(d) =
14620 dlg.http_failure(&response, error.as_ref().ok())
14621 {
14622 sleep(d).await;
14623 continue;
14624 }
14625
14626 dlg.finished(false);
14627
14628 return Err(match error {
14629 Ok(value) => common::Error::BadRequest(value),
14630 _ => common::Error::Failure(response),
14631 });
14632 }
14633 let response = common::Response::from_parts(parts, body);
14634
14635 dlg.finished(true);
14636 return Ok(response);
14637 }
14638 }
14639 }
14640 }
14641
14642 /// The ID of the file.
14643 ///
14644 /// Sets the *file id* path property to the given value.
14645 ///
14646 /// Even though the property as already been set when instantiating this call,
14647 /// we provide this method for API completeness.
14648 pub fn file_id(mut self, new_value: &str) -> FileExportCall<'a, C> {
14649 self._file_id = new_value.to_string();
14650 self
14651 }
14652 /// Required. The MIME type of the format requested for this export. For a list of supported MIME types, see [Export MIME types for Google Workspace documents](https://developers.google.com/workspace/drive/api/guides/ref-export-formats).
14653 ///
14654 /// Sets the *mime type* query property to the given value.
14655 ///
14656 /// Even though the property as already been set when instantiating this call,
14657 /// we provide this method for API completeness.
14658 pub fn mime_type(mut self, new_value: &str) -> FileExportCall<'a, C> {
14659 self._mime_type = new_value.to_string();
14660 self
14661 }
14662 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14663 /// while executing the actual API request.
14664 ///
14665 /// ````text
14666 /// It should be used to handle progress information, and to implement a certain level of resilience.
14667 /// ````
14668 ///
14669 /// Sets the *delegate* property to the given value.
14670 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileExportCall<'a, C> {
14671 self._delegate = Some(new_value);
14672 self
14673 }
14674
14675 /// Set any additional parameter of the query string used in the request.
14676 /// It should be used to set parameters which are not yet available through their own
14677 /// setters.
14678 ///
14679 /// Please note that this method must not be used to set any of the known parameters
14680 /// which have their own setter method. If done anyway, the request will fail.
14681 ///
14682 /// # Additional Parameters
14683 ///
14684 /// * *$.xgafv* (query-string) - V1 error format.
14685 /// * *access_token* (query-string) - OAuth access token.
14686 /// * *alt* (query-string) - Data format for response.
14687 /// * *callback* (query-string) - JSONP
14688 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14689 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14690 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14691 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14692 /// * *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.
14693 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14694 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14695 pub fn param<T>(mut self, name: T, value: T) -> FileExportCall<'a, C>
14696 where
14697 T: AsRef<str>,
14698 {
14699 self._additional_params
14700 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14701 self
14702 }
14703
14704 /// Identifies the authorization scope for the method you are building.
14705 ///
14706 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14707 /// [`Scope::MeetReadonly`].
14708 ///
14709 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14710 /// tokens for more than one scope.
14711 ///
14712 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14713 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14714 /// sufficient, a read-write scope will do as well.
14715 pub fn add_scope<St>(mut self, scope: St) -> FileExportCall<'a, C>
14716 where
14717 St: AsRef<str>,
14718 {
14719 self._scopes.insert(String::from(scope.as_ref()));
14720 self
14721 }
14722 /// Identifies the authorization scope(s) for the method you are building.
14723 ///
14724 /// See [`Self::add_scope()`] for details.
14725 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileExportCall<'a, C>
14726 where
14727 I: IntoIterator<Item = St>,
14728 St: AsRef<str>,
14729 {
14730 self._scopes
14731 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14732 self
14733 }
14734
14735 /// Removes all scopes, and no default scope will be used either.
14736 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14737 /// for details).
14738 pub fn clear_scopes(mut self) -> FileExportCall<'a, C> {
14739 self._scopes.clear();
14740 self
14741 }
14742}
14743
14744/// Generates a set of file IDs which can be provided in create or copy requests. For more information, see [Create and manage files](https://developers.google.com/workspace/drive/api/guides/create-file).
14745///
14746/// A builder for the *generateIds* method supported by a *file* resource.
14747/// It is not used directly, but through a [`FileMethods`] instance.
14748///
14749/// # Example
14750///
14751/// Instantiate a resource method builder
14752///
14753/// ```test_harness,no_run
14754/// # extern crate hyper;
14755/// # extern crate hyper_rustls;
14756/// # extern crate google_drive3 as drive3;
14757/// # async fn dox() {
14758/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14759///
14760/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14761/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14762/// # .with_native_roots()
14763/// # .unwrap()
14764/// # .https_only()
14765/// # .enable_http2()
14766/// # .build();
14767///
14768/// # let executor = hyper_util::rt::TokioExecutor::new();
14769/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14770/// # secret,
14771/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14772/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14773/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14774/// # ),
14775/// # ).build().await.unwrap();
14776///
14777/// # let client = hyper_util::client::legacy::Client::builder(
14778/// # hyper_util::rt::TokioExecutor::new()
14779/// # )
14780/// # .build(
14781/// # hyper_rustls::HttpsConnectorBuilder::new()
14782/// # .with_native_roots()
14783/// # .unwrap()
14784/// # .https_or_http()
14785/// # .enable_http2()
14786/// # .build()
14787/// # );
14788/// # let mut hub = DriveHub::new(client, auth);
14789/// // You can configure optional parameters by calling the respective setters at will, and
14790/// // execute the final call using `doit()`.
14791/// // Values shown here are possibly random and not representative !
14792/// let result = hub.files().generate_ids()
14793/// .type_("dolor")
14794/// .space("aliquyam")
14795/// .count(-61)
14796/// .doit().await;
14797/// # }
14798/// ```
14799pub struct FileGenerateIdCall<'a, C>
14800where
14801 C: 'a,
14802{
14803 hub: &'a DriveHub<C>,
14804 _type_: Option<String>,
14805 _space: Option<String>,
14806 _count: Option<i32>,
14807 _delegate: Option<&'a mut dyn common::Delegate>,
14808 _additional_params: HashMap<String, String>,
14809 _scopes: BTreeSet<String>,
14810}
14811
14812impl<'a, C> common::CallBuilder for FileGenerateIdCall<'a, C> {}
14813
14814impl<'a, C> FileGenerateIdCall<'a, C>
14815where
14816 C: common::Connector,
14817{
14818 /// Perform the operation you have build so far.
14819 pub async fn doit(mut self) -> common::Result<(common::Response, GeneratedIds)> {
14820 use std::borrow::Cow;
14821 use std::io::{Read, Seek};
14822
14823 use common::{url::Params, ToParts};
14824 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14825
14826 let mut dd = common::DefaultDelegate;
14827 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14828 dlg.begin(common::MethodInfo {
14829 id: "drive.files.generateIds",
14830 http_method: hyper::Method::GET,
14831 });
14832
14833 for &field in ["alt", "type", "space", "count"].iter() {
14834 if self._additional_params.contains_key(field) {
14835 dlg.finished(false);
14836 return Err(common::Error::FieldClash(field));
14837 }
14838 }
14839
14840 let mut params = Params::with_capacity(5 + self._additional_params.len());
14841 if let Some(value) = self._type_.as_ref() {
14842 params.push("type", value);
14843 }
14844 if let Some(value) = self._space.as_ref() {
14845 params.push("space", value);
14846 }
14847 if let Some(value) = self._count.as_ref() {
14848 params.push("count", value.to_string());
14849 }
14850
14851 params.extend(self._additional_params.iter());
14852
14853 params.push("alt", "json");
14854 let mut url = self.hub._base_url.clone() + "files/generateIds";
14855 if self._scopes.is_empty() {
14856 self._scopes.insert(Scope::Full.as_ref().to_string());
14857 }
14858
14859 let url = params.parse_with_url(&url);
14860
14861 loop {
14862 let token = match self
14863 .hub
14864 .auth
14865 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14866 .await
14867 {
14868 Ok(token) => token,
14869 Err(e) => match dlg.token(e) {
14870 Ok(token) => token,
14871 Err(e) => {
14872 dlg.finished(false);
14873 return Err(common::Error::MissingToken(e));
14874 }
14875 },
14876 };
14877 let mut req_result = {
14878 let client = &self.hub.client;
14879 dlg.pre_request();
14880 let mut req_builder = hyper::Request::builder()
14881 .method(hyper::Method::GET)
14882 .uri(url.as_str())
14883 .header(USER_AGENT, self.hub._user_agent.clone());
14884
14885 if let Some(token) = token.as_ref() {
14886 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14887 }
14888
14889 let request = req_builder
14890 .header(CONTENT_LENGTH, 0_u64)
14891 .body(common::to_body::<String>(None));
14892
14893 client.request(request.unwrap()).await
14894 };
14895
14896 match req_result {
14897 Err(err) => {
14898 if let common::Retry::After(d) = dlg.http_error(&err) {
14899 sleep(d).await;
14900 continue;
14901 }
14902 dlg.finished(false);
14903 return Err(common::Error::HttpError(err));
14904 }
14905 Ok(res) => {
14906 let (mut parts, body) = res.into_parts();
14907 let mut body = common::Body::new(body);
14908 if !parts.status.is_success() {
14909 let bytes = common::to_bytes(body).await.unwrap_or_default();
14910 let error = serde_json::from_str(&common::to_string(&bytes));
14911 let response = common::to_response(parts, bytes.into());
14912
14913 if let common::Retry::After(d) =
14914 dlg.http_failure(&response, error.as_ref().ok())
14915 {
14916 sleep(d).await;
14917 continue;
14918 }
14919
14920 dlg.finished(false);
14921
14922 return Err(match error {
14923 Ok(value) => common::Error::BadRequest(value),
14924 _ => common::Error::Failure(response),
14925 });
14926 }
14927 let response = {
14928 let bytes = common::to_bytes(body).await.unwrap_or_default();
14929 let encoded = common::to_string(&bytes);
14930 match serde_json::from_str(&encoded) {
14931 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14932 Err(error) => {
14933 dlg.response_json_decode_error(&encoded, &error);
14934 return Err(common::Error::JsonDecodeError(
14935 encoded.to_string(),
14936 error,
14937 ));
14938 }
14939 }
14940 };
14941
14942 dlg.finished(true);
14943 return Ok(response);
14944 }
14945 }
14946 }
14947 }
14948
14949 /// 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`.) For more information, see [File organization](https://developers.google.com/workspace/drive/api/guides/about-files#file-organization).
14950 ///
14951 /// Sets the *type* query property to the given value.
14952 pub fn type_(mut self, new_value: &str) -> FileGenerateIdCall<'a, C> {
14953 self._type_ = Some(new_value.to_string());
14954 self
14955 }
14956 /// The space in which the IDs can be used to create files. Supported values are `drive` and `appDataFolder`. (Default: `drive`.) For more information, see [File organization](https://developers.google.com/workspace/drive/api/guides/about-files#file-organization).
14957 ///
14958 /// Sets the *space* query property to the given value.
14959 pub fn space(mut self, new_value: &str) -> FileGenerateIdCall<'a, C> {
14960 self._space = Some(new_value.to_string());
14961 self
14962 }
14963 /// The number of IDs to return.
14964 ///
14965 /// Sets the *count* query property to the given value.
14966 pub fn count(mut self, new_value: i32) -> FileGenerateIdCall<'a, C> {
14967 self._count = Some(new_value);
14968 self
14969 }
14970 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14971 /// while executing the actual API request.
14972 ///
14973 /// ````text
14974 /// It should be used to handle progress information, and to implement a certain level of resilience.
14975 /// ````
14976 ///
14977 /// Sets the *delegate* property to the given value.
14978 pub fn delegate(
14979 mut self,
14980 new_value: &'a mut dyn common::Delegate,
14981 ) -> FileGenerateIdCall<'a, C> {
14982 self._delegate = Some(new_value);
14983 self
14984 }
14985
14986 /// Set any additional parameter of the query string used in the request.
14987 /// It should be used to set parameters which are not yet available through their own
14988 /// setters.
14989 ///
14990 /// Please note that this method must not be used to set any of the known parameters
14991 /// which have their own setter method. If done anyway, the request will fail.
14992 ///
14993 /// # Additional Parameters
14994 ///
14995 /// * *$.xgafv* (query-string) - V1 error format.
14996 /// * *access_token* (query-string) - OAuth access token.
14997 /// * *alt* (query-string) - Data format for response.
14998 /// * *callback* (query-string) - JSONP
14999 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15000 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15001 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15002 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15003 /// * *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.
15004 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15005 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15006 pub fn param<T>(mut self, name: T, value: T) -> FileGenerateIdCall<'a, C>
15007 where
15008 T: AsRef<str>,
15009 {
15010 self._additional_params
15011 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15012 self
15013 }
15014
15015 /// Identifies the authorization scope for the method you are building.
15016 ///
15017 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15018 /// [`Scope::Full`].
15019 ///
15020 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15021 /// tokens for more than one scope.
15022 ///
15023 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15024 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15025 /// sufficient, a read-write scope will do as well.
15026 pub fn add_scope<St>(mut self, scope: St) -> FileGenerateIdCall<'a, C>
15027 where
15028 St: AsRef<str>,
15029 {
15030 self._scopes.insert(String::from(scope.as_ref()));
15031 self
15032 }
15033 /// Identifies the authorization scope(s) for the method you are building.
15034 ///
15035 /// See [`Self::add_scope()`] for details.
15036 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileGenerateIdCall<'a, C>
15037 where
15038 I: IntoIterator<Item = St>,
15039 St: AsRef<str>,
15040 {
15041 self._scopes
15042 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15043 self
15044 }
15045
15046 /// Removes all scopes, and no default scope will be used either.
15047 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15048 /// for details).
15049 pub fn clear_scopes(mut self) -> FileGenerateIdCall<'a, C> {
15050 self._scopes.clear();
15051 self
15052 }
15053}
15054
15055/// Gets a file’s metadata or content by ID. For more information, see [Search for files and folders](https://developers.google.com/workspace/drive/api/guides/search-files). 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/v3/files/export) instead. For more information, see [Download and export files](https://developers.google.com/workspace/drive/api/guides/manage-downloads).
15056///
15057/// This method supports **media download**. To enable it, adjust the builder like this:
15058/// `.param("alt", "media")`.
15059/// Please note that due to missing multi-part support on the server side, you will only receive the media,
15060/// but not the `File` structure that you would usually get. The latter will be a default value.
15061///
15062/// A builder for the *get* method supported by a *file* resource.
15063/// It is not used directly, but through a [`FileMethods`] instance.
15064///
15065/// # Example
15066///
15067/// Instantiate a resource method builder
15068///
15069/// ```test_harness,no_run
15070/// # extern crate hyper;
15071/// # extern crate hyper_rustls;
15072/// # extern crate google_drive3 as drive3;
15073/// # async fn dox() {
15074/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15075///
15076/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15077/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15078/// # .with_native_roots()
15079/// # .unwrap()
15080/// # .https_only()
15081/// # .enable_http2()
15082/// # .build();
15083///
15084/// # let executor = hyper_util::rt::TokioExecutor::new();
15085/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15086/// # secret,
15087/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15088/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15089/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15090/// # ),
15091/// # ).build().await.unwrap();
15092///
15093/// # let client = hyper_util::client::legacy::Client::builder(
15094/// # hyper_util::rt::TokioExecutor::new()
15095/// # )
15096/// # .build(
15097/// # hyper_rustls::HttpsConnectorBuilder::new()
15098/// # .with_native_roots()
15099/// # .unwrap()
15100/// # .https_or_http()
15101/// # .enable_http2()
15102/// # .build()
15103/// # );
15104/// # let mut hub = DriveHub::new(client, auth);
15105/// // You can configure optional parameters by calling the respective setters at will, and
15106/// // execute the final call using `doit()`.
15107/// // Values shown here are possibly random and not representative !
15108/// let result = hub.files().get("fileId")
15109/// .supports_team_drives(true)
15110/// .supports_all_drives(true)
15111/// .include_permissions_for_view("accusam")
15112/// .include_labels("gubergren")
15113/// .acknowledge_abuse(true)
15114/// .doit().await;
15115/// # }
15116/// ```
15117pub struct FileGetCall<'a, C>
15118where
15119 C: 'a,
15120{
15121 hub: &'a DriveHub<C>,
15122 _file_id: String,
15123 _supports_team_drives: Option<bool>,
15124 _supports_all_drives: Option<bool>,
15125 _include_permissions_for_view: Option<String>,
15126 _include_labels: Option<String>,
15127 _acknowledge_abuse: Option<bool>,
15128 _delegate: Option<&'a mut dyn common::Delegate>,
15129 _additional_params: HashMap<String, String>,
15130 _scopes: BTreeSet<String>,
15131}
15132
15133impl<'a, C> common::CallBuilder for FileGetCall<'a, C> {}
15134
15135impl<'a, C> FileGetCall<'a, C>
15136where
15137 C: common::Connector,
15138{
15139 /// Perform the operation you have build so far.
15140 pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
15141 use std::borrow::Cow;
15142 use std::io::{Read, Seek};
15143
15144 use common::{url::Params, ToParts};
15145 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15146
15147 let mut dd = common::DefaultDelegate;
15148 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15149 dlg.begin(common::MethodInfo {
15150 id: "drive.files.get",
15151 http_method: hyper::Method::GET,
15152 });
15153
15154 for &field in [
15155 "fileId",
15156 "supportsTeamDrives",
15157 "supportsAllDrives",
15158 "includePermissionsForView",
15159 "includeLabels",
15160 "acknowledgeAbuse",
15161 ]
15162 .iter()
15163 {
15164 if self._additional_params.contains_key(field) {
15165 dlg.finished(false);
15166 return Err(common::Error::FieldClash(field));
15167 }
15168 }
15169
15170 let mut params = Params::with_capacity(7 + self._additional_params.len());
15171 params.push("fileId", self._file_id);
15172 if let Some(value) = self._supports_team_drives.as_ref() {
15173 params.push("supportsTeamDrives", value.to_string());
15174 }
15175 if let Some(value) = self._supports_all_drives.as_ref() {
15176 params.push("supportsAllDrives", value.to_string());
15177 }
15178 if let Some(value) = self._include_permissions_for_view.as_ref() {
15179 params.push("includePermissionsForView", value);
15180 }
15181 if let Some(value) = self._include_labels.as_ref() {
15182 params.push("includeLabels", value);
15183 }
15184 if let Some(value) = self._acknowledge_abuse.as_ref() {
15185 params.push("acknowledgeAbuse", value.to_string());
15186 }
15187
15188 params.extend(self._additional_params.iter());
15189
15190 let (alt_field_missing, enable_resource_parsing) = {
15191 if let Some(value) = params.get("alt") {
15192 (false, value == "json")
15193 } else {
15194 (true, true)
15195 }
15196 };
15197 if alt_field_missing {
15198 params.push("alt", "json");
15199 }
15200 let mut url = self.hub._base_url.clone() + "files/{fileId}";
15201 if self._scopes.is_empty() {
15202 self._scopes
15203 .insert(Scope::MeetReadonly.as_ref().to_string());
15204 }
15205
15206 #[allow(clippy::single_element_loop)]
15207 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
15208 url = params.uri_replacement(url, param_name, find_this, false);
15209 }
15210 {
15211 let to_remove = ["fileId"];
15212 params.remove_params(&to_remove);
15213 }
15214
15215 let url = params.parse_with_url(&url);
15216
15217 loop {
15218 let token = match self
15219 .hub
15220 .auth
15221 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15222 .await
15223 {
15224 Ok(token) => token,
15225 Err(e) => match dlg.token(e) {
15226 Ok(token) => token,
15227 Err(e) => {
15228 dlg.finished(false);
15229 return Err(common::Error::MissingToken(e));
15230 }
15231 },
15232 };
15233 let mut req_result = {
15234 let client = &self.hub.client;
15235 dlg.pre_request();
15236 let mut req_builder = hyper::Request::builder()
15237 .method(hyper::Method::GET)
15238 .uri(url.as_str())
15239 .header(USER_AGENT, self.hub._user_agent.clone());
15240
15241 if let Some(token) = token.as_ref() {
15242 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15243 }
15244
15245 let request = req_builder
15246 .header(CONTENT_LENGTH, 0_u64)
15247 .body(common::to_body::<String>(None));
15248
15249 client.request(request.unwrap()).await
15250 };
15251
15252 match req_result {
15253 Err(err) => {
15254 if let common::Retry::After(d) = dlg.http_error(&err) {
15255 sleep(d).await;
15256 continue;
15257 }
15258 dlg.finished(false);
15259 return Err(common::Error::HttpError(err));
15260 }
15261 Ok(res) => {
15262 let (mut parts, body) = res.into_parts();
15263 let mut body = common::Body::new(body);
15264 if !parts.status.is_success() {
15265 let bytes = common::to_bytes(body).await.unwrap_or_default();
15266 let error = serde_json::from_str(&common::to_string(&bytes));
15267 let response = common::to_response(parts, bytes.into());
15268
15269 if let common::Retry::After(d) =
15270 dlg.http_failure(&response, error.as_ref().ok())
15271 {
15272 sleep(d).await;
15273 continue;
15274 }
15275
15276 dlg.finished(false);
15277
15278 return Err(match error {
15279 Ok(value) => common::Error::BadRequest(value),
15280 _ => common::Error::Failure(response),
15281 });
15282 }
15283 let response = if enable_resource_parsing {
15284 let bytes = common::to_bytes(body).await.unwrap_or_default();
15285 let encoded = common::to_string(&bytes);
15286 match serde_json::from_str(&encoded) {
15287 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15288 Err(error) => {
15289 dlg.response_json_decode_error(&encoded, &error);
15290 return Err(common::Error::JsonDecodeError(
15291 encoded.to_string(),
15292 error,
15293 ));
15294 }
15295 }
15296 } else {
15297 (
15298 common::Response::from_parts(parts, body),
15299 Default::default(),
15300 )
15301 };
15302
15303 dlg.finished(true);
15304 return Ok(response);
15305 }
15306 }
15307 }
15308 }
15309
15310 /// The ID of the file.
15311 ///
15312 /// Sets the *file id* path property to the given value.
15313 ///
15314 /// Even though the property as already been set when instantiating this call,
15315 /// we provide this method for API completeness.
15316 pub fn file_id(mut self, new_value: &str) -> FileGetCall<'a, C> {
15317 self._file_id = new_value.to_string();
15318 self
15319 }
15320 /// Deprecated: Use `supportsAllDrives` instead.
15321 ///
15322 /// Sets the *supports team drives* query property to the given value.
15323 pub fn supports_team_drives(mut self, new_value: bool) -> FileGetCall<'a, C> {
15324 self._supports_team_drives = Some(new_value);
15325 self
15326 }
15327 /// Whether the requesting application supports both My Drives and shared drives.
15328 ///
15329 /// Sets the *supports all drives* query property to the given value.
15330 pub fn supports_all_drives(mut self, new_value: bool) -> FileGetCall<'a, C> {
15331 self._supports_all_drives = Some(new_value);
15332 self
15333 }
15334 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
15335 ///
15336 /// Sets the *include permissions for view* query property to the given value.
15337 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileGetCall<'a, C> {
15338 self._include_permissions_for_view = Some(new_value.to_string());
15339 self
15340 }
15341 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
15342 ///
15343 /// Sets the *include labels* query property to the given value.
15344 pub fn include_labels(mut self, new_value: &str) -> FileGetCall<'a, C> {
15345 self._include_labels = Some(new_value.to_string());
15346 self
15347 }
15348 /// 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.
15349 ///
15350 /// Sets the *acknowledge abuse* query property to the given value.
15351 pub fn acknowledge_abuse(mut self, new_value: bool) -> FileGetCall<'a, C> {
15352 self._acknowledge_abuse = Some(new_value);
15353 self
15354 }
15355 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15356 /// while executing the actual API request.
15357 ///
15358 /// ````text
15359 /// It should be used to handle progress information, and to implement a certain level of resilience.
15360 /// ````
15361 ///
15362 /// Sets the *delegate* property to the given value.
15363 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileGetCall<'a, C> {
15364 self._delegate = Some(new_value);
15365 self
15366 }
15367
15368 /// Set any additional parameter of the query string used in the request.
15369 /// It should be used to set parameters which are not yet available through their own
15370 /// setters.
15371 ///
15372 /// Please note that this method must not be used to set any of the known parameters
15373 /// which have their own setter method. If done anyway, the request will fail.
15374 ///
15375 /// # Additional Parameters
15376 ///
15377 /// * *$.xgafv* (query-string) - V1 error format.
15378 /// * *access_token* (query-string) - OAuth access token.
15379 /// * *alt* (query-string) - Data format for response.
15380 /// * *callback* (query-string) - JSONP
15381 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15382 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15383 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15384 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15385 /// * *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.
15386 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15387 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15388 pub fn param<T>(mut self, name: T, value: T) -> FileGetCall<'a, C>
15389 where
15390 T: AsRef<str>,
15391 {
15392 self._additional_params
15393 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15394 self
15395 }
15396
15397 /// Identifies the authorization scope for the method you are building.
15398 ///
15399 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15400 /// [`Scope::MeetReadonly`].
15401 ///
15402 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15403 /// tokens for more than one scope.
15404 ///
15405 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15406 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15407 /// sufficient, a read-write scope will do as well.
15408 pub fn add_scope<St>(mut self, scope: St) -> FileGetCall<'a, C>
15409 where
15410 St: AsRef<str>,
15411 {
15412 self._scopes.insert(String::from(scope.as_ref()));
15413 self
15414 }
15415 /// Identifies the authorization scope(s) for the method you are building.
15416 ///
15417 /// See [`Self::add_scope()`] for details.
15418 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileGetCall<'a, C>
15419 where
15420 I: IntoIterator<Item = St>,
15421 St: AsRef<str>,
15422 {
15423 self._scopes
15424 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15425 self
15426 }
15427
15428 /// Removes all scopes, and no default scope will be used either.
15429 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15430 /// for details).
15431 pub fn clear_scopes(mut self) -> FileGetCall<'a, C> {
15432 self._scopes.clear();
15433 self
15434 }
15435}
15436
15437/// 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.
15438///
15439/// A builder for the *list* method supported by a *file* resource.
15440/// It is not used directly, but through a [`FileMethods`] instance.
15441///
15442/// # Example
15443///
15444/// Instantiate a resource method builder
15445///
15446/// ```test_harness,no_run
15447/// # extern crate hyper;
15448/// # extern crate hyper_rustls;
15449/// # extern crate google_drive3 as drive3;
15450/// # async fn dox() {
15451/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15452///
15453/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15454/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15455/// # .with_native_roots()
15456/// # .unwrap()
15457/// # .https_only()
15458/// # .enable_http2()
15459/// # .build();
15460///
15461/// # let executor = hyper_util::rt::TokioExecutor::new();
15462/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15463/// # secret,
15464/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15465/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15466/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15467/// # ),
15468/// # ).build().await.unwrap();
15469///
15470/// # let client = hyper_util::client::legacy::Client::builder(
15471/// # hyper_util::rt::TokioExecutor::new()
15472/// # )
15473/// # .build(
15474/// # hyper_rustls::HttpsConnectorBuilder::new()
15475/// # .with_native_roots()
15476/// # .unwrap()
15477/// # .https_or_http()
15478/// # .enable_http2()
15479/// # .build()
15480/// # );
15481/// # let mut hub = DriveHub::new(client, auth);
15482/// // You can configure optional parameters by calling the respective setters at will, and
15483/// // execute the final call using `doit()`.
15484/// // Values shown here are possibly random and not representative !
15485/// let result = hub.files().list()
15486/// .team_drive_id("At")
15487/// .supports_team_drives(true)
15488/// .supports_all_drives(true)
15489/// .spaces("magna")
15490/// .q("et")
15491/// .page_token("rebum.")
15492/// .page_size(-4)
15493/// .order_by("Lorem")
15494/// .include_team_drive_items(false)
15495/// .include_permissions_for_view("amet.")
15496/// .include_labels("no")
15497/// .include_items_from_all_drives(false)
15498/// .drive_id("sed")
15499/// .corpus("kasd")
15500/// .corpora("Lorem")
15501/// .doit().await;
15502/// # }
15503/// ```
15504pub struct FileListCall<'a, C>
15505where
15506 C: 'a,
15507{
15508 hub: &'a DriveHub<C>,
15509 _team_drive_id: Option<String>,
15510 _supports_team_drives: Option<bool>,
15511 _supports_all_drives: Option<bool>,
15512 _spaces: Option<String>,
15513 _q: Option<String>,
15514 _page_token: Option<String>,
15515 _page_size: Option<i32>,
15516 _order_by: Option<String>,
15517 _include_team_drive_items: Option<bool>,
15518 _include_permissions_for_view: Option<String>,
15519 _include_labels: Option<String>,
15520 _include_items_from_all_drives: Option<bool>,
15521 _drive_id: Option<String>,
15522 _corpus: Option<String>,
15523 _corpora: Option<String>,
15524 _delegate: Option<&'a mut dyn common::Delegate>,
15525 _additional_params: HashMap<String, String>,
15526 _scopes: BTreeSet<String>,
15527}
15528
15529impl<'a, C> common::CallBuilder for FileListCall<'a, C> {}
15530
15531impl<'a, C> FileListCall<'a, C>
15532where
15533 C: common::Connector,
15534{
15535 /// Perform the operation you have build so far.
15536 pub async fn doit(mut self) -> common::Result<(common::Response, FileList)> {
15537 use std::borrow::Cow;
15538 use std::io::{Read, Seek};
15539
15540 use common::{url::Params, ToParts};
15541 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15542
15543 let mut dd = common::DefaultDelegate;
15544 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15545 dlg.begin(common::MethodInfo {
15546 id: "drive.files.list",
15547 http_method: hyper::Method::GET,
15548 });
15549
15550 for &field in [
15551 "alt",
15552 "teamDriveId",
15553 "supportsTeamDrives",
15554 "supportsAllDrives",
15555 "spaces",
15556 "q",
15557 "pageToken",
15558 "pageSize",
15559 "orderBy",
15560 "includeTeamDriveItems",
15561 "includePermissionsForView",
15562 "includeLabels",
15563 "includeItemsFromAllDrives",
15564 "driveId",
15565 "corpus",
15566 "corpora",
15567 ]
15568 .iter()
15569 {
15570 if self._additional_params.contains_key(field) {
15571 dlg.finished(false);
15572 return Err(common::Error::FieldClash(field));
15573 }
15574 }
15575
15576 let mut params = Params::with_capacity(17 + self._additional_params.len());
15577 if let Some(value) = self._team_drive_id.as_ref() {
15578 params.push("teamDriveId", value);
15579 }
15580 if let Some(value) = self._supports_team_drives.as_ref() {
15581 params.push("supportsTeamDrives", value.to_string());
15582 }
15583 if let Some(value) = self._supports_all_drives.as_ref() {
15584 params.push("supportsAllDrives", value.to_string());
15585 }
15586 if let Some(value) = self._spaces.as_ref() {
15587 params.push("spaces", value);
15588 }
15589 if let Some(value) = self._q.as_ref() {
15590 params.push("q", value);
15591 }
15592 if let Some(value) = self._page_token.as_ref() {
15593 params.push("pageToken", value);
15594 }
15595 if let Some(value) = self._page_size.as_ref() {
15596 params.push("pageSize", value.to_string());
15597 }
15598 if let Some(value) = self._order_by.as_ref() {
15599 params.push("orderBy", value);
15600 }
15601 if let Some(value) = self._include_team_drive_items.as_ref() {
15602 params.push("includeTeamDriveItems", value.to_string());
15603 }
15604 if let Some(value) = self._include_permissions_for_view.as_ref() {
15605 params.push("includePermissionsForView", value);
15606 }
15607 if let Some(value) = self._include_labels.as_ref() {
15608 params.push("includeLabels", value);
15609 }
15610 if let Some(value) = self._include_items_from_all_drives.as_ref() {
15611 params.push("includeItemsFromAllDrives", value.to_string());
15612 }
15613 if let Some(value) = self._drive_id.as_ref() {
15614 params.push("driveId", value);
15615 }
15616 if let Some(value) = self._corpus.as_ref() {
15617 params.push("corpus", value);
15618 }
15619 if let Some(value) = self._corpora.as_ref() {
15620 params.push("corpora", value);
15621 }
15622
15623 params.extend(self._additional_params.iter());
15624
15625 params.push("alt", "json");
15626 let mut url = self.hub._base_url.clone() + "files";
15627 if self._scopes.is_empty() {
15628 self._scopes
15629 .insert(Scope::MeetReadonly.as_ref().to_string());
15630 }
15631
15632 let url = params.parse_with_url(&url);
15633
15634 loop {
15635 let token = match self
15636 .hub
15637 .auth
15638 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15639 .await
15640 {
15641 Ok(token) => token,
15642 Err(e) => match dlg.token(e) {
15643 Ok(token) => token,
15644 Err(e) => {
15645 dlg.finished(false);
15646 return Err(common::Error::MissingToken(e));
15647 }
15648 },
15649 };
15650 let mut req_result = {
15651 let client = &self.hub.client;
15652 dlg.pre_request();
15653 let mut req_builder = hyper::Request::builder()
15654 .method(hyper::Method::GET)
15655 .uri(url.as_str())
15656 .header(USER_AGENT, self.hub._user_agent.clone());
15657
15658 if let Some(token) = token.as_ref() {
15659 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15660 }
15661
15662 let request = req_builder
15663 .header(CONTENT_LENGTH, 0_u64)
15664 .body(common::to_body::<String>(None));
15665
15666 client.request(request.unwrap()).await
15667 };
15668
15669 match req_result {
15670 Err(err) => {
15671 if let common::Retry::After(d) = dlg.http_error(&err) {
15672 sleep(d).await;
15673 continue;
15674 }
15675 dlg.finished(false);
15676 return Err(common::Error::HttpError(err));
15677 }
15678 Ok(res) => {
15679 let (mut parts, body) = res.into_parts();
15680 let mut body = common::Body::new(body);
15681 if !parts.status.is_success() {
15682 let bytes = common::to_bytes(body).await.unwrap_or_default();
15683 let error = serde_json::from_str(&common::to_string(&bytes));
15684 let response = common::to_response(parts, bytes.into());
15685
15686 if let common::Retry::After(d) =
15687 dlg.http_failure(&response, error.as_ref().ok())
15688 {
15689 sleep(d).await;
15690 continue;
15691 }
15692
15693 dlg.finished(false);
15694
15695 return Err(match error {
15696 Ok(value) => common::Error::BadRequest(value),
15697 _ => common::Error::Failure(response),
15698 });
15699 }
15700 let response = {
15701 let bytes = common::to_bytes(body).await.unwrap_or_default();
15702 let encoded = common::to_string(&bytes);
15703 match serde_json::from_str(&encoded) {
15704 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15705 Err(error) => {
15706 dlg.response_json_decode_error(&encoded, &error);
15707 return Err(common::Error::JsonDecodeError(
15708 encoded.to_string(),
15709 error,
15710 ));
15711 }
15712 }
15713 };
15714
15715 dlg.finished(true);
15716 return Ok(response);
15717 }
15718 }
15719 }
15720 }
15721
15722 /// Deprecated: Use `driveId` instead.
15723 ///
15724 /// Sets the *team drive id* query property to the given value.
15725 pub fn team_drive_id(mut self, new_value: &str) -> FileListCall<'a, C> {
15726 self._team_drive_id = Some(new_value.to_string());
15727 self
15728 }
15729 /// Deprecated: Use `supportsAllDrives` instead.
15730 ///
15731 /// Sets the *supports team drives* query property to the given value.
15732 pub fn supports_team_drives(mut self, new_value: bool) -> FileListCall<'a, C> {
15733 self._supports_team_drives = Some(new_value);
15734 self
15735 }
15736 /// Whether the requesting application supports both My Drives and shared drives.
15737 ///
15738 /// Sets the *supports all drives* query property to the given value.
15739 pub fn supports_all_drives(mut self, new_value: bool) -> FileListCall<'a, C> {
15740 self._supports_all_drives = Some(new_value);
15741 self
15742 }
15743 /// A comma-separated list of spaces to query within the corpora. Supported values are `drive` and `appDataFolder`. For more information, see [File organization](https://developers.google.com/workspace/drive/api/guides/about-files#file-organization).
15744 ///
15745 /// Sets the *spaces* query property to the given value.
15746 pub fn spaces(mut self, new_value: &str) -> FileListCall<'a, C> {
15747 self._spaces = Some(new_value.to_string());
15748 self
15749 }
15750 /// A query for filtering the file results. For supported syntax, see [Search for files and folders](https://developers.google.com/workspace/drive/api/guides/search-files).
15751 ///
15752 /// Sets the *q* query property to the given value.
15753 pub fn q(mut self, new_value: &str) -> FileListCall<'a, C> {
15754 self._q = Some(new_value.to_string());
15755 self
15756 }
15757 /// 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.
15758 ///
15759 /// Sets the *page token* query property to the given value.
15760 pub fn page_token(mut self, new_value: &str) -> FileListCall<'a, C> {
15761 self._page_token = Some(new_value.to_string());
15762 self
15763 }
15764 /// 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.
15765 ///
15766 /// Sets the *page size* query property to the given value.
15767 pub fn page_size(mut self, new_value: i32) -> FileListCall<'a, C> {
15768 self._page_size = Some(new_value);
15769 self
15770 }
15771 /// A comma-separated list of sort keys. Valid keys are: * `createdTime`: When the file was created. * `folder`: The folder ID. This field is sorted using alphabetical ordering. * `modifiedByMeTime`: The last time the file was modified by the user. * `modifiedTime`: The last time the file was modified by anyone. * `name`: The name of the file. This field is sorted using alphabetical ordering, so 1, 12, 2, 22. * `name_natural`: The name of the file. This field is sorted using natural sort ordering, so 1, 2, 12, 22. * `quotaBytesUsed`: The number of storage quota bytes used by the file. * `recency`: The most recent timestamp from the file's date-time fields. * `sharedWithMeTime`: When the file was shared with the user, if applicable. * `starred`: Whether the user has starred the file. * `viewedByMeTime`: The last time the file was viewed by the user. Each key sorts ascending by default, but can be reversed with the `desc` modifier. Example usage: `?orderBy=folder,modifiedTime desc,name`.
15772 ///
15773 /// Sets the *order by* query property to the given value.
15774 pub fn order_by(mut self, new_value: &str) -> FileListCall<'a, C> {
15775 self._order_by = Some(new_value.to_string());
15776 self
15777 }
15778 /// Deprecated: Use `includeItemsFromAllDrives` instead.
15779 ///
15780 /// Sets the *include team drive items* query property to the given value.
15781 pub fn include_team_drive_items(mut self, new_value: bool) -> FileListCall<'a, C> {
15782 self._include_team_drive_items = Some(new_value);
15783 self
15784 }
15785 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
15786 ///
15787 /// Sets the *include permissions for view* query property to the given value.
15788 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileListCall<'a, C> {
15789 self._include_permissions_for_view = Some(new_value.to_string());
15790 self
15791 }
15792 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
15793 ///
15794 /// Sets the *include labels* query property to the given value.
15795 pub fn include_labels(mut self, new_value: &str) -> FileListCall<'a, C> {
15796 self._include_labels = Some(new_value.to_string());
15797 self
15798 }
15799 /// Whether both My Drive and shared drive items should be included in results.
15800 ///
15801 /// Sets the *include items from all drives* query property to the given value.
15802 pub fn include_items_from_all_drives(mut self, new_value: bool) -> FileListCall<'a, C> {
15803 self._include_items_from_all_drives = Some(new_value);
15804 self
15805 }
15806 /// ID of the shared drive to search.
15807 ///
15808 /// Sets the *drive id* query property to the given value.
15809 pub fn drive_id(mut self, new_value: &str) -> FileListCall<'a, C> {
15810 self._drive_id = Some(new_value.to_string());
15811 self
15812 }
15813 /// Deprecated: The source of files to list. Use `corpora` instead.
15814 ///
15815 /// Sets the *corpus* query property to the given value.
15816 pub fn corpus(mut self, new_value: &str) -> FileListCall<'a, C> {
15817 self._corpus = Some(new_value.to_string());
15818 self
15819 }
15820 /// Bodies of items (files or documents) to which the query applies. Supported bodies are: * `user` * `domain` * `drive` * `allDrives` Prefer `user` or `drive` to `allDrives` for efficiency. By default, corpora is set to `user`. However, this can change depending on the filter set through the `q` parameter. For more information, see [File organization](https://developers.google.com/workspace/drive/api/guides/about-files#file-organization).
15821 ///
15822 /// Sets the *corpora* query property to the given value.
15823 pub fn corpora(mut self, new_value: &str) -> FileListCall<'a, C> {
15824 self._corpora = Some(new_value.to_string());
15825 self
15826 }
15827 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15828 /// while executing the actual API request.
15829 ///
15830 /// ````text
15831 /// It should be used to handle progress information, and to implement a certain level of resilience.
15832 /// ````
15833 ///
15834 /// Sets the *delegate* property to the given value.
15835 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileListCall<'a, C> {
15836 self._delegate = Some(new_value);
15837 self
15838 }
15839
15840 /// Set any additional parameter of the query string used in the request.
15841 /// It should be used to set parameters which are not yet available through their own
15842 /// setters.
15843 ///
15844 /// Please note that this method must not be used to set any of the known parameters
15845 /// which have their own setter method. If done anyway, the request will fail.
15846 ///
15847 /// # Additional Parameters
15848 ///
15849 /// * *$.xgafv* (query-string) - V1 error format.
15850 /// * *access_token* (query-string) - OAuth access token.
15851 /// * *alt* (query-string) - Data format for response.
15852 /// * *callback* (query-string) - JSONP
15853 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15854 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15855 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15856 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15857 /// * *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.
15858 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15859 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15860 pub fn param<T>(mut self, name: T, value: T) -> FileListCall<'a, C>
15861 where
15862 T: AsRef<str>,
15863 {
15864 self._additional_params
15865 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15866 self
15867 }
15868
15869 /// Identifies the authorization scope for the method you are building.
15870 ///
15871 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15872 /// [`Scope::MeetReadonly`].
15873 ///
15874 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15875 /// tokens for more than one scope.
15876 ///
15877 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15878 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15879 /// sufficient, a read-write scope will do as well.
15880 pub fn add_scope<St>(mut self, scope: St) -> FileListCall<'a, C>
15881 where
15882 St: AsRef<str>,
15883 {
15884 self._scopes.insert(String::from(scope.as_ref()));
15885 self
15886 }
15887 /// Identifies the authorization scope(s) for the method you are building.
15888 ///
15889 /// See [`Self::add_scope()`] for details.
15890 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileListCall<'a, C>
15891 where
15892 I: IntoIterator<Item = St>,
15893 St: AsRef<str>,
15894 {
15895 self._scopes
15896 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15897 self
15898 }
15899
15900 /// Removes all scopes, and no default scope will be used either.
15901 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15902 /// for details).
15903 pub fn clear_scopes(mut self) -> FileListCall<'a, C> {
15904 self._scopes.clear();
15905 self
15906 }
15907}
15908
15909/// Lists the labels on a file. For more information, see [List labels on a file](https://developers.google.com/workspace/drive/api/guides/list-labels).
15910///
15911/// A builder for the *listLabels* method supported by a *file* resource.
15912/// It is not used directly, but through a [`FileMethods`] instance.
15913///
15914/// # Example
15915///
15916/// Instantiate a resource method builder
15917///
15918/// ```test_harness,no_run
15919/// # extern crate hyper;
15920/// # extern crate hyper_rustls;
15921/// # extern crate google_drive3 as drive3;
15922/// # async fn dox() {
15923/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15924///
15925/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15926/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15927/// # .with_native_roots()
15928/// # .unwrap()
15929/// # .https_only()
15930/// # .enable_http2()
15931/// # .build();
15932///
15933/// # let executor = hyper_util::rt::TokioExecutor::new();
15934/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15935/// # secret,
15936/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15937/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15938/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15939/// # ),
15940/// # ).build().await.unwrap();
15941///
15942/// # let client = hyper_util::client::legacy::Client::builder(
15943/// # hyper_util::rt::TokioExecutor::new()
15944/// # )
15945/// # .build(
15946/// # hyper_rustls::HttpsConnectorBuilder::new()
15947/// # .with_native_roots()
15948/// # .unwrap()
15949/// # .https_or_http()
15950/// # .enable_http2()
15951/// # .build()
15952/// # );
15953/// # let mut hub = DriveHub::new(client, auth);
15954/// // You can configure optional parameters by calling the respective setters at will, and
15955/// // execute the final call using `doit()`.
15956/// // Values shown here are possibly random and not representative !
15957/// let result = hub.files().list_labels("fileId")
15958/// .page_token("nonumy")
15959/// .max_results(-66)
15960/// .doit().await;
15961/// # }
15962/// ```
15963pub struct FileListLabelCall<'a, C>
15964where
15965 C: 'a,
15966{
15967 hub: &'a DriveHub<C>,
15968 _file_id: String,
15969 _page_token: Option<String>,
15970 _max_results: Option<i32>,
15971 _delegate: Option<&'a mut dyn common::Delegate>,
15972 _additional_params: HashMap<String, String>,
15973 _scopes: BTreeSet<String>,
15974}
15975
15976impl<'a, C> common::CallBuilder for FileListLabelCall<'a, C> {}
15977
15978impl<'a, C> FileListLabelCall<'a, C>
15979where
15980 C: common::Connector,
15981{
15982 /// Perform the operation you have build so far.
15983 pub async fn doit(mut self) -> common::Result<(common::Response, LabelList)> {
15984 use std::borrow::Cow;
15985 use std::io::{Read, Seek};
15986
15987 use common::{url::Params, ToParts};
15988 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15989
15990 let mut dd = common::DefaultDelegate;
15991 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15992 dlg.begin(common::MethodInfo {
15993 id: "drive.files.listLabels",
15994 http_method: hyper::Method::GET,
15995 });
15996
15997 for &field in ["alt", "fileId", "pageToken", "maxResults"].iter() {
15998 if self._additional_params.contains_key(field) {
15999 dlg.finished(false);
16000 return Err(common::Error::FieldClash(field));
16001 }
16002 }
16003
16004 let mut params = Params::with_capacity(5 + self._additional_params.len());
16005 params.push("fileId", self._file_id);
16006 if let Some(value) = self._page_token.as_ref() {
16007 params.push("pageToken", value);
16008 }
16009 if let Some(value) = self._max_results.as_ref() {
16010 params.push("maxResults", value.to_string());
16011 }
16012
16013 params.extend(self._additional_params.iter());
16014
16015 params.push("alt", "json");
16016 let mut url = self.hub._base_url.clone() + "files/{fileId}/listLabels";
16017 if self._scopes.is_empty() {
16018 self._scopes
16019 .insert(Scope::MeetReadonly.as_ref().to_string());
16020 }
16021
16022 #[allow(clippy::single_element_loop)]
16023 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
16024 url = params.uri_replacement(url, param_name, find_this, false);
16025 }
16026 {
16027 let to_remove = ["fileId"];
16028 params.remove_params(&to_remove);
16029 }
16030
16031 let url = params.parse_with_url(&url);
16032
16033 loop {
16034 let token = match self
16035 .hub
16036 .auth
16037 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16038 .await
16039 {
16040 Ok(token) => token,
16041 Err(e) => match dlg.token(e) {
16042 Ok(token) => token,
16043 Err(e) => {
16044 dlg.finished(false);
16045 return Err(common::Error::MissingToken(e));
16046 }
16047 },
16048 };
16049 let mut req_result = {
16050 let client = &self.hub.client;
16051 dlg.pre_request();
16052 let mut req_builder = hyper::Request::builder()
16053 .method(hyper::Method::GET)
16054 .uri(url.as_str())
16055 .header(USER_AGENT, self.hub._user_agent.clone());
16056
16057 if let Some(token) = token.as_ref() {
16058 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16059 }
16060
16061 let request = req_builder
16062 .header(CONTENT_LENGTH, 0_u64)
16063 .body(common::to_body::<String>(None));
16064
16065 client.request(request.unwrap()).await
16066 };
16067
16068 match req_result {
16069 Err(err) => {
16070 if let common::Retry::After(d) = dlg.http_error(&err) {
16071 sleep(d).await;
16072 continue;
16073 }
16074 dlg.finished(false);
16075 return Err(common::Error::HttpError(err));
16076 }
16077 Ok(res) => {
16078 let (mut parts, body) = res.into_parts();
16079 let mut body = common::Body::new(body);
16080 if !parts.status.is_success() {
16081 let bytes = common::to_bytes(body).await.unwrap_or_default();
16082 let error = serde_json::from_str(&common::to_string(&bytes));
16083 let response = common::to_response(parts, bytes.into());
16084
16085 if let common::Retry::After(d) =
16086 dlg.http_failure(&response, error.as_ref().ok())
16087 {
16088 sleep(d).await;
16089 continue;
16090 }
16091
16092 dlg.finished(false);
16093
16094 return Err(match error {
16095 Ok(value) => common::Error::BadRequest(value),
16096 _ => common::Error::Failure(response),
16097 });
16098 }
16099 let response = {
16100 let bytes = common::to_bytes(body).await.unwrap_or_default();
16101 let encoded = common::to_string(&bytes);
16102 match serde_json::from_str(&encoded) {
16103 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16104 Err(error) => {
16105 dlg.response_json_decode_error(&encoded, &error);
16106 return Err(common::Error::JsonDecodeError(
16107 encoded.to_string(),
16108 error,
16109 ));
16110 }
16111 }
16112 };
16113
16114 dlg.finished(true);
16115 return Ok(response);
16116 }
16117 }
16118 }
16119 }
16120
16121 /// The ID for the file.
16122 ///
16123 /// Sets the *file id* path property to the given value.
16124 ///
16125 /// Even though the property as already been set when instantiating this call,
16126 /// we provide this method for API completeness.
16127 pub fn file_id(mut self, new_value: &str) -> FileListLabelCall<'a, C> {
16128 self._file_id = new_value.to_string();
16129 self
16130 }
16131 /// 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.
16132 ///
16133 /// Sets the *page token* query property to the given value.
16134 pub fn page_token(mut self, new_value: &str) -> FileListLabelCall<'a, C> {
16135 self._page_token = Some(new_value.to_string());
16136 self
16137 }
16138 /// The maximum number of labels to return per page. When not set, defaults to 100.
16139 ///
16140 /// Sets the *max results* query property to the given value.
16141 pub fn max_results(mut self, new_value: i32) -> FileListLabelCall<'a, C> {
16142 self._max_results = Some(new_value);
16143 self
16144 }
16145 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16146 /// while executing the actual API request.
16147 ///
16148 /// ````text
16149 /// It should be used to handle progress information, and to implement a certain level of resilience.
16150 /// ````
16151 ///
16152 /// Sets the *delegate* property to the given value.
16153 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileListLabelCall<'a, C> {
16154 self._delegate = Some(new_value);
16155 self
16156 }
16157
16158 /// Set any additional parameter of the query string used in the request.
16159 /// It should be used to set parameters which are not yet available through their own
16160 /// setters.
16161 ///
16162 /// Please note that this method must not be used to set any of the known parameters
16163 /// which have their own setter method. If done anyway, the request will fail.
16164 ///
16165 /// # Additional Parameters
16166 ///
16167 /// * *$.xgafv* (query-string) - V1 error format.
16168 /// * *access_token* (query-string) - OAuth access token.
16169 /// * *alt* (query-string) - Data format for response.
16170 /// * *callback* (query-string) - JSONP
16171 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16172 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16173 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16174 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16175 /// * *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.
16176 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16177 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16178 pub fn param<T>(mut self, name: T, value: T) -> FileListLabelCall<'a, C>
16179 where
16180 T: AsRef<str>,
16181 {
16182 self._additional_params
16183 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16184 self
16185 }
16186
16187 /// Identifies the authorization scope for the method you are building.
16188 ///
16189 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16190 /// [`Scope::MeetReadonly`].
16191 ///
16192 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16193 /// tokens for more than one scope.
16194 ///
16195 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16196 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16197 /// sufficient, a read-write scope will do as well.
16198 pub fn add_scope<St>(mut self, scope: St) -> FileListLabelCall<'a, C>
16199 where
16200 St: AsRef<str>,
16201 {
16202 self._scopes.insert(String::from(scope.as_ref()));
16203 self
16204 }
16205 /// Identifies the authorization scope(s) for the method you are building.
16206 ///
16207 /// See [`Self::add_scope()`] for details.
16208 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileListLabelCall<'a, C>
16209 where
16210 I: IntoIterator<Item = St>,
16211 St: AsRef<str>,
16212 {
16213 self._scopes
16214 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16215 self
16216 }
16217
16218 /// Removes all scopes, and no default scope will be used either.
16219 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16220 /// for details).
16221 pub fn clear_scopes(mut self) -> FileListLabelCall<'a, C> {
16222 self._scopes.clear();
16223 self
16224 }
16225}
16226
16227/// Modifies the set of labels applied to a file. For more information, see [Set a label field on a file](https://developers.google.com/workspace/drive/api/guides/set-label). Returns a list of the labels that were added or modified.
16228///
16229/// A builder for the *modifyLabels* method supported by a *file* resource.
16230/// It is not used directly, but through a [`FileMethods`] instance.
16231///
16232/// # Example
16233///
16234/// Instantiate a resource method builder
16235///
16236/// ```test_harness,no_run
16237/// # extern crate hyper;
16238/// # extern crate hyper_rustls;
16239/// # extern crate google_drive3 as drive3;
16240/// use drive3::api::ModifyLabelsRequest;
16241/// # async fn dox() {
16242/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16243///
16244/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16245/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16246/// # .with_native_roots()
16247/// # .unwrap()
16248/// # .https_only()
16249/// # .enable_http2()
16250/// # .build();
16251///
16252/// # let executor = hyper_util::rt::TokioExecutor::new();
16253/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16254/// # secret,
16255/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16256/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16257/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16258/// # ),
16259/// # ).build().await.unwrap();
16260///
16261/// # let client = hyper_util::client::legacy::Client::builder(
16262/// # hyper_util::rt::TokioExecutor::new()
16263/// # )
16264/// # .build(
16265/// # hyper_rustls::HttpsConnectorBuilder::new()
16266/// # .with_native_roots()
16267/// # .unwrap()
16268/// # .https_or_http()
16269/// # .enable_http2()
16270/// # .build()
16271/// # );
16272/// # let mut hub = DriveHub::new(client, auth);
16273/// // As the method needs a request, you would usually fill it with the desired information
16274/// // into the respective structure. Some of the parts shown here might not be applicable !
16275/// // Values shown here are possibly random and not representative !
16276/// let mut req = ModifyLabelsRequest::default();
16277///
16278/// // You can configure optional parameters by calling the respective setters at will, and
16279/// // execute the final call using `doit()`.
16280/// // Values shown here are possibly random and not representative !
16281/// let result = hub.files().modify_labels(req, "fileId")
16282/// .doit().await;
16283/// # }
16284/// ```
16285pub struct FileModifyLabelCall<'a, C>
16286where
16287 C: 'a,
16288{
16289 hub: &'a DriveHub<C>,
16290 _request: ModifyLabelsRequest,
16291 _file_id: String,
16292 _delegate: Option<&'a mut dyn common::Delegate>,
16293 _additional_params: HashMap<String, String>,
16294 _scopes: BTreeSet<String>,
16295}
16296
16297impl<'a, C> common::CallBuilder for FileModifyLabelCall<'a, C> {}
16298
16299impl<'a, C> FileModifyLabelCall<'a, C>
16300where
16301 C: common::Connector,
16302{
16303 /// Perform the operation you have build so far.
16304 pub async fn doit(mut self) -> common::Result<(common::Response, ModifyLabelsResponse)> {
16305 use std::borrow::Cow;
16306 use std::io::{Read, Seek};
16307
16308 use common::{url::Params, ToParts};
16309 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16310
16311 let mut dd = common::DefaultDelegate;
16312 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16313 dlg.begin(common::MethodInfo {
16314 id: "drive.files.modifyLabels",
16315 http_method: hyper::Method::POST,
16316 });
16317
16318 for &field in ["alt", "fileId"].iter() {
16319 if self._additional_params.contains_key(field) {
16320 dlg.finished(false);
16321 return Err(common::Error::FieldClash(field));
16322 }
16323 }
16324
16325 let mut params = Params::with_capacity(4 + self._additional_params.len());
16326 params.push("fileId", self._file_id);
16327
16328 params.extend(self._additional_params.iter());
16329
16330 params.push("alt", "json");
16331 let mut url = self.hub._base_url.clone() + "files/{fileId}/modifyLabels";
16332 if self._scopes.is_empty() {
16333 self._scopes.insert(Scope::Full.as_ref().to_string());
16334 }
16335
16336 #[allow(clippy::single_element_loop)]
16337 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
16338 url = params.uri_replacement(url, param_name, find_this, false);
16339 }
16340 {
16341 let to_remove = ["fileId"];
16342 params.remove_params(&to_remove);
16343 }
16344
16345 let url = params.parse_with_url(&url);
16346
16347 let mut json_mime_type = mime::APPLICATION_JSON;
16348 let mut request_value_reader = {
16349 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16350 common::remove_json_null_values(&mut value);
16351 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16352 serde_json::to_writer(&mut dst, &value).unwrap();
16353 dst
16354 };
16355 let request_size = request_value_reader
16356 .seek(std::io::SeekFrom::End(0))
16357 .unwrap();
16358 request_value_reader
16359 .seek(std::io::SeekFrom::Start(0))
16360 .unwrap();
16361
16362 loop {
16363 let token = match self
16364 .hub
16365 .auth
16366 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16367 .await
16368 {
16369 Ok(token) => token,
16370 Err(e) => match dlg.token(e) {
16371 Ok(token) => token,
16372 Err(e) => {
16373 dlg.finished(false);
16374 return Err(common::Error::MissingToken(e));
16375 }
16376 },
16377 };
16378 request_value_reader
16379 .seek(std::io::SeekFrom::Start(0))
16380 .unwrap();
16381 let mut req_result = {
16382 let client = &self.hub.client;
16383 dlg.pre_request();
16384 let mut req_builder = hyper::Request::builder()
16385 .method(hyper::Method::POST)
16386 .uri(url.as_str())
16387 .header(USER_AGENT, self.hub._user_agent.clone());
16388
16389 if let Some(token) = token.as_ref() {
16390 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16391 }
16392
16393 let request = req_builder
16394 .header(CONTENT_TYPE, json_mime_type.to_string())
16395 .header(CONTENT_LENGTH, request_size as u64)
16396 .body(common::to_body(
16397 request_value_reader.get_ref().clone().into(),
16398 ));
16399
16400 client.request(request.unwrap()).await
16401 };
16402
16403 match req_result {
16404 Err(err) => {
16405 if let common::Retry::After(d) = dlg.http_error(&err) {
16406 sleep(d).await;
16407 continue;
16408 }
16409 dlg.finished(false);
16410 return Err(common::Error::HttpError(err));
16411 }
16412 Ok(res) => {
16413 let (mut parts, body) = res.into_parts();
16414 let mut body = common::Body::new(body);
16415 if !parts.status.is_success() {
16416 let bytes = common::to_bytes(body).await.unwrap_or_default();
16417 let error = serde_json::from_str(&common::to_string(&bytes));
16418 let response = common::to_response(parts, bytes.into());
16419
16420 if let common::Retry::After(d) =
16421 dlg.http_failure(&response, error.as_ref().ok())
16422 {
16423 sleep(d).await;
16424 continue;
16425 }
16426
16427 dlg.finished(false);
16428
16429 return Err(match error {
16430 Ok(value) => common::Error::BadRequest(value),
16431 _ => common::Error::Failure(response),
16432 });
16433 }
16434 let response = {
16435 let bytes = common::to_bytes(body).await.unwrap_or_default();
16436 let encoded = common::to_string(&bytes);
16437 match serde_json::from_str(&encoded) {
16438 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16439 Err(error) => {
16440 dlg.response_json_decode_error(&encoded, &error);
16441 return Err(common::Error::JsonDecodeError(
16442 encoded.to_string(),
16443 error,
16444 ));
16445 }
16446 }
16447 };
16448
16449 dlg.finished(true);
16450 return Ok(response);
16451 }
16452 }
16453 }
16454 }
16455
16456 ///
16457 /// Sets the *request* property to the given value.
16458 ///
16459 /// Even though the property as already been set when instantiating this call,
16460 /// we provide this method for API completeness.
16461 pub fn request(mut self, new_value: ModifyLabelsRequest) -> FileModifyLabelCall<'a, C> {
16462 self._request = new_value;
16463 self
16464 }
16465 /// The ID of the file to which the labels belong.
16466 ///
16467 /// Sets the *file id* path property to the given value.
16468 ///
16469 /// Even though the property as already been set when instantiating this call,
16470 /// we provide this method for API completeness.
16471 pub fn file_id(mut self, new_value: &str) -> FileModifyLabelCall<'a, C> {
16472 self._file_id = new_value.to_string();
16473 self
16474 }
16475 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16476 /// while executing the actual API request.
16477 ///
16478 /// ````text
16479 /// It should be used to handle progress information, and to implement a certain level of resilience.
16480 /// ````
16481 ///
16482 /// Sets the *delegate* property to the given value.
16483 pub fn delegate(
16484 mut self,
16485 new_value: &'a mut dyn common::Delegate,
16486 ) -> FileModifyLabelCall<'a, C> {
16487 self._delegate = Some(new_value);
16488 self
16489 }
16490
16491 /// Set any additional parameter of the query string used in the request.
16492 /// It should be used to set parameters which are not yet available through their own
16493 /// setters.
16494 ///
16495 /// Please note that this method must not be used to set any of the known parameters
16496 /// which have their own setter method. If done anyway, the request will fail.
16497 ///
16498 /// # Additional Parameters
16499 ///
16500 /// * *$.xgafv* (query-string) - V1 error format.
16501 /// * *access_token* (query-string) - OAuth access token.
16502 /// * *alt* (query-string) - Data format for response.
16503 /// * *callback* (query-string) - JSONP
16504 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16505 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16506 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16507 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16508 /// * *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.
16509 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16510 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16511 pub fn param<T>(mut self, name: T, value: T) -> FileModifyLabelCall<'a, C>
16512 where
16513 T: AsRef<str>,
16514 {
16515 self._additional_params
16516 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16517 self
16518 }
16519
16520 /// Identifies the authorization scope for the method you are building.
16521 ///
16522 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16523 /// [`Scope::Full`].
16524 ///
16525 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16526 /// tokens for more than one scope.
16527 ///
16528 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16529 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16530 /// sufficient, a read-write scope will do as well.
16531 pub fn add_scope<St>(mut self, scope: St) -> FileModifyLabelCall<'a, C>
16532 where
16533 St: AsRef<str>,
16534 {
16535 self._scopes.insert(String::from(scope.as_ref()));
16536 self
16537 }
16538 /// Identifies the authorization scope(s) for the method you are building.
16539 ///
16540 /// See [`Self::add_scope()`] for details.
16541 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileModifyLabelCall<'a, C>
16542 where
16543 I: IntoIterator<Item = St>,
16544 St: AsRef<str>,
16545 {
16546 self._scopes
16547 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16548 self
16549 }
16550
16551 /// Removes all scopes, and no default scope will be used either.
16552 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16553 /// for details).
16554 pub fn clear_scopes(mut self) -> FileModifyLabelCall<'a, C> {
16555 self._scopes.clear();
16556 self
16557 }
16558}
16559
16560/// 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).
16561///
16562/// A builder for the *update* method supported by a *file* resource.
16563/// It is not used directly, but through a [`FileMethods`] instance.
16564///
16565/// # Example
16566///
16567/// Instantiate a resource method builder
16568///
16569/// ```test_harness,no_run
16570/// # extern crate hyper;
16571/// # extern crate hyper_rustls;
16572/// # extern crate google_drive3 as drive3;
16573/// use drive3::api::File;
16574/// use std::fs;
16575/// # async fn dox() {
16576/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16577///
16578/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16579/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16580/// # .with_native_roots()
16581/// # .unwrap()
16582/// # .https_only()
16583/// # .enable_http2()
16584/// # .build();
16585///
16586/// # let executor = hyper_util::rt::TokioExecutor::new();
16587/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16588/// # secret,
16589/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16590/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16591/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16592/// # ),
16593/// # ).build().await.unwrap();
16594///
16595/// # let client = hyper_util::client::legacy::Client::builder(
16596/// # hyper_util::rt::TokioExecutor::new()
16597/// # )
16598/// # .build(
16599/// # hyper_rustls::HttpsConnectorBuilder::new()
16600/// # .with_native_roots()
16601/// # .unwrap()
16602/// # .https_or_http()
16603/// # .enable_http2()
16604/// # .build()
16605/// # );
16606/// # let mut hub = DriveHub::new(client, auth);
16607/// // As the method needs a request, you would usually fill it with the desired information
16608/// // into the respective structure. Some of the parts shown here might not be applicable !
16609/// // Values shown here are possibly random and not representative !
16610/// let mut req = File::default();
16611///
16612/// // You can configure optional parameters by calling the respective setters at will, and
16613/// // execute the final call using `upload(...)`.
16614/// // Values shown here are possibly random and not representative !
16615/// let result = hub.files().update(req, "fileId")
16616/// .use_content_as_indexable_text(true)
16617/// .supports_team_drives(false)
16618/// .supports_all_drives(false)
16619/// .remove_parents("ut")
16620/// .ocr_language("At")
16621/// .keep_revision_forever(true)
16622/// .include_permissions_for_view("vero")
16623/// .include_labels("duo")
16624/// .enforce_single_parent(true)
16625/// .add_parents("ut")
16626/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
16627/// # }
16628/// ```
16629pub struct FileUpdateCall<'a, C>
16630where
16631 C: 'a,
16632{
16633 hub: &'a DriveHub<C>,
16634 _request: File,
16635 _file_id: String,
16636 _use_content_as_indexable_text: Option<bool>,
16637 _supports_team_drives: Option<bool>,
16638 _supports_all_drives: Option<bool>,
16639 _remove_parents: Option<String>,
16640 _ocr_language: Option<String>,
16641 _keep_revision_forever: Option<bool>,
16642 _include_permissions_for_view: Option<String>,
16643 _include_labels: Option<String>,
16644 _enforce_single_parent: Option<bool>,
16645 _add_parents: Option<String>,
16646 _delegate: Option<&'a mut dyn common::Delegate>,
16647 _additional_params: HashMap<String, String>,
16648 _scopes: BTreeSet<String>,
16649}
16650
16651impl<'a, C> common::CallBuilder for FileUpdateCall<'a, C> {}
16652
16653impl<'a, C> FileUpdateCall<'a, C>
16654where
16655 C: common::Connector,
16656{
16657 /// 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
16658 pub async fn doit_without_upload(mut self) -> common::Result<(common::Response, File)> {
16659 use std::borrow::Cow;
16660 use std::io::{Read, Seek};
16661
16662 use common::{url::Params, ToParts};
16663 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16664
16665 let mut dd = common::DefaultDelegate;
16666 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16667 dlg.begin(common::MethodInfo {
16668 id: "drive.files.update",
16669 http_method: hyper::Method::PATCH,
16670 });
16671
16672 for &field in [
16673 "alt",
16674 "fileId",
16675 "useContentAsIndexableText",
16676 "supportsTeamDrives",
16677 "supportsAllDrives",
16678 "removeParents",
16679 "ocrLanguage",
16680 "keepRevisionForever",
16681 "includePermissionsForView",
16682 "includeLabels",
16683 "enforceSingleParent",
16684 "addParents",
16685 ]
16686 .iter()
16687 {
16688 if self._additional_params.contains_key(field) {
16689 dlg.finished(false);
16690 return Err(common::Error::FieldClash(field));
16691 }
16692 }
16693
16694 let mut params = Params::with_capacity(14 + self._additional_params.len());
16695 params.push("fileId", self._file_id);
16696 if let Some(value) = self._use_content_as_indexable_text.as_ref() {
16697 params.push("useContentAsIndexableText", value.to_string());
16698 }
16699 if let Some(value) = self._supports_team_drives.as_ref() {
16700 params.push("supportsTeamDrives", value.to_string());
16701 }
16702 if let Some(value) = self._supports_all_drives.as_ref() {
16703 params.push("supportsAllDrives", value.to_string());
16704 }
16705 if let Some(value) = self._remove_parents.as_ref() {
16706 params.push("removeParents", value);
16707 }
16708 if let Some(value) = self._ocr_language.as_ref() {
16709 params.push("ocrLanguage", value);
16710 }
16711 if let Some(value) = self._keep_revision_forever.as_ref() {
16712 params.push("keepRevisionForever", value.to_string());
16713 }
16714 if let Some(value) = self._include_permissions_for_view.as_ref() {
16715 params.push("includePermissionsForView", value);
16716 }
16717 if let Some(value) = self._include_labels.as_ref() {
16718 params.push("includeLabels", value);
16719 }
16720 if let Some(value) = self._enforce_single_parent.as_ref() {
16721 params.push("enforceSingleParent", value.to_string());
16722 }
16723 if let Some(value) = self._add_parents.as_ref() {
16724 params.push("addParents", value);
16725 }
16726
16727 params.extend(self._additional_params.iter());
16728
16729 params.push("alt", "json");
16730 let mut url = self.hub._base_url.clone() + "files/{fileId}";
16731 if self._scopes.is_empty() {
16732 self._scopes.insert(Scope::Full.as_ref().to_string());
16733 }
16734
16735 #[allow(clippy::single_element_loop)]
16736 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
16737 url = params.uri_replacement(url, param_name, find_this, false);
16738 }
16739 {
16740 let to_remove = ["fileId"];
16741 params.remove_params(&to_remove);
16742 }
16743
16744 let url = params.parse_with_url(&url);
16745
16746 let mut json_mime_type = mime::APPLICATION_JSON;
16747 let mut request_value_reader = {
16748 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16749 common::remove_json_null_values(&mut value);
16750 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16751 serde_json::to_writer(&mut dst, &value).unwrap();
16752 dst
16753 };
16754 let request_size = request_value_reader
16755 .seek(std::io::SeekFrom::End(0))
16756 .unwrap();
16757 request_value_reader
16758 .seek(std::io::SeekFrom::Start(0))
16759 .unwrap();
16760
16761 loop {
16762 let token = match self
16763 .hub
16764 .auth
16765 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16766 .await
16767 {
16768 Ok(token) => token,
16769 Err(e) => match dlg.token(e) {
16770 Ok(token) => token,
16771 Err(e) => {
16772 dlg.finished(false);
16773 return Err(common::Error::MissingToken(e));
16774 }
16775 },
16776 };
16777 request_value_reader
16778 .seek(std::io::SeekFrom::Start(0))
16779 .unwrap();
16780 let mut req_result = {
16781 let client = &self.hub.client;
16782 dlg.pre_request();
16783 let mut req_builder = hyper::Request::builder()
16784 .method(hyper::Method::PATCH)
16785 .uri(url.as_str())
16786 .header(USER_AGENT, self.hub._user_agent.clone());
16787
16788 if let Some(token) = token.as_ref() {
16789 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16790 }
16791
16792 let request = req_builder
16793 .header(CONTENT_TYPE, json_mime_type.to_string())
16794 .header(CONTENT_LENGTH, request_size as u64)
16795 .body(common::to_body(
16796 request_value_reader.get_ref().clone().into(),
16797 ));
16798
16799 client.request(request.unwrap()).await
16800 };
16801
16802 match req_result {
16803 Err(err) => {
16804 if let common::Retry::After(d) = dlg.http_error(&err) {
16805 sleep(d).await;
16806 continue;
16807 }
16808 dlg.finished(false);
16809 return Err(common::Error::HttpError(err));
16810 }
16811 Ok(res) => {
16812 let (mut parts, body) = res.into_parts();
16813 let mut body = common::Body::new(body);
16814 if !parts.status.is_success() {
16815 let bytes = common::to_bytes(body).await.unwrap_or_default();
16816 let error = serde_json::from_str(&common::to_string(&bytes));
16817 let response = common::to_response(parts, bytes.into());
16818
16819 if let common::Retry::After(d) =
16820 dlg.http_failure(&response, error.as_ref().ok())
16821 {
16822 sleep(d).await;
16823 continue;
16824 }
16825
16826 dlg.finished(false);
16827
16828 return Err(match error {
16829 Ok(value) => common::Error::BadRequest(value),
16830 _ => common::Error::Failure(response),
16831 });
16832 }
16833 let response = {
16834 let bytes = common::to_bytes(body).await.unwrap_or_default();
16835 let encoded = common::to_string(&bytes);
16836 match serde_json::from_str(&encoded) {
16837 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16838 Err(error) => {
16839 dlg.response_json_decode_error(&encoded, &error);
16840 return Err(common::Error::JsonDecodeError(
16841 encoded.to_string(),
16842 error,
16843 ));
16844 }
16845 }
16846 };
16847
16848 dlg.finished(true);
16849 return Ok(response);
16850 }
16851 }
16852 }
16853 }
16854
16855 /// Perform the operation you have build so far.
16856 async fn doit<RS>(
16857 mut self,
16858 mut reader: RS,
16859 reader_mime_type: mime::Mime,
16860 protocol: common::UploadProtocol,
16861 ) -> common::Result<(common::Response, File)>
16862 where
16863 RS: common::ReadSeek,
16864 {
16865 use std::borrow::Cow;
16866 use std::io::{Read, Seek};
16867
16868 use common::{url::Params, ToParts};
16869 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16870
16871 let mut dd = common::DefaultDelegate;
16872 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16873 dlg.begin(common::MethodInfo {
16874 id: "drive.files.update",
16875 http_method: hyper::Method::PATCH,
16876 });
16877
16878 for &field in [
16879 "alt",
16880 "fileId",
16881 "useContentAsIndexableText",
16882 "supportsTeamDrives",
16883 "supportsAllDrives",
16884 "removeParents",
16885 "ocrLanguage",
16886 "keepRevisionForever",
16887 "includePermissionsForView",
16888 "includeLabels",
16889 "enforceSingleParent",
16890 "addParents",
16891 ]
16892 .iter()
16893 {
16894 if self._additional_params.contains_key(field) {
16895 dlg.finished(false);
16896 return Err(common::Error::FieldClash(field));
16897 }
16898 }
16899
16900 let mut params = Params::with_capacity(14 + self._additional_params.len());
16901 params.push("fileId", self._file_id);
16902 if let Some(value) = self._use_content_as_indexable_text.as_ref() {
16903 params.push("useContentAsIndexableText", value.to_string());
16904 }
16905 if let Some(value) = self._supports_team_drives.as_ref() {
16906 params.push("supportsTeamDrives", value.to_string());
16907 }
16908 if let Some(value) = self._supports_all_drives.as_ref() {
16909 params.push("supportsAllDrives", value.to_string());
16910 }
16911 if let Some(value) = self._remove_parents.as_ref() {
16912 params.push("removeParents", value);
16913 }
16914 if let Some(value) = self._ocr_language.as_ref() {
16915 params.push("ocrLanguage", value);
16916 }
16917 if let Some(value) = self._keep_revision_forever.as_ref() {
16918 params.push("keepRevisionForever", value.to_string());
16919 }
16920 if let Some(value) = self._include_permissions_for_view.as_ref() {
16921 params.push("includePermissionsForView", value);
16922 }
16923 if let Some(value) = self._include_labels.as_ref() {
16924 params.push("includeLabels", value);
16925 }
16926 if let Some(value) = self._enforce_single_parent.as_ref() {
16927 params.push("enforceSingleParent", value.to_string());
16928 }
16929 if let Some(value) = self._add_parents.as_ref() {
16930 params.push("addParents", value);
16931 }
16932
16933 params.extend(self._additional_params.iter());
16934
16935 params.push("alt", "json");
16936 let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
16937 (
16938 self.hub._root_url.clone() + "resumable/upload/drive/v3/files/{fileId}",
16939 "resumable",
16940 )
16941 } else if protocol == common::UploadProtocol::Simple {
16942 (
16943 self.hub._root_url.clone() + "upload/drive/v3/files/{fileId}",
16944 "multipart",
16945 )
16946 } else {
16947 unreachable!()
16948 };
16949 params.push("uploadType", upload_type);
16950 if self._scopes.is_empty() {
16951 self._scopes.insert(Scope::Full.as_ref().to_string());
16952 }
16953
16954 #[allow(clippy::single_element_loop)]
16955 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
16956 url = params.uri_replacement(url, param_name, find_this, false);
16957 }
16958 {
16959 let to_remove = ["fileId"];
16960 params.remove_params(&to_remove);
16961 }
16962
16963 let url = params.parse_with_url(&url);
16964
16965 let mut json_mime_type = mime::APPLICATION_JSON;
16966 let mut request_value_reader = {
16967 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16968 common::remove_json_null_values(&mut value);
16969 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16970 serde_json::to_writer(&mut dst, &value).unwrap();
16971 dst
16972 };
16973 let request_size = request_value_reader
16974 .seek(std::io::SeekFrom::End(0))
16975 .unwrap();
16976 request_value_reader
16977 .seek(std::io::SeekFrom::Start(0))
16978 .unwrap();
16979
16980 let mut upload_url_from_server;
16981
16982 loop {
16983 let token = match self
16984 .hub
16985 .auth
16986 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16987 .await
16988 {
16989 Ok(token) => token,
16990 Err(e) => match dlg.token(e) {
16991 Ok(token) => token,
16992 Err(e) => {
16993 dlg.finished(false);
16994 return Err(common::Error::MissingToken(e));
16995 }
16996 },
16997 };
16998 request_value_reader
16999 .seek(std::io::SeekFrom::Start(0))
17000 .unwrap();
17001 let mut req_result = {
17002 let mut mp_reader: common::MultiPartReader = Default::default();
17003 let (mut body_reader, content_type) = match protocol {
17004 common::UploadProtocol::Simple => {
17005 mp_reader.reserve_exact(2);
17006 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
17007 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
17008 if size > 5497558138880 {
17009 return Err(common::Error::UploadSizeLimitExceeded(size, 5497558138880));
17010 }
17011 mp_reader
17012 .add_part(
17013 &mut request_value_reader,
17014 request_size,
17015 json_mime_type.clone(),
17016 )
17017 .add_part(&mut reader, size, reader_mime_type.clone());
17018 (
17019 &mut mp_reader as &mut (dyn std::io::Read + Send),
17020 common::MultiPartReader::mime_type(),
17021 )
17022 }
17023 _ => (
17024 &mut request_value_reader as &mut (dyn std::io::Read + Send),
17025 json_mime_type.clone(),
17026 ),
17027 };
17028 let client = &self.hub.client;
17029 dlg.pre_request();
17030 let mut req_builder = hyper::Request::builder()
17031 .method(hyper::Method::PATCH)
17032 .uri(url.as_str())
17033 .header(USER_AGENT, self.hub._user_agent.clone());
17034
17035 if let Some(token) = token.as_ref() {
17036 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17037 }
17038
17039 upload_url_from_server = true;
17040 if protocol == common::UploadProtocol::Resumable {
17041 req_builder = req_builder
17042 .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
17043 }
17044
17045 let mut body_reader_bytes = vec![];
17046 body_reader.read_to_end(&mut body_reader_bytes).unwrap();
17047 let request = req_builder
17048 .header(CONTENT_TYPE, content_type.to_string())
17049 .body(common::to_body(body_reader_bytes.into()));
17050
17051 client.request(request.unwrap()).await
17052 };
17053
17054 match req_result {
17055 Err(err) => {
17056 if let common::Retry::After(d) = dlg.http_error(&err) {
17057 sleep(d).await;
17058 continue;
17059 }
17060 dlg.finished(false);
17061 return Err(common::Error::HttpError(err));
17062 }
17063 Ok(res) => {
17064 let (mut parts, body) = res.into_parts();
17065 let mut body = common::Body::new(body);
17066 if !parts.status.is_success() {
17067 let bytes = common::to_bytes(body).await.unwrap_or_default();
17068 let error = serde_json::from_str(&common::to_string(&bytes));
17069 let response = common::to_response(parts, bytes.into());
17070
17071 if let common::Retry::After(d) =
17072 dlg.http_failure(&response, error.as_ref().ok())
17073 {
17074 sleep(d).await;
17075 continue;
17076 }
17077
17078 dlg.finished(false);
17079
17080 return Err(match error {
17081 Ok(value) => common::Error::BadRequest(value),
17082 _ => common::Error::Failure(response),
17083 });
17084 }
17085 if protocol == common::UploadProtocol::Resumable {
17086 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
17087 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
17088 if size > 5497558138880 {
17089 return Err(common::Error::UploadSizeLimitExceeded(size, 5497558138880));
17090 }
17091 let upload_result = {
17092 let url_str = &parts
17093 .headers
17094 .get("Location")
17095 .expect("LOCATION header is part of protocol")
17096 .to_str()
17097 .unwrap();
17098 if upload_url_from_server {
17099 dlg.store_upload_url(Some(url_str));
17100 }
17101
17102 common::ResumableUploadHelper {
17103 client: &self.hub.client,
17104 delegate: dlg,
17105 start_at: if upload_url_from_server {
17106 Some(0)
17107 } else {
17108 None
17109 },
17110 auth: &self.hub.auth,
17111 user_agent: &self.hub._user_agent,
17112 // TODO: Check this assumption
17113 auth_header: format!(
17114 "Bearer {}",
17115 token
17116 .ok_or_else(|| common::Error::MissingToken(
17117 "resumable upload requires token".into()
17118 ))?
17119 .as_str()
17120 ),
17121 url: url_str,
17122 reader: &mut reader,
17123 media_type: reader_mime_type.clone(),
17124 content_length: size,
17125 }
17126 .upload()
17127 .await
17128 };
17129 match upload_result {
17130 None => {
17131 dlg.finished(false);
17132 return Err(common::Error::Cancelled);
17133 }
17134 Some(Err(err)) => {
17135 dlg.finished(false);
17136 return Err(common::Error::HttpError(err));
17137 }
17138 Some(Ok(response)) => {
17139 (parts, body) = response.into_parts();
17140 if !parts.status.is_success() {
17141 dlg.store_upload_url(None);
17142 dlg.finished(false);
17143 return Err(common::Error::Failure(
17144 common::Response::from_parts(parts, body),
17145 ));
17146 }
17147 }
17148 }
17149 }
17150 let response = {
17151 let bytes = common::to_bytes(body).await.unwrap_or_default();
17152 let encoded = common::to_string(&bytes);
17153 match serde_json::from_str(&encoded) {
17154 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17155 Err(error) => {
17156 dlg.response_json_decode_error(&encoded, &error);
17157 return Err(common::Error::JsonDecodeError(
17158 encoded.to_string(),
17159 error,
17160 ));
17161 }
17162 }
17163 };
17164
17165 dlg.finished(true);
17166 return Ok(response);
17167 }
17168 }
17169 }
17170 }
17171
17172 /// Upload media in a resumable fashion.
17173 /// Even if the upload fails or is interrupted, it can be resumed for a
17174 /// certain amount of time as the server maintains state temporarily.
17175 ///
17176 /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
17177 /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
17178 /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
17179 /// `cancel_chunk_upload(...)`.
17180 ///
17181 /// * *multipart*: yes
17182 /// * *max size*: 5497558138880
17183 /// * *valid mime types*: '*/*'
17184 pub async fn upload_resumable<RS>(
17185 self,
17186 resumeable_stream: RS,
17187 mime_type: mime::Mime,
17188 ) -> common::Result<(common::Response, File)>
17189 where
17190 RS: common::ReadSeek,
17191 {
17192 self.doit(
17193 resumeable_stream,
17194 mime_type,
17195 common::UploadProtocol::Resumable,
17196 )
17197 .await
17198 }
17199 /// Upload media all at once.
17200 /// If the upload fails for whichever reason, all progress is lost.
17201 ///
17202 /// * *multipart*: yes
17203 /// * *max size*: 5497558138880
17204 /// * *valid mime types*: '*/*'
17205 pub async fn upload<RS>(
17206 self,
17207 stream: RS,
17208 mime_type: mime::Mime,
17209 ) -> common::Result<(common::Response, File)>
17210 where
17211 RS: common::ReadSeek,
17212 {
17213 self.doit(stream, mime_type, common::UploadProtocol::Simple)
17214 .await
17215 }
17216
17217 ///
17218 /// Sets the *request* property to the given value.
17219 ///
17220 /// Even though the property as already been set when instantiating this call,
17221 /// we provide this method for API completeness.
17222 pub fn request(mut self, new_value: File) -> FileUpdateCall<'a, C> {
17223 self._request = new_value;
17224 self
17225 }
17226 /// The ID of the file.
17227 ///
17228 /// Sets the *file id* path property to the given value.
17229 ///
17230 /// Even though the property as already been set when instantiating this call,
17231 /// we provide this method for API completeness.
17232 pub fn file_id(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
17233 self._file_id = new_value.to_string();
17234 self
17235 }
17236 /// Whether to use the uploaded content as indexable text.
17237 ///
17238 /// Sets the *use content as indexable text* query property to the given value.
17239 pub fn use_content_as_indexable_text(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
17240 self._use_content_as_indexable_text = Some(new_value);
17241 self
17242 }
17243 /// Deprecated: Use `supportsAllDrives` instead.
17244 ///
17245 /// Sets the *supports team drives* query property to the given value.
17246 pub fn supports_team_drives(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
17247 self._supports_team_drives = Some(new_value);
17248 self
17249 }
17250 /// Whether the requesting application supports both My Drives and shared drives.
17251 ///
17252 /// Sets the *supports all drives* query property to the given value.
17253 pub fn supports_all_drives(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
17254 self._supports_all_drives = Some(new_value);
17255 self
17256 }
17257 /// A comma-separated list of parent IDs to remove.
17258 ///
17259 /// Sets the *remove parents* query property to the given value.
17260 pub fn remove_parents(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
17261 self._remove_parents = Some(new_value.to_string());
17262 self
17263 }
17264 /// A language hint for OCR processing during image import (ISO 639-1 code).
17265 ///
17266 /// Sets the *ocr language* query property to the given value.
17267 pub fn ocr_language(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
17268 self._ocr_language = Some(new_value.to_string());
17269 self
17270 }
17271 /// Whether to set the `keepForever` field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions.
17272 ///
17273 /// Sets the *keep revision forever* query property to the given value.
17274 pub fn keep_revision_forever(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
17275 self._keep_revision_forever = Some(new_value);
17276 self
17277 }
17278 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
17279 ///
17280 /// Sets the *include permissions for view* query property to the given value.
17281 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
17282 self._include_permissions_for_view = Some(new_value.to_string());
17283 self
17284 }
17285 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
17286 ///
17287 /// Sets the *include labels* query property to the given value.
17288 pub fn include_labels(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
17289 self._include_labels = Some(new_value.to_string());
17290 self
17291 }
17292 /// Deprecated: Adding files to multiple folders is no longer supported. Use shortcuts instead.
17293 ///
17294 /// Sets the *enforce single parent* query property to the given value.
17295 pub fn enforce_single_parent(mut self, new_value: bool) -> FileUpdateCall<'a, C> {
17296 self._enforce_single_parent = Some(new_value);
17297 self
17298 }
17299 /// A comma-separated list of parent IDs to add.
17300 ///
17301 /// Sets the *add parents* query property to the given value.
17302 pub fn add_parents(mut self, new_value: &str) -> FileUpdateCall<'a, C> {
17303 self._add_parents = Some(new_value.to_string());
17304 self
17305 }
17306 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17307 /// while executing the actual API request.
17308 ///
17309 /// ````text
17310 /// It should be used to handle progress information, and to implement a certain level of resilience.
17311 /// ````
17312 ///
17313 /// Sets the *delegate* property to the given value.
17314 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileUpdateCall<'a, C> {
17315 self._delegate = Some(new_value);
17316 self
17317 }
17318
17319 /// Set any additional parameter of the query string used in the request.
17320 /// It should be used to set parameters which are not yet available through their own
17321 /// setters.
17322 ///
17323 /// Please note that this method must not be used to set any of the known parameters
17324 /// which have their own setter method. If done anyway, the request will fail.
17325 ///
17326 /// # Additional Parameters
17327 ///
17328 /// * *$.xgafv* (query-string) - V1 error format.
17329 /// * *access_token* (query-string) - OAuth access token.
17330 /// * *alt* (query-string) - Data format for response.
17331 /// * *callback* (query-string) - JSONP
17332 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17333 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17334 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17335 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17336 /// * *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.
17337 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17338 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17339 pub fn param<T>(mut self, name: T, value: T) -> FileUpdateCall<'a, C>
17340 where
17341 T: AsRef<str>,
17342 {
17343 self._additional_params
17344 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17345 self
17346 }
17347
17348 /// Identifies the authorization scope for the method you are building.
17349 ///
17350 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17351 /// [`Scope::Full`].
17352 ///
17353 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17354 /// tokens for more than one scope.
17355 ///
17356 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17357 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17358 /// sufficient, a read-write scope will do as well.
17359 pub fn add_scope<St>(mut self, scope: St) -> FileUpdateCall<'a, C>
17360 where
17361 St: AsRef<str>,
17362 {
17363 self._scopes.insert(String::from(scope.as_ref()));
17364 self
17365 }
17366 /// Identifies the authorization scope(s) for the method you are building.
17367 ///
17368 /// See [`Self::add_scope()`] for details.
17369 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileUpdateCall<'a, C>
17370 where
17371 I: IntoIterator<Item = St>,
17372 St: AsRef<str>,
17373 {
17374 self._scopes
17375 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17376 self
17377 }
17378
17379 /// Removes all scopes, and no default scope will be used either.
17380 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17381 /// for details).
17382 pub fn clear_scopes(mut self) -> FileUpdateCall<'a, C> {
17383 self._scopes.clear();
17384 self
17385 }
17386}
17387
17388/// Subscribes to changes to a file. For more information, see [Notifications for resource changes](https://developers.google.com/workspace/drive/api/guides/push).
17389///
17390/// A builder for the *watch* method supported by a *file* resource.
17391/// It is not used directly, but through a [`FileMethods`] instance.
17392///
17393/// # Example
17394///
17395/// Instantiate a resource method builder
17396///
17397/// ```test_harness,no_run
17398/// # extern crate hyper;
17399/// # extern crate hyper_rustls;
17400/// # extern crate google_drive3 as drive3;
17401/// use drive3::api::Channel;
17402/// # async fn dox() {
17403/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17404///
17405/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17406/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17407/// # .with_native_roots()
17408/// # .unwrap()
17409/// # .https_only()
17410/// # .enable_http2()
17411/// # .build();
17412///
17413/// # let executor = hyper_util::rt::TokioExecutor::new();
17414/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17415/// # secret,
17416/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17417/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17418/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17419/// # ),
17420/// # ).build().await.unwrap();
17421///
17422/// # let client = hyper_util::client::legacy::Client::builder(
17423/// # hyper_util::rt::TokioExecutor::new()
17424/// # )
17425/// # .build(
17426/// # hyper_rustls::HttpsConnectorBuilder::new()
17427/// # .with_native_roots()
17428/// # .unwrap()
17429/// # .https_or_http()
17430/// # .enable_http2()
17431/// # .build()
17432/// # );
17433/// # let mut hub = DriveHub::new(client, auth);
17434/// // As the method needs a request, you would usually fill it with the desired information
17435/// // into the respective structure. Some of the parts shown here might not be applicable !
17436/// // Values shown here are possibly random and not representative !
17437/// let mut req = Channel::default();
17438///
17439/// // You can configure optional parameters by calling the respective setters at will, and
17440/// // execute the final call using `doit()`.
17441/// // Values shown here are possibly random and not representative !
17442/// let result = hub.files().watch(req, "fileId")
17443/// .supports_team_drives(false)
17444/// .supports_all_drives(true)
17445/// .include_permissions_for_view("sadipscing")
17446/// .include_labels("tempor")
17447/// .acknowledge_abuse(false)
17448/// .doit().await;
17449/// # }
17450/// ```
17451pub struct FileWatchCall<'a, C>
17452where
17453 C: 'a,
17454{
17455 hub: &'a DriveHub<C>,
17456 _request: Channel,
17457 _file_id: String,
17458 _supports_team_drives: Option<bool>,
17459 _supports_all_drives: Option<bool>,
17460 _include_permissions_for_view: Option<String>,
17461 _include_labels: Option<String>,
17462 _acknowledge_abuse: Option<bool>,
17463 _delegate: Option<&'a mut dyn common::Delegate>,
17464 _additional_params: HashMap<String, String>,
17465 _scopes: BTreeSet<String>,
17466}
17467
17468impl<'a, C> common::CallBuilder for FileWatchCall<'a, C> {}
17469
17470impl<'a, C> FileWatchCall<'a, C>
17471where
17472 C: common::Connector,
17473{
17474 /// Perform the operation you have build so far.
17475 pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
17476 use std::borrow::Cow;
17477 use std::io::{Read, Seek};
17478
17479 use common::{url::Params, ToParts};
17480 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17481
17482 let mut dd = common::DefaultDelegate;
17483 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17484 dlg.begin(common::MethodInfo {
17485 id: "drive.files.watch",
17486 http_method: hyper::Method::POST,
17487 });
17488
17489 for &field in [
17490 "alt",
17491 "fileId",
17492 "supportsTeamDrives",
17493 "supportsAllDrives",
17494 "includePermissionsForView",
17495 "includeLabels",
17496 "acknowledgeAbuse",
17497 ]
17498 .iter()
17499 {
17500 if self._additional_params.contains_key(field) {
17501 dlg.finished(false);
17502 return Err(common::Error::FieldClash(field));
17503 }
17504 }
17505
17506 let mut params = Params::with_capacity(9 + self._additional_params.len());
17507 params.push("fileId", self._file_id);
17508 if let Some(value) = self._supports_team_drives.as_ref() {
17509 params.push("supportsTeamDrives", value.to_string());
17510 }
17511 if let Some(value) = self._supports_all_drives.as_ref() {
17512 params.push("supportsAllDrives", value.to_string());
17513 }
17514 if let Some(value) = self._include_permissions_for_view.as_ref() {
17515 params.push("includePermissionsForView", value);
17516 }
17517 if let Some(value) = self._include_labels.as_ref() {
17518 params.push("includeLabels", value);
17519 }
17520 if let Some(value) = self._acknowledge_abuse.as_ref() {
17521 params.push("acknowledgeAbuse", value.to_string());
17522 }
17523
17524 params.extend(self._additional_params.iter());
17525
17526 params.push("alt", "json");
17527 let mut url = self.hub._base_url.clone() + "files/{fileId}/watch";
17528 if self._scopes.is_empty() {
17529 self._scopes
17530 .insert(Scope::MeetReadonly.as_ref().to_string());
17531 }
17532
17533 #[allow(clippy::single_element_loop)]
17534 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
17535 url = params.uri_replacement(url, param_name, find_this, false);
17536 }
17537 {
17538 let to_remove = ["fileId"];
17539 params.remove_params(&to_remove);
17540 }
17541
17542 let url = params.parse_with_url(&url);
17543
17544 let mut json_mime_type = mime::APPLICATION_JSON;
17545 let mut request_value_reader = {
17546 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17547 common::remove_json_null_values(&mut value);
17548 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17549 serde_json::to_writer(&mut dst, &value).unwrap();
17550 dst
17551 };
17552 let request_size = request_value_reader
17553 .seek(std::io::SeekFrom::End(0))
17554 .unwrap();
17555 request_value_reader
17556 .seek(std::io::SeekFrom::Start(0))
17557 .unwrap();
17558
17559 loop {
17560 let token = match self
17561 .hub
17562 .auth
17563 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17564 .await
17565 {
17566 Ok(token) => token,
17567 Err(e) => match dlg.token(e) {
17568 Ok(token) => token,
17569 Err(e) => {
17570 dlg.finished(false);
17571 return Err(common::Error::MissingToken(e));
17572 }
17573 },
17574 };
17575 request_value_reader
17576 .seek(std::io::SeekFrom::Start(0))
17577 .unwrap();
17578 let mut req_result = {
17579 let client = &self.hub.client;
17580 dlg.pre_request();
17581 let mut req_builder = hyper::Request::builder()
17582 .method(hyper::Method::POST)
17583 .uri(url.as_str())
17584 .header(USER_AGENT, self.hub._user_agent.clone());
17585
17586 if let Some(token) = token.as_ref() {
17587 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17588 }
17589
17590 let request = req_builder
17591 .header(CONTENT_TYPE, json_mime_type.to_string())
17592 .header(CONTENT_LENGTH, request_size as u64)
17593 .body(common::to_body(
17594 request_value_reader.get_ref().clone().into(),
17595 ));
17596
17597 client.request(request.unwrap()).await
17598 };
17599
17600 match req_result {
17601 Err(err) => {
17602 if let common::Retry::After(d) = dlg.http_error(&err) {
17603 sleep(d).await;
17604 continue;
17605 }
17606 dlg.finished(false);
17607 return Err(common::Error::HttpError(err));
17608 }
17609 Ok(res) => {
17610 let (mut parts, body) = res.into_parts();
17611 let mut body = common::Body::new(body);
17612 if !parts.status.is_success() {
17613 let bytes = common::to_bytes(body).await.unwrap_or_default();
17614 let error = serde_json::from_str(&common::to_string(&bytes));
17615 let response = common::to_response(parts, bytes.into());
17616
17617 if let common::Retry::After(d) =
17618 dlg.http_failure(&response, error.as_ref().ok())
17619 {
17620 sleep(d).await;
17621 continue;
17622 }
17623
17624 dlg.finished(false);
17625
17626 return Err(match error {
17627 Ok(value) => common::Error::BadRequest(value),
17628 _ => common::Error::Failure(response),
17629 });
17630 }
17631 let response = {
17632 let bytes = common::to_bytes(body).await.unwrap_or_default();
17633 let encoded = common::to_string(&bytes);
17634 match serde_json::from_str(&encoded) {
17635 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17636 Err(error) => {
17637 dlg.response_json_decode_error(&encoded, &error);
17638 return Err(common::Error::JsonDecodeError(
17639 encoded.to_string(),
17640 error,
17641 ));
17642 }
17643 }
17644 };
17645
17646 dlg.finished(true);
17647 return Ok(response);
17648 }
17649 }
17650 }
17651 }
17652
17653 ///
17654 /// Sets the *request* property to the given value.
17655 ///
17656 /// Even though the property as already been set when instantiating this call,
17657 /// we provide this method for API completeness.
17658 pub fn request(mut self, new_value: Channel) -> FileWatchCall<'a, C> {
17659 self._request = new_value;
17660 self
17661 }
17662 /// The ID of the file.
17663 ///
17664 /// Sets the *file id* path property to the given value.
17665 ///
17666 /// Even though the property as already been set when instantiating this call,
17667 /// we provide this method for API completeness.
17668 pub fn file_id(mut self, new_value: &str) -> FileWatchCall<'a, C> {
17669 self._file_id = new_value.to_string();
17670 self
17671 }
17672 /// Deprecated: Use `supportsAllDrives` instead.
17673 ///
17674 /// Sets the *supports team drives* query property to the given value.
17675 pub fn supports_team_drives(mut self, new_value: bool) -> FileWatchCall<'a, C> {
17676 self._supports_team_drives = Some(new_value);
17677 self
17678 }
17679 /// Whether the requesting application supports both My Drives and shared drives.
17680 ///
17681 /// Sets the *supports all drives* query property to the given value.
17682 pub fn supports_all_drives(mut self, new_value: bool) -> FileWatchCall<'a, C> {
17683 self._supports_all_drives = Some(new_value);
17684 self
17685 }
17686 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
17687 ///
17688 /// Sets the *include permissions for view* query property to the given value.
17689 pub fn include_permissions_for_view(mut self, new_value: &str) -> FileWatchCall<'a, C> {
17690 self._include_permissions_for_view = Some(new_value.to_string());
17691 self
17692 }
17693 /// A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
17694 ///
17695 /// Sets the *include labels* query property to the given value.
17696 pub fn include_labels(mut self, new_value: &str) -> FileWatchCall<'a, C> {
17697 self._include_labels = Some(new_value.to_string());
17698 self
17699 }
17700 /// 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.
17701 ///
17702 /// Sets the *acknowledge abuse* query property to the given value.
17703 pub fn acknowledge_abuse(mut self, new_value: bool) -> FileWatchCall<'a, C> {
17704 self._acknowledge_abuse = Some(new_value);
17705 self
17706 }
17707 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17708 /// while executing the actual API request.
17709 ///
17710 /// ````text
17711 /// It should be used to handle progress information, and to implement a certain level of resilience.
17712 /// ````
17713 ///
17714 /// Sets the *delegate* property to the given value.
17715 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileWatchCall<'a, C> {
17716 self._delegate = Some(new_value);
17717 self
17718 }
17719
17720 /// Set any additional parameter of the query string used in the request.
17721 /// It should be used to set parameters which are not yet available through their own
17722 /// setters.
17723 ///
17724 /// Please note that this method must not be used to set any of the known parameters
17725 /// which have their own setter method. If done anyway, the request will fail.
17726 ///
17727 /// # Additional Parameters
17728 ///
17729 /// * *$.xgafv* (query-string) - V1 error format.
17730 /// * *access_token* (query-string) - OAuth access token.
17731 /// * *alt* (query-string) - Data format for response.
17732 /// * *callback* (query-string) - JSONP
17733 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17734 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17735 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17736 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17737 /// * *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.
17738 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17739 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17740 pub fn param<T>(mut self, name: T, value: T) -> FileWatchCall<'a, C>
17741 where
17742 T: AsRef<str>,
17743 {
17744 self._additional_params
17745 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17746 self
17747 }
17748
17749 /// Identifies the authorization scope for the method you are building.
17750 ///
17751 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17752 /// [`Scope::MeetReadonly`].
17753 ///
17754 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17755 /// tokens for more than one scope.
17756 ///
17757 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17758 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17759 /// sufficient, a read-write scope will do as well.
17760 pub fn add_scope<St>(mut self, scope: St) -> FileWatchCall<'a, C>
17761 where
17762 St: AsRef<str>,
17763 {
17764 self._scopes.insert(String::from(scope.as_ref()));
17765 self
17766 }
17767 /// Identifies the authorization scope(s) for the method you are building.
17768 ///
17769 /// See [`Self::add_scope()`] for details.
17770 pub fn add_scopes<I, St>(mut self, scopes: I) -> FileWatchCall<'a, C>
17771 where
17772 I: IntoIterator<Item = St>,
17773 St: AsRef<str>,
17774 {
17775 self._scopes
17776 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17777 self
17778 }
17779
17780 /// Removes all scopes, and no default scope will be used either.
17781 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17782 /// for details).
17783 pub fn clear_scopes(mut self) -> FileWatchCall<'a, C> {
17784 self._scopes.clear();
17785 self
17786 }
17787}
17788
17789/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
17790///
17791/// A builder for the *get* method supported by a *operation* resource.
17792/// It is not used directly, but through a [`OperationMethods`] instance.
17793///
17794/// # Example
17795///
17796/// Instantiate a resource method builder
17797///
17798/// ```test_harness,no_run
17799/// # extern crate hyper;
17800/// # extern crate hyper_rustls;
17801/// # extern crate google_drive3 as drive3;
17802/// # async fn dox() {
17803/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17804///
17805/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17806/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17807/// # .with_native_roots()
17808/// # .unwrap()
17809/// # .https_only()
17810/// # .enable_http2()
17811/// # .build();
17812///
17813/// # let executor = hyper_util::rt::TokioExecutor::new();
17814/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17815/// # secret,
17816/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17817/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17818/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17819/// # ),
17820/// # ).build().await.unwrap();
17821///
17822/// # let client = hyper_util::client::legacy::Client::builder(
17823/// # hyper_util::rt::TokioExecutor::new()
17824/// # )
17825/// # .build(
17826/// # hyper_rustls::HttpsConnectorBuilder::new()
17827/// # .with_native_roots()
17828/// # .unwrap()
17829/// # .https_or_http()
17830/// # .enable_http2()
17831/// # .build()
17832/// # );
17833/// # let mut hub = DriveHub::new(client, auth);
17834/// // You can configure optional parameters by calling the respective setters at will, and
17835/// // execute the final call using `doit()`.
17836/// // Values shown here are possibly random and not representative !
17837/// let result = hub.operations().get("name")
17838/// .doit().await;
17839/// # }
17840/// ```
17841pub struct OperationGetCall<'a, C>
17842where
17843 C: 'a,
17844{
17845 hub: &'a DriveHub<C>,
17846 _name: String,
17847 _delegate: Option<&'a mut dyn common::Delegate>,
17848 _additional_params: HashMap<String, String>,
17849 _scopes: BTreeSet<String>,
17850}
17851
17852impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
17853
17854impl<'a, C> OperationGetCall<'a, C>
17855where
17856 C: common::Connector,
17857{
17858 /// Perform the operation you have build so far.
17859 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17860 use std::borrow::Cow;
17861 use std::io::{Read, Seek};
17862
17863 use common::{url::Params, ToParts};
17864 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17865
17866 let mut dd = common::DefaultDelegate;
17867 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17868 dlg.begin(common::MethodInfo {
17869 id: "drive.operations.get",
17870 http_method: hyper::Method::GET,
17871 });
17872
17873 for &field in ["alt", "name"].iter() {
17874 if self._additional_params.contains_key(field) {
17875 dlg.finished(false);
17876 return Err(common::Error::FieldClash(field));
17877 }
17878 }
17879
17880 let mut params = Params::with_capacity(3 + self._additional_params.len());
17881 params.push("name", self._name);
17882
17883 params.extend(self._additional_params.iter());
17884
17885 params.push("alt", "json");
17886 let mut url = self.hub._base_url.clone() + "operations/{name}";
17887 if self._scopes.is_empty() {
17888 self._scopes
17889 .insert(Scope::MeetReadonly.as_ref().to_string());
17890 }
17891
17892 #[allow(clippy::single_element_loop)]
17893 for &(find_this, param_name) in [("{name}", "name")].iter() {
17894 url = params.uri_replacement(url, param_name, find_this, false);
17895 }
17896 {
17897 let to_remove = ["name"];
17898 params.remove_params(&to_remove);
17899 }
17900
17901 let url = params.parse_with_url(&url);
17902
17903 loop {
17904 let token = match self
17905 .hub
17906 .auth
17907 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17908 .await
17909 {
17910 Ok(token) => token,
17911 Err(e) => match dlg.token(e) {
17912 Ok(token) => token,
17913 Err(e) => {
17914 dlg.finished(false);
17915 return Err(common::Error::MissingToken(e));
17916 }
17917 },
17918 };
17919 let mut req_result = {
17920 let client = &self.hub.client;
17921 dlg.pre_request();
17922 let mut req_builder = hyper::Request::builder()
17923 .method(hyper::Method::GET)
17924 .uri(url.as_str())
17925 .header(USER_AGENT, self.hub._user_agent.clone());
17926
17927 if let Some(token) = token.as_ref() {
17928 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17929 }
17930
17931 let request = req_builder
17932 .header(CONTENT_LENGTH, 0_u64)
17933 .body(common::to_body::<String>(None));
17934
17935 client.request(request.unwrap()).await
17936 };
17937
17938 match req_result {
17939 Err(err) => {
17940 if let common::Retry::After(d) = dlg.http_error(&err) {
17941 sleep(d).await;
17942 continue;
17943 }
17944 dlg.finished(false);
17945 return Err(common::Error::HttpError(err));
17946 }
17947 Ok(res) => {
17948 let (mut parts, body) = res.into_parts();
17949 let mut body = common::Body::new(body);
17950 if !parts.status.is_success() {
17951 let bytes = common::to_bytes(body).await.unwrap_or_default();
17952 let error = serde_json::from_str(&common::to_string(&bytes));
17953 let response = common::to_response(parts, bytes.into());
17954
17955 if let common::Retry::After(d) =
17956 dlg.http_failure(&response, error.as_ref().ok())
17957 {
17958 sleep(d).await;
17959 continue;
17960 }
17961
17962 dlg.finished(false);
17963
17964 return Err(match error {
17965 Ok(value) => common::Error::BadRequest(value),
17966 _ => common::Error::Failure(response),
17967 });
17968 }
17969 let response = {
17970 let bytes = common::to_bytes(body).await.unwrap_or_default();
17971 let encoded = common::to_string(&bytes);
17972 match serde_json::from_str(&encoded) {
17973 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17974 Err(error) => {
17975 dlg.response_json_decode_error(&encoded, &error);
17976 return Err(common::Error::JsonDecodeError(
17977 encoded.to_string(),
17978 error,
17979 ));
17980 }
17981 }
17982 };
17983
17984 dlg.finished(true);
17985 return Ok(response);
17986 }
17987 }
17988 }
17989 }
17990
17991 /// The name of the operation resource.
17992 ///
17993 /// Sets the *name* path property to the given value.
17994 ///
17995 /// Even though the property as already been set when instantiating this call,
17996 /// we provide this method for API completeness.
17997 pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
17998 self._name = new_value.to_string();
17999 self
18000 }
18001 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18002 /// while executing the actual API request.
18003 ///
18004 /// ````text
18005 /// It should be used to handle progress information, and to implement a certain level of resilience.
18006 /// ````
18007 ///
18008 /// Sets the *delegate* property to the given value.
18009 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
18010 self._delegate = Some(new_value);
18011 self
18012 }
18013
18014 /// Set any additional parameter of the query string used in the request.
18015 /// It should be used to set parameters which are not yet available through their own
18016 /// setters.
18017 ///
18018 /// Please note that this method must not be used to set any of the known parameters
18019 /// which have their own setter method. If done anyway, the request will fail.
18020 ///
18021 /// # Additional Parameters
18022 ///
18023 /// * *$.xgafv* (query-string) - V1 error format.
18024 /// * *access_token* (query-string) - OAuth access token.
18025 /// * *alt* (query-string) - Data format for response.
18026 /// * *callback* (query-string) - JSONP
18027 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18028 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18029 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18030 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18031 /// * *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.
18032 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18033 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18034 pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
18035 where
18036 T: AsRef<str>,
18037 {
18038 self._additional_params
18039 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18040 self
18041 }
18042
18043 /// Identifies the authorization scope for the method you are building.
18044 ///
18045 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18046 /// [`Scope::MeetReadonly`].
18047 ///
18048 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18049 /// tokens for more than one scope.
18050 ///
18051 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18052 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18053 /// sufficient, a read-write scope will do as well.
18054 pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
18055 where
18056 St: AsRef<str>,
18057 {
18058 self._scopes.insert(String::from(scope.as_ref()));
18059 self
18060 }
18061 /// Identifies the authorization scope(s) for the method you are building.
18062 ///
18063 /// See [`Self::add_scope()`] for details.
18064 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
18065 where
18066 I: IntoIterator<Item = St>,
18067 St: AsRef<str>,
18068 {
18069 self._scopes
18070 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18071 self
18072 }
18073
18074 /// Removes all scopes, and no default scope will be used either.
18075 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18076 /// for details).
18077 pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
18078 self._scopes.clear();
18079 self
18080 }
18081}
18082
18083/// Creates a permission for a file or shared drive. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing). **Warning:** Concurrent permissions operations on the same file aren't supported; only the last update is applied.
18084///
18085/// A builder for the *create* method supported by a *permission* resource.
18086/// It is not used directly, but through a [`PermissionMethods`] instance.
18087///
18088/// # Example
18089///
18090/// Instantiate a resource method builder
18091///
18092/// ```test_harness,no_run
18093/// # extern crate hyper;
18094/// # extern crate hyper_rustls;
18095/// # extern crate google_drive3 as drive3;
18096/// use drive3::api::Permission;
18097/// # async fn dox() {
18098/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18099///
18100/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18101/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18102/// # .with_native_roots()
18103/// # .unwrap()
18104/// # .https_only()
18105/// # .enable_http2()
18106/// # .build();
18107///
18108/// # let executor = hyper_util::rt::TokioExecutor::new();
18109/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18110/// # secret,
18111/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18112/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18113/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18114/// # ),
18115/// # ).build().await.unwrap();
18116///
18117/// # let client = hyper_util::client::legacy::Client::builder(
18118/// # hyper_util::rt::TokioExecutor::new()
18119/// # )
18120/// # .build(
18121/// # hyper_rustls::HttpsConnectorBuilder::new()
18122/// # .with_native_roots()
18123/// # .unwrap()
18124/// # .https_or_http()
18125/// # .enable_http2()
18126/// # .build()
18127/// # );
18128/// # let mut hub = DriveHub::new(client, auth);
18129/// // As the method needs a request, you would usually fill it with the desired information
18130/// // into the respective structure. Some of the parts shown here might not be applicable !
18131/// // Values shown here are possibly random and not representative !
18132/// let mut req = Permission::default();
18133///
18134/// // You can configure optional parameters by calling the respective setters at will, and
18135/// // execute the final call using `doit()`.
18136/// // Values shown here are possibly random and not representative !
18137/// let result = hub.permissions().create(req, "fileId")
18138/// .use_domain_admin_access(true)
18139/// .transfer_ownership(true)
18140/// .supports_team_drives(false)
18141/// .supports_all_drives(false)
18142/// .send_notification_email(false)
18143/// .move_to_new_owners_root(true)
18144/// .enforce_single_parent(true)
18145/// .enforce_expansive_access(false)
18146/// .email_message("aliquyam")
18147/// .doit().await;
18148/// # }
18149/// ```
18150pub struct PermissionCreateCall<'a, C>
18151where
18152 C: 'a,
18153{
18154 hub: &'a DriveHub<C>,
18155 _request: Permission,
18156 _file_id: String,
18157 _use_domain_admin_access: Option<bool>,
18158 _transfer_ownership: Option<bool>,
18159 _supports_team_drives: Option<bool>,
18160 _supports_all_drives: Option<bool>,
18161 _send_notification_email: Option<bool>,
18162 _move_to_new_owners_root: Option<bool>,
18163 _enforce_single_parent: Option<bool>,
18164 _enforce_expansive_access: Option<bool>,
18165 _email_message: Option<String>,
18166 _delegate: Option<&'a mut dyn common::Delegate>,
18167 _additional_params: HashMap<String, String>,
18168 _scopes: BTreeSet<String>,
18169}
18170
18171impl<'a, C> common::CallBuilder for PermissionCreateCall<'a, C> {}
18172
18173impl<'a, C> PermissionCreateCall<'a, C>
18174where
18175 C: common::Connector,
18176{
18177 /// Perform the operation you have build so far.
18178 pub async fn doit(mut self) -> common::Result<(common::Response, Permission)> {
18179 use std::borrow::Cow;
18180 use std::io::{Read, Seek};
18181
18182 use common::{url::Params, ToParts};
18183 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18184
18185 let mut dd = common::DefaultDelegate;
18186 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18187 dlg.begin(common::MethodInfo {
18188 id: "drive.permissions.create",
18189 http_method: hyper::Method::POST,
18190 });
18191
18192 for &field in [
18193 "alt",
18194 "fileId",
18195 "useDomainAdminAccess",
18196 "transferOwnership",
18197 "supportsTeamDrives",
18198 "supportsAllDrives",
18199 "sendNotificationEmail",
18200 "moveToNewOwnersRoot",
18201 "enforceSingleParent",
18202 "enforceExpansiveAccess",
18203 "emailMessage",
18204 ]
18205 .iter()
18206 {
18207 if self._additional_params.contains_key(field) {
18208 dlg.finished(false);
18209 return Err(common::Error::FieldClash(field));
18210 }
18211 }
18212
18213 let mut params = Params::with_capacity(13 + self._additional_params.len());
18214 params.push("fileId", self._file_id);
18215 if let Some(value) = self._use_domain_admin_access.as_ref() {
18216 params.push("useDomainAdminAccess", value.to_string());
18217 }
18218 if let Some(value) = self._transfer_ownership.as_ref() {
18219 params.push("transferOwnership", value.to_string());
18220 }
18221 if let Some(value) = self._supports_team_drives.as_ref() {
18222 params.push("supportsTeamDrives", value.to_string());
18223 }
18224 if let Some(value) = self._supports_all_drives.as_ref() {
18225 params.push("supportsAllDrives", value.to_string());
18226 }
18227 if let Some(value) = self._send_notification_email.as_ref() {
18228 params.push("sendNotificationEmail", value.to_string());
18229 }
18230 if let Some(value) = self._move_to_new_owners_root.as_ref() {
18231 params.push("moveToNewOwnersRoot", value.to_string());
18232 }
18233 if let Some(value) = self._enforce_single_parent.as_ref() {
18234 params.push("enforceSingleParent", value.to_string());
18235 }
18236 if let Some(value) = self._enforce_expansive_access.as_ref() {
18237 params.push("enforceExpansiveAccess", value.to_string());
18238 }
18239 if let Some(value) = self._email_message.as_ref() {
18240 params.push("emailMessage", value);
18241 }
18242
18243 params.extend(self._additional_params.iter());
18244
18245 params.push("alt", "json");
18246 let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions";
18247 if self._scopes.is_empty() {
18248 self._scopes.insert(Scope::Full.as_ref().to_string());
18249 }
18250
18251 #[allow(clippy::single_element_loop)]
18252 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
18253 url = params.uri_replacement(url, param_name, find_this, false);
18254 }
18255 {
18256 let to_remove = ["fileId"];
18257 params.remove_params(&to_remove);
18258 }
18259
18260 let url = params.parse_with_url(&url);
18261
18262 let mut json_mime_type = mime::APPLICATION_JSON;
18263 let mut request_value_reader = {
18264 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18265 common::remove_json_null_values(&mut value);
18266 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18267 serde_json::to_writer(&mut dst, &value).unwrap();
18268 dst
18269 };
18270 let request_size = request_value_reader
18271 .seek(std::io::SeekFrom::End(0))
18272 .unwrap();
18273 request_value_reader
18274 .seek(std::io::SeekFrom::Start(0))
18275 .unwrap();
18276
18277 loop {
18278 let token = match self
18279 .hub
18280 .auth
18281 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18282 .await
18283 {
18284 Ok(token) => token,
18285 Err(e) => match dlg.token(e) {
18286 Ok(token) => token,
18287 Err(e) => {
18288 dlg.finished(false);
18289 return Err(common::Error::MissingToken(e));
18290 }
18291 },
18292 };
18293 request_value_reader
18294 .seek(std::io::SeekFrom::Start(0))
18295 .unwrap();
18296 let mut req_result = {
18297 let client = &self.hub.client;
18298 dlg.pre_request();
18299 let mut req_builder = hyper::Request::builder()
18300 .method(hyper::Method::POST)
18301 .uri(url.as_str())
18302 .header(USER_AGENT, self.hub._user_agent.clone());
18303
18304 if let Some(token) = token.as_ref() {
18305 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18306 }
18307
18308 let request = req_builder
18309 .header(CONTENT_TYPE, json_mime_type.to_string())
18310 .header(CONTENT_LENGTH, request_size as u64)
18311 .body(common::to_body(
18312 request_value_reader.get_ref().clone().into(),
18313 ));
18314
18315 client.request(request.unwrap()).await
18316 };
18317
18318 match req_result {
18319 Err(err) => {
18320 if let common::Retry::After(d) = dlg.http_error(&err) {
18321 sleep(d).await;
18322 continue;
18323 }
18324 dlg.finished(false);
18325 return Err(common::Error::HttpError(err));
18326 }
18327 Ok(res) => {
18328 let (mut parts, body) = res.into_parts();
18329 let mut body = common::Body::new(body);
18330 if !parts.status.is_success() {
18331 let bytes = common::to_bytes(body).await.unwrap_or_default();
18332 let error = serde_json::from_str(&common::to_string(&bytes));
18333 let response = common::to_response(parts, bytes.into());
18334
18335 if let common::Retry::After(d) =
18336 dlg.http_failure(&response, error.as_ref().ok())
18337 {
18338 sleep(d).await;
18339 continue;
18340 }
18341
18342 dlg.finished(false);
18343
18344 return Err(match error {
18345 Ok(value) => common::Error::BadRequest(value),
18346 _ => common::Error::Failure(response),
18347 });
18348 }
18349 let response = {
18350 let bytes = common::to_bytes(body).await.unwrap_or_default();
18351 let encoded = common::to_string(&bytes);
18352 match serde_json::from_str(&encoded) {
18353 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18354 Err(error) => {
18355 dlg.response_json_decode_error(&encoded, &error);
18356 return Err(common::Error::JsonDecodeError(
18357 encoded.to_string(),
18358 error,
18359 ));
18360 }
18361 }
18362 };
18363
18364 dlg.finished(true);
18365 return Ok(response);
18366 }
18367 }
18368 }
18369 }
18370
18371 ///
18372 /// Sets the *request* property to the given value.
18373 ///
18374 /// Even though the property as already been set when instantiating this call,
18375 /// we provide this method for API completeness.
18376 pub fn request(mut self, new_value: Permission) -> PermissionCreateCall<'a, C> {
18377 self._request = new_value;
18378 self
18379 }
18380 /// The ID of the file or shared drive.
18381 ///
18382 /// Sets the *file id* path property to the given value.
18383 ///
18384 /// Even though the property as already been set when instantiating this call,
18385 /// we provide this method for API completeness.
18386 pub fn file_id(mut self, new_value: &str) -> PermissionCreateCall<'a, C> {
18387 self._file_id = new_value.to_string();
18388 self
18389 }
18390 /// Issue the request as a domain administrator. If set to `true`, and if the following additional conditions are met, the requester is granted access: 1. The file ID parameter refers to a shared drive. 2. The requester is an administrator of the domain to which the shared drive belongs. For more information, see [Manage shared drives as domain administrators](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives#manage-administrators).
18391 ///
18392 /// Sets the *use domain admin access* query property to the given value.
18393 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionCreateCall<'a, C> {
18394 self._use_domain_admin_access = Some(new_value);
18395 self
18396 }
18397 /// Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect. For more information, see [Transfer file ownership](https://developers.google.com/workspace/drive/api/guides/transfer-file).
18398 ///
18399 /// Sets the *transfer ownership* query property to the given value.
18400 pub fn transfer_ownership(mut self, new_value: bool) -> PermissionCreateCall<'a, C> {
18401 self._transfer_ownership = Some(new_value);
18402 self
18403 }
18404 /// Deprecated: Use `supportsAllDrives` instead.
18405 ///
18406 /// Sets the *supports team drives* query property to the given value.
18407 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionCreateCall<'a, C> {
18408 self._supports_team_drives = Some(new_value);
18409 self
18410 }
18411 /// Whether the requesting application supports both My Drives and shared drives.
18412 ///
18413 /// Sets the *supports all drives* query property to the given value.
18414 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionCreateCall<'a, C> {
18415 self._supports_all_drives = Some(new_value);
18416 self
18417 }
18418 /// Whether to send a notification email when sharing to users or groups. This defaults to `true` for users and groups, and is not allowed for other requests. It must not be disabled for ownership transfers.
18419 ///
18420 /// Sets the *send notification email* query property to the given value.
18421 pub fn send_notification_email(mut self, new_value: bool) -> PermissionCreateCall<'a, C> {
18422 self._send_notification_email = Some(new_value);
18423 self
18424 }
18425 /// This parameter only takes effect if the item isn't in a shared drive and the request is attempting to transfer the ownership of the item. If set to `true`, the item is moved to the new owner's My Drive root folder and all prior parents removed. If set to `false`, parents aren't changed.
18426 ///
18427 /// Sets the *move to new owners root* query property to the given value.
18428 pub fn move_to_new_owners_root(mut self, new_value: bool) -> PermissionCreateCall<'a, C> {
18429 self._move_to_new_owners_root = Some(new_value);
18430 self
18431 }
18432 /// Deprecated: See `moveToNewOwnersRoot` for details.
18433 ///
18434 /// Sets the *enforce single parent* query property to the given value.
18435 pub fn enforce_single_parent(mut self, new_value: bool) -> PermissionCreateCall<'a, C> {
18436 self._enforce_single_parent = Some(new_value);
18437 self
18438 }
18439 /// Whether the request should enforce expansive access rules.
18440 ///
18441 /// Sets the *enforce expansive access* query property to the given value.
18442 pub fn enforce_expansive_access(mut self, new_value: bool) -> PermissionCreateCall<'a, C> {
18443 self._enforce_expansive_access = Some(new_value);
18444 self
18445 }
18446 /// A plain text custom message to include in the notification email.
18447 ///
18448 /// Sets the *email message* query property to the given value.
18449 pub fn email_message(mut self, new_value: &str) -> PermissionCreateCall<'a, C> {
18450 self._email_message = Some(new_value.to_string());
18451 self
18452 }
18453 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18454 /// while executing the actual API request.
18455 ///
18456 /// ````text
18457 /// It should be used to handle progress information, and to implement a certain level of resilience.
18458 /// ````
18459 ///
18460 /// Sets the *delegate* property to the given value.
18461 pub fn delegate(
18462 mut self,
18463 new_value: &'a mut dyn common::Delegate,
18464 ) -> PermissionCreateCall<'a, C> {
18465 self._delegate = Some(new_value);
18466 self
18467 }
18468
18469 /// Set any additional parameter of the query string used in the request.
18470 /// It should be used to set parameters which are not yet available through their own
18471 /// setters.
18472 ///
18473 /// Please note that this method must not be used to set any of the known parameters
18474 /// which have their own setter method. If done anyway, the request will fail.
18475 ///
18476 /// # Additional Parameters
18477 ///
18478 /// * *$.xgafv* (query-string) - V1 error format.
18479 /// * *access_token* (query-string) - OAuth access token.
18480 /// * *alt* (query-string) - Data format for response.
18481 /// * *callback* (query-string) - JSONP
18482 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18483 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18484 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18485 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18486 /// * *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.
18487 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18488 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18489 pub fn param<T>(mut self, name: T, value: T) -> PermissionCreateCall<'a, C>
18490 where
18491 T: AsRef<str>,
18492 {
18493 self._additional_params
18494 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18495 self
18496 }
18497
18498 /// Identifies the authorization scope for the method you are building.
18499 ///
18500 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18501 /// [`Scope::Full`].
18502 ///
18503 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18504 /// tokens for more than one scope.
18505 ///
18506 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18507 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18508 /// sufficient, a read-write scope will do as well.
18509 pub fn add_scope<St>(mut self, scope: St) -> PermissionCreateCall<'a, C>
18510 where
18511 St: AsRef<str>,
18512 {
18513 self._scopes.insert(String::from(scope.as_ref()));
18514 self
18515 }
18516 /// Identifies the authorization scope(s) for the method you are building.
18517 ///
18518 /// See [`Self::add_scope()`] for details.
18519 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionCreateCall<'a, C>
18520 where
18521 I: IntoIterator<Item = St>,
18522 St: AsRef<str>,
18523 {
18524 self._scopes
18525 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18526 self
18527 }
18528
18529 /// Removes all scopes, and no default scope will be used either.
18530 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18531 /// for details).
18532 pub fn clear_scopes(mut self) -> PermissionCreateCall<'a, C> {
18533 self._scopes.clear();
18534 self
18535 }
18536}
18537
18538/// Deletes a permission. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing). **Warning:** Concurrent permissions operations on the same file aren't supported; only the last update is applied.
18539///
18540/// A builder for the *delete* method supported by a *permission* resource.
18541/// It is not used directly, but through a [`PermissionMethods`] instance.
18542///
18543/// # Example
18544///
18545/// Instantiate a resource method builder
18546///
18547/// ```test_harness,no_run
18548/// # extern crate hyper;
18549/// # extern crate hyper_rustls;
18550/// # extern crate google_drive3 as drive3;
18551/// # async fn dox() {
18552/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18553///
18554/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18555/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18556/// # .with_native_roots()
18557/// # .unwrap()
18558/// # .https_only()
18559/// # .enable_http2()
18560/// # .build();
18561///
18562/// # let executor = hyper_util::rt::TokioExecutor::new();
18563/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18564/// # secret,
18565/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18566/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18567/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18568/// # ),
18569/// # ).build().await.unwrap();
18570///
18571/// # let client = hyper_util::client::legacy::Client::builder(
18572/// # hyper_util::rt::TokioExecutor::new()
18573/// # )
18574/// # .build(
18575/// # hyper_rustls::HttpsConnectorBuilder::new()
18576/// # .with_native_roots()
18577/// # .unwrap()
18578/// # .https_or_http()
18579/// # .enable_http2()
18580/// # .build()
18581/// # );
18582/// # let mut hub = DriveHub::new(client, auth);
18583/// // You can configure optional parameters by calling the respective setters at will, and
18584/// // execute the final call using `doit()`.
18585/// // Values shown here are possibly random and not representative !
18586/// let result = hub.permissions().delete("fileId", "permissionId")
18587/// .use_domain_admin_access(false)
18588/// .supports_team_drives(true)
18589/// .supports_all_drives(true)
18590/// .enforce_expansive_access(false)
18591/// .doit().await;
18592/// # }
18593/// ```
18594pub struct PermissionDeleteCall<'a, C>
18595where
18596 C: 'a,
18597{
18598 hub: &'a DriveHub<C>,
18599 _file_id: String,
18600 _permission_id: String,
18601 _use_domain_admin_access: Option<bool>,
18602 _supports_team_drives: Option<bool>,
18603 _supports_all_drives: Option<bool>,
18604 _enforce_expansive_access: Option<bool>,
18605 _delegate: Option<&'a mut dyn common::Delegate>,
18606 _additional_params: HashMap<String, String>,
18607 _scopes: BTreeSet<String>,
18608}
18609
18610impl<'a, C> common::CallBuilder for PermissionDeleteCall<'a, C> {}
18611
18612impl<'a, C> PermissionDeleteCall<'a, C>
18613where
18614 C: common::Connector,
18615{
18616 /// Perform the operation you have build so far.
18617 pub async fn doit(mut self) -> common::Result<common::Response> {
18618 use std::borrow::Cow;
18619 use std::io::{Read, Seek};
18620
18621 use common::{url::Params, ToParts};
18622 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18623
18624 let mut dd = common::DefaultDelegate;
18625 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18626 dlg.begin(common::MethodInfo {
18627 id: "drive.permissions.delete",
18628 http_method: hyper::Method::DELETE,
18629 });
18630
18631 for &field in [
18632 "fileId",
18633 "permissionId",
18634 "useDomainAdminAccess",
18635 "supportsTeamDrives",
18636 "supportsAllDrives",
18637 "enforceExpansiveAccess",
18638 ]
18639 .iter()
18640 {
18641 if self._additional_params.contains_key(field) {
18642 dlg.finished(false);
18643 return Err(common::Error::FieldClash(field));
18644 }
18645 }
18646
18647 let mut params = Params::with_capacity(7 + self._additional_params.len());
18648 params.push("fileId", self._file_id);
18649 params.push("permissionId", self._permission_id);
18650 if let Some(value) = self._use_domain_admin_access.as_ref() {
18651 params.push("useDomainAdminAccess", value.to_string());
18652 }
18653 if let Some(value) = self._supports_team_drives.as_ref() {
18654 params.push("supportsTeamDrives", value.to_string());
18655 }
18656 if let Some(value) = self._supports_all_drives.as_ref() {
18657 params.push("supportsAllDrives", value.to_string());
18658 }
18659 if let Some(value) = self._enforce_expansive_access.as_ref() {
18660 params.push("enforceExpansiveAccess", value.to_string());
18661 }
18662
18663 params.extend(self._additional_params.iter());
18664
18665 let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}";
18666 if self._scopes.is_empty() {
18667 self._scopes.insert(Scope::Full.as_ref().to_string());
18668 }
18669
18670 #[allow(clippy::single_element_loop)]
18671 for &(find_this, param_name) in
18672 [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter()
18673 {
18674 url = params.uri_replacement(url, param_name, find_this, false);
18675 }
18676 {
18677 let to_remove = ["permissionId", "fileId"];
18678 params.remove_params(&to_remove);
18679 }
18680
18681 let url = params.parse_with_url(&url);
18682
18683 loop {
18684 let token = match self
18685 .hub
18686 .auth
18687 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18688 .await
18689 {
18690 Ok(token) => token,
18691 Err(e) => match dlg.token(e) {
18692 Ok(token) => token,
18693 Err(e) => {
18694 dlg.finished(false);
18695 return Err(common::Error::MissingToken(e));
18696 }
18697 },
18698 };
18699 let mut req_result = {
18700 let client = &self.hub.client;
18701 dlg.pre_request();
18702 let mut req_builder = hyper::Request::builder()
18703 .method(hyper::Method::DELETE)
18704 .uri(url.as_str())
18705 .header(USER_AGENT, self.hub._user_agent.clone());
18706
18707 if let Some(token) = token.as_ref() {
18708 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18709 }
18710
18711 let request = req_builder
18712 .header(CONTENT_LENGTH, 0_u64)
18713 .body(common::to_body::<String>(None));
18714
18715 client.request(request.unwrap()).await
18716 };
18717
18718 match req_result {
18719 Err(err) => {
18720 if let common::Retry::After(d) = dlg.http_error(&err) {
18721 sleep(d).await;
18722 continue;
18723 }
18724 dlg.finished(false);
18725 return Err(common::Error::HttpError(err));
18726 }
18727 Ok(res) => {
18728 let (mut parts, body) = res.into_parts();
18729 let mut body = common::Body::new(body);
18730 if !parts.status.is_success() {
18731 let bytes = common::to_bytes(body).await.unwrap_or_default();
18732 let error = serde_json::from_str(&common::to_string(&bytes));
18733 let response = common::to_response(parts, bytes.into());
18734
18735 if let common::Retry::After(d) =
18736 dlg.http_failure(&response, error.as_ref().ok())
18737 {
18738 sleep(d).await;
18739 continue;
18740 }
18741
18742 dlg.finished(false);
18743
18744 return Err(match error {
18745 Ok(value) => common::Error::BadRequest(value),
18746 _ => common::Error::Failure(response),
18747 });
18748 }
18749 let response = common::Response::from_parts(parts, body);
18750
18751 dlg.finished(true);
18752 return Ok(response);
18753 }
18754 }
18755 }
18756 }
18757
18758 /// The ID of the file or shared drive.
18759 ///
18760 /// Sets the *file id* path property to the given value.
18761 ///
18762 /// Even though the property as already been set when instantiating this call,
18763 /// we provide this method for API completeness.
18764 pub fn file_id(mut self, new_value: &str) -> PermissionDeleteCall<'a, C> {
18765 self._file_id = new_value.to_string();
18766 self
18767 }
18768 /// The ID of the permission.
18769 ///
18770 /// Sets the *permission id* path property to the given value.
18771 ///
18772 /// Even though the property as already been set when instantiating this call,
18773 /// we provide this method for API completeness.
18774 pub fn permission_id(mut self, new_value: &str) -> PermissionDeleteCall<'a, C> {
18775 self._permission_id = new_value.to_string();
18776 self
18777 }
18778 /// Issue the request as a domain administrator. If set to `true`, and if the following additional conditions are met, the requester is granted access: 1. The file ID parameter refers to a shared drive. 2. The requester is an administrator of the domain to which the shared drive belongs. For more information, see [Manage shared drives as domain administrators](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives#manage-administrators).
18779 ///
18780 /// Sets the *use domain admin access* query property to the given value.
18781 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionDeleteCall<'a, C> {
18782 self._use_domain_admin_access = Some(new_value);
18783 self
18784 }
18785 /// Deprecated: Use `supportsAllDrives` instead.
18786 ///
18787 /// Sets the *supports team drives* query property to the given value.
18788 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionDeleteCall<'a, C> {
18789 self._supports_team_drives = Some(new_value);
18790 self
18791 }
18792 /// Whether the requesting application supports both My Drives and shared drives.
18793 ///
18794 /// Sets the *supports all drives* query property to the given value.
18795 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionDeleteCall<'a, C> {
18796 self._supports_all_drives = Some(new_value);
18797 self
18798 }
18799 /// Whether the request should enforce expansive access rules.
18800 ///
18801 /// Sets the *enforce expansive access* query property to the given value.
18802 pub fn enforce_expansive_access(mut self, new_value: bool) -> PermissionDeleteCall<'a, C> {
18803 self._enforce_expansive_access = Some(new_value);
18804 self
18805 }
18806 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18807 /// while executing the actual API request.
18808 ///
18809 /// ````text
18810 /// It should be used to handle progress information, and to implement a certain level of resilience.
18811 /// ````
18812 ///
18813 /// Sets the *delegate* property to the given value.
18814 pub fn delegate(
18815 mut self,
18816 new_value: &'a mut dyn common::Delegate,
18817 ) -> PermissionDeleteCall<'a, C> {
18818 self._delegate = Some(new_value);
18819 self
18820 }
18821
18822 /// Set any additional parameter of the query string used in the request.
18823 /// It should be used to set parameters which are not yet available through their own
18824 /// setters.
18825 ///
18826 /// Please note that this method must not be used to set any of the known parameters
18827 /// which have their own setter method. If done anyway, the request will fail.
18828 ///
18829 /// # Additional Parameters
18830 ///
18831 /// * *$.xgafv* (query-string) - V1 error format.
18832 /// * *access_token* (query-string) - OAuth access token.
18833 /// * *alt* (query-string) - Data format for response.
18834 /// * *callback* (query-string) - JSONP
18835 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18836 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18837 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18838 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18839 /// * *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.
18840 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18841 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18842 pub fn param<T>(mut self, name: T, value: T) -> PermissionDeleteCall<'a, C>
18843 where
18844 T: AsRef<str>,
18845 {
18846 self._additional_params
18847 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18848 self
18849 }
18850
18851 /// Identifies the authorization scope for the method you are building.
18852 ///
18853 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18854 /// [`Scope::Full`].
18855 ///
18856 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18857 /// tokens for more than one scope.
18858 ///
18859 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18860 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18861 /// sufficient, a read-write scope will do as well.
18862 pub fn add_scope<St>(mut self, scope: St) -> PermissionDeleteCall<'a, C>
18863 where
18864 St: AsRef<str>,
18865 {
18866 self._scopes.insert(String::from(scope.as_ref()));
18867 self
18868 }
18869 /// Identifies the authorization scope(s) for the method you are building.
18870 ///
18871 /// See [`Self::add_scope()`] for details.
18872 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionDeleteCall<'a, C>
18873 where
18874 I: IntoIterator<Item = St>,
18875 St: AsRef<str>,
18876 {
18877 self._scopes
18878 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18879 self
18880 }
18881
18882 /// Removes all scopes, and no default scope will be used either.
18883 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18884 /// for details).
18885 pub fn clear_scopes(mut self) -> PermissionDeleteCall<'a, C> {
18886 self._scopes.clear();
18887 self
18888 }
18889}
18890
18891/// Gets a permission by ID. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing).
18892///
18893/// A builder for the *get* method supported by a *permission* resource.
18894/// It is not used directly, but through a [`PermissionMethods`] instance.
18895///
18896/// # Example
18897///
18898/// Instantiate a resource method builder
18899///
18900/// ```test_harness,no_run
18901/// # extern crate hyper;
18902/// # extern crate hyper_rustls;
18903/// # extern crate google_drive3 as drive3;
18904/// # async fn dox() {
18905/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18906///
18907/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18908/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18909/// # .with_native_roots()
18910/// # .unwrap()
18911/// # .https_only()
18912/// # .enable_http2()
18913/// # .build();
18914///
18915/// # let executor = hyper_util::rt::TokioExecutor::new();
18916/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18917/// # secret,
18918/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18919/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18920/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18921/// # ),
18922/// # ).build().await.unwrap();
18923///
18924/// # let client = hyper_util::client::legacy::Client::builder(
18925/// # hyper_util::rt::TokioExecutor::new()
18926/// # )
18927/// # .build(
18928/// # hyper_rustls::HttpsConnectorBuilder::new()
18929/// # .with_native_roots()
18930/// # .unwrap()
18931/// # .https_or_http()
18932/// # .enable_http2()
18933/// # .build()
18934/// # );
18935/// # let mut hub = DriveHub::new(client, auth);
18936/// // You can configure optional parameters by calling the respective setters at will, and
18937/// // execute the final call using `doit()`.
18938/// // Values shown here are possibly random and not representative !
18939/// let result = hub.permissions().get("fileId", "permissionId")
18940/// .use_domain_admin_access(false)
18941/// .supports_team_drives(false)
18942/// .supports_all_drives(false)
18943/// .doit().await;
18944/// # }
18945/// ```
18946pub struct PermissionGetCall<'a, C>
18947where
18948 C: 'a,
18949{
18950 hub: &'a DriveHub<C>,
18951 _file_id: String,
18952 _permission_id: String,
18953 _use_domain_admin_access: Option<bool>,
18954 _supports_team_drives: Option<bool>,
18955 _supports_all_drives: Option<bool>,
18956 _delegate: Option<&'a mut dyn common::Delegate>,
18957 _additional_params: HashMap<String, String>,
18958 _scopes: BTreeSet<String>,
18959}
18960
18961impl<'a, C> common::CallBuilder for PermissionGetCall<'a, C> {}
18962
18963impl<'a, C> PermissionGetCall<'a, C>
18964where
18965 C: common::Connector,
18966{
18967 /// Perform the operation you have build so far.
18968 pub async fn doit(mut self) -> common::Result<(common::Response, Permission)> {
18969 use std::borrow::Cow;
18970 use std::io::{Read, Seek};
18971
18972 use common::{url::Params, ToParts};
18973 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18974
18975 let mut dd = common::DefaultDelegate;
18976 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18977 dlg.begin(common::MethodInfo {
18978 id: "drive.permissions.get",
18979 http_method: hyper::Method::GET,
18980 });
18981
18982 for &field in [
18983 "alt",
18984 "fileId",
18985 "permissionId",
18986 "useDomainAdminAccess",
18987 "supportsTeamDrives",
18988 "supportsAllDrives",
18989 ]
18990 .iter()
18991 {
18992 if self._additional_params.contains_key(field) {
18993 dlg.finished(false);
18994 return Err(common::Error::FieldClash(field));
18995 }
18996 }
18997
18998 let mut params = Params::with_capacity(7 + self._additional_params.len());
18999 params.push("fileId", self._file_id);
19000 params.push("permissionId", self._permission_id);
19001 if let Some(value) = self._use_domain_admin_access.as_ref() {
19002 params.push("useDomainAdminAccess", value.to_string());
19003 }
19004 if let Some(value) = self._supports_team_drives.as_ref() {
19005 params.push("supportsTeamDrives", value.to_string());
19006 }
19007 if let Some(value) = self._supports_all_drives.as_ref() {
19008 params.push("supportsAllDrives", value.to_string());
19009 }
19010
19011 params.extend(self._additional_params.iter());
19012
19013 params.push("alt", "json");
19014 let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}";
19015 if self._scopes.is_empty() {
19016 self._scopes
19017 .insert(Scope::MeetReadonly.as_ref().to_string());
19018 }
19019
19020 #[allow(clippy::single_element_loop)]
19021 for &(find_this, param_name) in
19022 [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter()
19023 {
19024 url = params.uri_replacement(url, param_name, find_this, false);
19025 }
19026 {
19027 let to_remove = ["permissionId", "fileId"];
19028 params.remove_params(&to_remove);
19029 }
19030
19031 let url = params.parse_with_url(&url);
19032
19033 loop {
19034 let token = match self
19035 .hub
19036 .auth
19037 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19038 .await
19039 {
19040 Ok(token) => token,
19041 Err(e) => match dlg.token(e) {
19042 Ok(token) => token,
19043 Err(e) => {
19044 dlg.finished(false);
19045 return Err(common::Error::MissingToken(e));
19046 }
19047 },
19048 };
19049 let mut req_result = {
19050 let client = &self.hub.client;
19051 dlg.pre_request();
19052 let mut req_builder = hyper::Request::builder()
19053 .method(hyper::Method::GET)
19054 .uri(url.as_str())
19055 .header(USER_AGENT, self.hub._user_agent.clone());
19056
19057 if let Some(token) = token.as_ref() {
19058 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19059 }
19060
19061 let request = req_builder
19062 .header(CONTENT_LENGTH, 0_u64)
19063 .body(common::to_body::<String>(None));
19064
19065 client.request(request.unwrap()).await
19066 };
19067
19068 match req_result {
19069 Err(err) => {
19070 if let common::Retry::After(d) = dlg.http_error(&err) {
19071 sleep(d).await;
19072 continue;
19073 }
19074 dlg.finished(false);
19075 return Err(common::Error::HttpError(err));
19076 }
19077 Ok(res) => {
19078 let (mut parts, body) = res.into_parts();
19079 let mut body = common::Body::new(body);
19080 if !parts.status.is_success() {
19081 let bytes = common::to_bytes(body).await.unwrap_or_default();
19082 let error = serde_json::from_str(&common::to_string(&bytes));
19083 let response = common::to_response(parts, bytes.into());
19084
19085 if let common::Retry::After(d) =
19086 dlg.http_failure(&response, error.as_ref().ok())
19087 {
19088 sleep(d).await;
19089 continue;
19090 }
19091
19092 dlg.finished(false);
19093
19094 return Err(match error {
19095 Ok(value) => common::Error::BadRequest(value),
19096 _ => common::Error::Failure(response),
19097 });
19098 }
19099 let response = {
19100 let bytes = common::to_bytes(body).await.unwrap_or_default();
19101 let encoded = common::to_string(&bytes);
19102 match serde_json::from_str(&encoded) {
19103 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19104 Err(error) => {
19105 dlg.response_json_decode_error(&encoded, &error);
19106 return Err(common::Error::JsonDecodeError(
19107 encoded.to_string(),
19108 error,
19109 ));
19110 }
19111 }
19112 };
19113
19114 dlg.finished(true);
19115 return Ok(response);
19116 }
19117 }
19118 }
19119 }
19120
19121 /// The ID of the file.
19122 ///
19123 /// Sets the *file id* path property to the given value.
19124 ///
19125 /// Even though the property as already been set when instantiating this call,
19126 /// we provide this method for API completeness.
19127 pub fn file_id(mut self, new_value: &str) -> PermissionGetCall<'a, C> {
19128 self._file_id = new_value.to_string();
19129 self
19130 }
19131 /// The ID of the permission.
19132 ///
19133 /// Sets the *permission id* path property to the given value.
19134 ///
19135 /// Even though the property as already been set when instantiating this call,
19136 /// we provide this method for API completeness.
19137 pub fn permission_id(mut self, new_value: &str) -> PermissionGetCall<'a, C> {
19138 self._permission_id = new_value.to_string();
19139 self
19140 }
19141 /// Issue the request as a domain administrator. If set to `true`, and if the following additional conditions are met, the requester is granted access: 1. The file ID parameter refers to a shared drive. 2. The requester is an administrator of the domain to which the shared drive belongs. For more information, see [Manage shared drives as domain administrators](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives#manage-administrators).
19142 ///
19143 /// Sets the *use domain admin access* query property to the given value.
19144 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionGetCall<'a, C> {
19145 self._use_domain_admin_access = Some(new_value);
19146 self
19147 }
19148 /// Deprecated: Use `supportsAllDrives` instead.
19149 ///
19150 /// Sets the *supports team drives* query property to the given value.
19151 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionGetCall<'a, C> {
19152 self._supports_team_drives = Some(new_value);
19153 self
19154 }
19155 /// Whether the requesting application supports both My Drives and shared drives.
19156 ///
19157 /// Sets the *supports all drives* query property to the given value.
19158 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionGetCall<'a, C> {
19159 self._supports_all_drives = Some(new_value);
19160 self
19161 }
19162 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19163 /// while executing the actual API request.
19164 ///
19165 /// ````text
19166 /// It should be used to handle progress information, and to implement a certain level of resilience.
19167 /// ````
19168 ///
19169 /// Sets the *delegate* property to the given value.
19170 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PermissionGetCall<'a, C> {
19171 self._delegate = Some(new_value);
19172 self
19173 }
19174
19175 /// Set any additional parameter of the query string used in the request.
19176 /// It should be used to set parameters which are not yet available through their own
19177 /// setters.
19178 ///
19179 /// Please note that this method must not be used to set any of the known parameters
19180 /// which have their own setter method. If done anyway, the request will fail.
19181 ///
19182 /// # Additional Parameters
19183 ///
19184 /// * *$.xgafv* (query-string) - V1 error format.
19185 /// * *access_token* (query-string) - OAuth access token.
19186 /// * *alt* (query-string) - Data format for response.
19187 /// * *callback* (query-string) - JSONP
19188 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19189 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19190 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19191 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19192 /// * *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.
19193 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19194 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19195 pub fn param<T>(mut self, name: T, value: T) -> PermissionGetCall<'a, C>
19196 where
19197 T: AsRef<str>,
19198 {
19199 self._additional_params
19200 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19201 self
19202 }
19203
19204 /// Identifies the authorization scope for the method you are building.
19205 ///
19206 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19207 /// [`Scope::MeetReadonly`].
19208 ///
19209 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19210 /// tokens for more than one scope.
19211 ///
19212 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19213 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19214 /// sufficient, a read-write scope will do as well.
19215 pub fn add_scope<St>(mut self, scope: St) -> PermissionGetCall<'a, C>
19216 where
19217 St: AsRef<str>,
19218 {
19219 self._scopes.insert(String::from(scope.as_ref()));
19220 self
19221 }
19222 /// Identifies the authorization scope(s) for the method you are building.
19223 ///
19224 /// See [`Self::add_scope()`] for details.
19225 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionGetCall<'a, C>
19226 where
19227 I: IntoIterator<Item = St>,
19228 St: AsRef<str>,
19229 {
19230 self._scopes
19231 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19232 self
19233 }
19234
19235 /// Removes all scopes, and no default scope will be used either.
19236 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19237 /// for details).
19238 pub fn clear_scopes(mut self) -> PermissionGetCall<'a, C> {
19239 self._scopes.clear();
19240 self
19241 }
19242}
19243
19244/// Lists a file's or shared drive's permissions. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing).
19245///
19246/// A builder for the *list* method supported by a *permission* resource.
19247/// It is not used directly, but through a [`PermissionMethods`] instance.
19248///
19249/// # Example
19250///
19251/// Instantiate a resource method builder
19252///
19253/// ```test_harness,no_run
19254/// # extern crate hyper;
19255/// # extern crate hyper_rustls;
19256/// # extern crate google_drive3 as drive3;
19257/// # async fn dox() {
19258/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19259///
19260/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19261/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19262/// # .with_native_roots()
19263/// # .unwrap()
19264/// # .https_only()
19265/// # .enable_http2()
19266/// # .build();
19267///
19268/// # let executor = hyper_util::rt::TokioExecutor::new();
19269/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19270/// # secret,
19271/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19272/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19273/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19274/// # ),
19275/// # ).build().await.unwrap();
19276///
19277/// # let client = hyper_util::client::legacy::Client::builder(
19278/// # hyper_util::rt::TokioExecutor::new()
19279/// # )
19280/// # .build(
19281/// # hyper_rustls::HttpsConnectorBuilder::new()
19282/// # .with_native_roots()
19283/// # .unwrap()
19284/// # .https_or_http()
19285/// # .enable_http2()
19286/// # .build()
19287/// # );
19288/// # let mut hub = DriveHub::new(client, auth);
19289/// // You can configure optional parameters by calling the respective setters at will, and
19290/// // execute the final call using `doit()`.
19291/// // Values shown here are possibly random and not representative !
19292/// let result = hub.permissions().list("fileId")
19293/// .use_domain_admin_access(false)
19294/// .supports_team_drives(true)
19295/// .supports_all_drives(true)
19296/// .page_token("sea")
19297/// .page_size(-50)
19298/// .include_permissions_for_view("Stet")
19299/// .doit().await;
19300/// # }
19301/// ```
19302pub struct PermissionListCall<'a, C>
19303where
19304 C: 'a,
19305{
19306 hub: &'a DriveHub<C>,
19307 _file_id: String,
19308 _use_domain_admin_access: Option<bool>,
19309 _supports_team_drives: Option<bool>,
19310 _supports_all_drives: Option<bool>,
19311 _page_token: Option<String>,
19312 _page_size: Option<i32>,
19313 _include_permissions_for_view: Option<String>,
19314 _delegate: Option<&'a mut dyn common::Delegate>,
19315 _additional_params: HashMap<String, String>,
19316 _scopes: BTreeSet<String>,
19317}
19318
19319impl<'a, C> common::CallBuilder for PermissionListCall<'a, C> {}
19320
19321impl<'a, C> PermissionListCall<'a, C>
19322where
19323 C: common::Connector,
19324{
19325 /// Perform the operation you have build so far.
19326 pub async fn doit(mut self) -> common::Result<(common::Response, PermissionList)> {
19327 use std::borrow::Cow;
19328 use std::io::{Read, Seek};
19329
19330 use common::{url::Params, ToParts};
19331 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19332
19333 let mut dd = common::DefaultDelegate;
19334 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19335 dlg.begin(common::MethodInfo {
19336 id: "drive.permissions.list",
19337 http_method: hyper::Method::GET,
19338 });
19339
19340 for &field in [
19341 "alt",
19342 "fileId",
19343 "useDomainAdminAccess",
19344 "supportsTeamDrives",
19345 "supportsAllDrives",
19346 "pageToken",
19347 "pageSize",
19348 "includePermissionsForView",
19349 ]
19350 .iter()
19351 {
19352 if self._additional_params.contains_key(field) {
19353 dlg.finished(false);
19354 return Err(common::Error::FieldClash(field));
19355 }
19356 }
19357
19358 let mut params = Params::with_capacity(9 + self._additional_params.len());
19359 params.push("fileId", self._file_id);
19360 if let Some(value) = self._use_domain_admin_access.as_ref() {
19361 params.push("useDomainAdminAccess", value.to_string());
19362 }
19363 if let Some(value) = self._supports_team_drives.as_ref() {
19364 params.push("supportsTeamDrives", value.to_string());
19365 }
19366 if let Some(value) = self._supports_all_drives.as_ref() {
19367 params.push("supportsAllDrives", value.to_string());
19368 }
19369 if let Some(value) = self._page_token.as_ref() {
19370 params.push("pageToken", value);
19371 }
19372 if let Some(value) = self._page_size.as_ref() {
19373 params.push("pageSize", value.to_string());
19374 }
19375 if let Some(value) = self._include_permissions_for_view.as_ref() {
19376 params.push("includePermissionsForView", 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}/permissions";
19383 if self._scopes.is_empty() {
19384 self._scopes
19385 .insert(Scope::MeetReadonly.as_ref().to_string());
19386 }
19387
19388 #[allow(clippy::single_element_loop)]
19389 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
19390 url = params.uri_replacement(url, param_name, find_this, false);
19391 }
19392 {
19393 let to_remove = ["fileId"];
19394 params.remove_params(&to_remove);
19395 }
19396
19397 let url = params.parse_with_url(&url);
19398
19399 loop {
19400 let token = match self
19401 .hub
19402 .auth
19403 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19404 .await
19405 {
19406 Ok(token) => token,
19407 Err(e) => match dlg.token(e) {
19408 Ok(token) => token,
19409 Err(e) => {
19410 dlg.finished(false);
19411 return Err(common::Error::MissingToken(e));
19412 }
19413 },
19414 };
19415 let mut req_result = {
19416 let client = &self.hub.client;
19417 dlg.pre_request();
19418 let mut req_builder = hyper::Request::builder()
19419 .method(hyper::Method::GET)
19420 .uri(url.as_str())
19421 .header(USER_AGENT, self.hub._user_agent.clone());
19422
19423 if let Some(token) = token.as_ref() {
19424 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19425 }
19426
19427 let request = req_builder
19428 .header(CONTENT_LENGTH, 0_u64)
19429 .body(common::to_body::<String>(None));
19430
19431 client.request(request.unwrap()).await
19432 };
19433
19434 match req_result {
19435 Err(err) => {
19436 if let common::Retry::After(d) = dlg.http_error(&err) {
19437 sleep(d).await;
19438 continue;
19439 }
19440 dlg.finished(false);
19441 return Err(common::Error::HttpError(err));
19442 }
19443 Ok(res) => {
19444 let (mut parts, body) = res.into_parts();
19445 let mut body = common::Body::new(body);
19446 if !parts.status.is_success() {
19447 let bytes = common::to_bytes(body).await.unwrap_or_default();
19448 let error = serde_json::from_str(&common::to_string(&bytes));
19449 let response = common::to_response(parts, bytes.into());
19450
19451 if let common::Retry::After(d) =
19452 dlg.http_failure(&response, error.as_ref().ok())
19453 {
19454 sleep(d).await;
19455 continue;
19456 }
19457
19458 dlg.finished(false);
19459
19460 return Err(match error {
19461 Ok(value) => common::Error::BadRequest(value),
19462 _ => common::Error::Failure(response),
19463 });
19464 }
19465 let response = {
19466 let bytes = common::to_bytes(body).await.unwrap_or_default();
19467 let encoded = common::to_string(&bytes);
19468 match serde_json::from_str(&encoded) {
19469 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19470 Err(error) => {
19471 dlg.response_json_decode_error(&encoded, &error);
19472 return Err(common::Error::JsonDecodeError(
19473 encoded.to_string(),
19474 error,
19475 ));
19476 }
19477 }
19478 };
19479
19480 dlg.finished(true);
19481 return Ok(response);
19482 }
19483 }
19484 }
19485 }
19486
19487 /// The ID of the file or shared drive.
19488 ///
19489 /// Sets the *file id* path property to the given value.
19490 ///
19491 /// Even though the property as already been set when instantiating this call,
19492 /// we provide this method for API completeness.
19493 pub fn file_id(mut self, new_value: &str) -> PermissionListCall<'a, C> {
19494 self._file_id = new_value.to_string();
19495 self
19496 }
19497 /// Issue the request as a domain administrator. If set to `true`, and if the following additional conditions are met, the requester is granted access: 1. The file ID parameter refers to a shared drive. 2. The requester is an administrator of the domain to which the shared drive belongs. For more information, see [Manage shared drives as domain administrators](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives#manage-administrators).
19498 ///
19499 /// Sets the *use domain admin access* query property to the given value.
19500 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionListCall<'a, C> {
19501 self._use_domain_admin_access = Some(new_value);
19502 self
19503 }
19504 /// Deprecated: Use `supportsAllDrives` instead.
19505 ///
19506 /// Sets the *supports team drives* query property to the given value.
19507 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionListCall<'a, C> {
19508 self._supports_team_drives = Some(new_value);
19509 self
19510 }
19511 /// Whether the requesting application supports both My Drives and shared drives.
19512 ///
19513 /// Sets the *supports all drives* query property to the given value.
19514 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionListCall<'a, C> {
19515 self._supports_all_drives = Some(new_value);
19516 self
19517 }
19518 /// 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.
19519 ///
19520 /// Sets the *page token* query property to the given value.
19521 pub fn page_token(mut self, new_value: &str) -> PermissionListCall<'a, C> {
19522 self._page_token = Some(new_value.to_string());
19523 self
19524 }
19525 /// 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.
19526 ///
19527 /// Sets the *page size* query property to the given value.
19528 pub fn page_size(mut self, new_value: i32) -> PermissionListCall<'a, C> {
19529 self._page_size = Some(new_value);
19530 self
19531 }
19532 /// Specifies which additional view's permissions to include in the response. Only `published` is supported.
19533 ///
19534 /// Sets the *include permissions for view* query property to the given value.
19535 pub fn include_permissions_for_view(mut self, new_value: &str) -> PermissionListCall<'a, C> {
19536 self._include_permissions_for_view = Some(new_value.to_string());
19537 self
19538 }
19539 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19540 /// while executing the actual API request.
19541 ///
19542 /// ````text
19543 /// It should be used to handle progress information, and to implement a certain level of resilience.
19544 /// ````
19545 ///
19546 /// Sets the *delegate* property to the given value.
19547 pub fn delegate(
19548 mut self,
19549 new_value: &'a mut dyn common::Delegate,
19550 ) -> PermissionListCall<'a, C> {
19551 self._delegate = Some(new_value);
19552 self
19553 }
19554
19555 /// Set any additional parameter of the query string used in the request.
19556 /// It should be used to set parameters which are not yet available through their own
19557 /// setters.
19558 ///
19559 /// Please note that this method must not be used to set any of the known parameters
19560 /// which have their own setter method. If done anyway, the request will fail.
19561 ///
19562 /// # Additional Parameters
19563 ///
19564 /// * *$.xgafv* (query-string) - V1 error format.
19565 /// * *access_token* (query-string) - OAuth access token.
19566 /// * *alt* (query-string) - Data format for response.
19567 /// * *callback* (query-string) - JSONP
19568 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19569 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19570 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19571 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19572 /// * *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.
19573 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19574 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19575 pub fn param<T>(mut self, name: T, value: T) -> PermissionListCall<'a, C>
19576 where
19577 T: AsRef<str>,
19578 {
19579 self._additional_params
19580 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19581 self
19582 }
19583
19584 /// Identifies the authorization scope for the method you are building.
19585 ///
19586 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19587 /// [`Scope::MeetReadonly`].
19588 ///
19589 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19590 /// tokens for more than one scope.
19591 ///
19592 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19593 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19594 /// sufficient, a read-write scope will do as well.
19595 pub fn add_scope<St>(mut self, scope: St) -> PermissionListCall<'a, C>
19596 where
19597 St: AsRef<str>,
19598 {
19599 self._scopes.insert(String::from(scope.as_ref()));
19600 self
19601 }
19602 /// Identifies the authorization scope(s) for the method you are building.
19603 ///
19604 /// See [`Self::add_scope()`] for details.
19605 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionListCall<'a, C>
19606 where
19607 I: IntoIterator<Item = St>,
19608 St: AsRef<str>,
19609 {
19610 self._scopes
19611 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19612 self
19613 }
19614
19615 /// Removes all scopes, and no default scope will be used either.
19616 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19617 /// for details).
19618 pub fn clear_scopes(mut self) -> PermissionListCall<'a, C> {
19619 self._scopes.clear();
19620 self
19621 }
19622}
19623
19624/// Updates a permission with patch semantics. For more information, see [Share files, folders, and drives](https://developers.google.com/workspace/drive/api/guides/manage-sharing). **Warning:** Concurrent permissions operations on the same file aren't supported; only the last update is applied.
19625///
19626/// A builder for the *update* method supported by a *permission* resource.
19627/// It is not used directly, but through a [`PermissionMethods`] instance.
19628///
19629/// # Example
19630///
19631/// Instantiate a resource method builder
19632///
19633/// ```test_harness,no_run
19634/// # extern crate hyper;
19635/// # extern crate hyper_rustls;
19636/// # extern crate google_drive3 as drive3;
19637/// use drive3::api::Permission;
19638/// # async fn dox() {
19639/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19640///
19641/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19642/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19643/// # .with_native_roots()
19644/// # .unwrap()
19645/// # .https_only()
19646/// # .enable_http2()
19647/// # .build();
19648///
19649/// # let executor = hyper_util::rt::TokioExecutor::new();
19650/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19651/// # secret,
19652/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19653/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19654/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19655/// # ),
19656/// # ).build().await.unwrap();
19657///
19658/// # let client = hyper_util::client::legacy::Client::builder(
19659/// # hyper_util::rt::TokioExecutor::new()
19660/// # )
19661/// # .build(
19662/// # hyper_rustls::HttpsConnectorBuilder::new()
19663/// # .with_native_roots()
19664/// # .unwrap()
19665/// # .https_or_http()
19666/// # .enable_http2()
19667/// # .build()
19668/// # );
19669/// # let mut hub = DriveHub::new(client, auth);
19670/// // As the method needs a request, you would usually fill it with the desired information
19671/// // into the respective structure. Some of the parts shown here might not be applicable !
19672/// // Values shown here are possibly random and not representative !
19673/// let mut req = Permission::default();
19674///
19675/// // You can configure optional parameters by calling the respective setters at will, and
19676/// // execute the final call using `doit()`.
19677/// // Values shown here are possibly random and not representative !
19678/// let result = hub.permissions().update(req, "fileId", "permissionId")
19679/// .use_domain_admin_access(true)
19680/// .transfer_ownership(false)
19681/// .supports_team_drives(true)
19682/// .supports_all_drives(true)
19683/// .remove_expiration(false)
19684/// .enforce_expansive_access(false)
19685/// .doit().await;
19686/// # }
19687/// ```
19688pub struct PermissionUpdateCall<'a, C>
19689where
19690 C: 'a,
19691{
19692 hub: &'a DriveHub<C>,
19693 _request: Permission,
19694 _file_id: String,
19695 _permission_id: String,
19696 _use_domain_admin_access: Option<bool>,
19697 _transfer_ownership: Option<bool>,
19698 _supports_team_drives: Option<bool>,
19699 _supports_all_drives: Option<bool>,
19700 _remove_expiration: Option<bool>,
19701 _enforce_expansive_access: Option<bool>,
19702 _delegate: Option<&'a mut dyn common::Delegate>,
19703 _additional_params: HashMap<String, String>,
19704 _scopes: BTreeSet<String>,
19705}
19706
19707impl<'a, C> common::CallBuilder for PermissionUpdateCall<'a, C> {}
19708
19709impl<'a, C> PermissionUpdateCall<'a, C>
19710where
19711 C: common::Connector,
19712{
19713 /// Perform the operation you have build so far.
19714 pub async fn doit(mut self) -> common::Result<(common::Response, Permission)> {
19715 use std::borrow::Cow;
19716 use std::io::{Read, Seek};
19717
19718 use common::{url::Params, ToParts};
19719 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19720
19721 let mut dd = common::DefaultDelegate;
19722 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19723 dlg.begin(common::MethodInfo {
19724 id: "drive.permissions.update",
19725 http_method: hyper::Method::PATCH,
19726 });
19727
19728 for &field in [
19729 "alt",
19730 "fileId",
19731 "permissionId",
19732 "useDomainAdminAccess",
19733 "transferOwnership",
19734 "supportsTeamDrives",
19735 "supportsAllDrives",
19736 "removeExpiration",
19737 "enforceExpansiveAccess",
19738 ]
19739 .iter()
19740 {
19741 if self._additional_params.contains_key(field) {
19742 dlg.finished(false);
19743 return Err(common::Error::FieldClash(field));
19744 }
19745 }
19746
19747 let mut params = Params::with_capacity(11 + self._additional_params.len());
19748 params.push("fileId", self._file_id);
19749 params.push("permissionId", self._permission_id);
19750 if let Some(value) = self._use_domain_admin_access.as_ref() {
19751 params.push("useDomainAdminAccess", value.to_string());
19752 }
19753 if let Some(value) = self._transfer_ownership.as_ref() {
19754 params.push("transferOwnership", value.to_string());
19755 }
19756 if let Some(value) = self._supports_team_drives.as_ref() {
19757 params.push("supportsTeamDrives", value.to_string());
19758 }
19759 if let Some(value) = self._supports_all_drives.as_ref() {
19760 params.push("supportsAllDrives", value.to_string());
19761 }
19762 if let Some(value) = self._remove_expiration.as_ref() {
19763 params.push("removeExpiration", value.to_string());
19764 }
19765 if let Some(value) = self._enforce_expansive_access.as_ref() {
19766 params.push("enforceExpansiveAccess", value.to_string());
19767 }
19768
19769 params.extend(self._additional_params.iter());
19770
19771 params.push("alt", "json");
19772 let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}";
19773 if self._scopes.is_empty() {
19774 self._scopes.insert(Scope::Full.as_ref().to_string());
19775 }
19776
19777 #[allow(clippy::single_element_loop)]
19778 for &(find_this, param_name) in
19779 [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter()
19780 {
19781 url = params.uri_replacement(url, param_name, find_this, false);
19782 }
19783 {
19784 let to_remove = ["permissionId", "fileId"];
19785 params.remove_params(&to_remove);
19786 }
19787
19788 let url = params.parse_with_url(&url);
19789
19790 let mut json_mime_type = mime::APPLICATION_JSON;
19791 let mut request_value_reader = {
19792 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19793 common::remove_json_null_values(&mut value);
19794 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19795 serde_json::to_writer(&mut dst, &value).unwrap();
19796 dst
19797 };
19798 let request_size = request_value_reader
19799 .seek(std::io::SeekFrom::End(0))
19800 .unwrap();
19801 request_value_reader
19802 .seek(std::io::SeekFrom::Start(0))
19803 .unwrap();
19804
19805 loop {
19806 let token = match self
19807 .hub
19808 .auth
19809 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19810 .await
19811 {
19812 Ok(token) => token,
19813 Err(e) => match dlg.token(e) {
19814 Ok(token) => token,
19815 Err(e) => {
19816 dlg.finished(false);
19817 return Err(common::Error::MissingToken(e));
19818 }
19819 },
19820 };
19821 request_value_reader
19822 .seek(std::io::SeekFrom::Start(0))
19823 .unwrap();
19824 let mut req_result = {
19825 let client = &self.hub.client;
19826 dlg.pre_request();
19827 let mut req_builder = hyper::Request::builder()
19828 .method(hyper::Method::PATCH)
19829 .uri(url.as_str())
19830 .header(USER_AGENT, self.hub._user_agent.clone());
19831
19832 if let Some(token) = token.as_ref() {
19833 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19834 }
19835
19836 let request = req_builder
19837 .header(CONTENT_TYPE, json_mime_type.to_string())
19838 .header(CONTENT_LENGTH, request_size as u64)
19839 .body(common::to_body(
19840 request_value_reader.get_ref().clone().into(),
19841 ));
19842
19843 client.request(request.unwrap()).await
19844 };
19845
19846 match req_result {
19847 Err(err) => {
19848 if let common::Retry::After(d) = dlg.http_error(&err) {
19849 sleep(d).await;
19850 continue;
19851 }
19852 dlg.finished(false);
19853 return Err(common::Error::HttpError(err));
19854 }
19855 Ok(res) => {
19856 let (mut parts, body) = res.into_parts();
19857 let mut body = common::Body::new(body);
19858 if !parts.status.is_success() {
19859 let bytes = common::to_bytes(body).await.unwrap_or_default();
19860 let error = serde_json::from_str(&common::to_string(&bytes));
19861 let response = common::to_response(parts, bytes.into());
19862
19863 if let common::Retry::After(d) =
19864 dlg.http_failure(&response, error.as_ref().ok())
19865 {
19866 sleep(d).await;
19867 continue;
19868 }
19869
19870 dlg.finished(false);
19871
19872 return Err(match error {
19873 Ok(value) => common::Error::BadRequest(value),
19874 _ => common::Error::Failure(response),
19875 });
19876 }
19877 let response = {
19878 let bytes = common::to_bytes(body).await.unwrap_or_default();
19879 let encoded = common::to_string(&bytes);
19880 match serde_json::from_str(&encoded) {
19881 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19882 Err(error) => {
19883 dlg.response_json_decode_error(&encoded, &error);
19884 return Err(common::Error::JsonDecodeError(
19885 encoded.to_string(),
19886 error,
19887 ));
19888 }
19889 }
19890 };
19891
19892 dlg.finished(true);
19893 return Ok(response);
19894 }
19895 }
19896 }
19897 }
19898
19899 ///
19900 /// Sets the *request* property to the given value.
19901 ///
19902 /// Even though the property as already been set when instantiating this call,
19903 /// we provide this method for API completeness.
19904 pub fn request(mut self, new_value: Permission) -> PermissionUpdateCall<'a, C> {
19905 self._request = new_value;
19906 self
19907 }
19908 /// The ID of the file or shared drive.
19909 ///
19910 /// Sets the *file id* path property to the given value.
19911 ///
19912 /// Even though the property as already been set when instantiating this call,
19913 /// we provide this method for API completeness.
19914 pub fn file_id(mut self, new_value: &str) -> PermissionUpdateCall<'a, C> {
19915 self._file_id = new_value.to_string();
19916 self
19917 }
19918 /// The ID of the permission.
19919 ///
19920 /// Sets the *permission id* path property to the given value.
19921 ///
19922 /// Even though the property as already been set when instantiating this call,
19923 /// we provide this method for API completeness.
19924 pub fn permission_id(mut self, new_value: &str) -> PermissionUpdateCall<'a, C> {
19925 self._permission_id = new_value.to_string();
19926 self
19927 }
19928 /// Issue the request as a domain administrator. If set to `true`, and if the following additional conditions are met, the requester is granted access: 1. The file ID parameter refers to a shared drive. 2. The requester is an administrator of the domain to which the shared drive belongs. For more information, see [Manage shared drives as domain administrators](https://developers.google.com/workspace/drive/api/guides/manage-shareddrives#manage-administrators).
19929 ///
19930 /// Sets the *use domain admin access* query property to the given value.
19931 pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
19932 self._use_domain_admin_access = Some(new_value);
19933 self
19934 }
19935 /// Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect. For more information, see [Transfer file ownership](https://developers.google.com//workspace/drive/api/guides/transfer-file).
19936 ///
19937 /// Sets the *transfer ownership* query property to the given value.
19938 pub fn transfer_ownership(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
19939 self._transfer_ownership = Some(new_value);
19940 self
19941 }
19942 /// Deprecated: Use `supportsAllDrives` instead.
19943 ///
19944 /// Sets the *supports team drives* query property to the given value.
19945 pub fn supports_team_drives(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
19946 self._supports_team_drives = Some(new_value);
19947 self
19948 }
19949 /// Whether the requesting application supports both My Drives and shared drives.
19950 ///
19951 /// Sets the *supports all drives* query property to the given value.
19952 pub fn supports_all_drives(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
19953 self._supports_all_drives = Some(new_value);
19954 self
19955 }
19956 /// Whether to remove the expiration date.
19957 ///
19958 /// Sets the *remove expiration* query property to the given value.
19959 pub fn remove_expiration(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
19960 self._remove_expiration = Some(new_value);
19961 self
19962 }
19963 /// Whether the request should enforce expansive access rules.
19964 ///
19965 /// Sets the *enforce expansive access* query property to the given value.
19966 pub fn enforce_expansive_access(mut self, new_value: bool) -> PermissionUpdateCall<'a, C> {
19967 self._enforce_expansive_access = Some(new_value);
19968 self
19969 }
19970 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19971 /// while executing the actual API request.
19972 ///
19973 /// ````text
19974 /// It should be used to handle progress information, and to implement a certain level of resilience.
19975 /// ````
19976 ///
19977 /// Sets the *delegate* property to the given value.
19978 pub fn delegate(
19979 mut self,
19980 new_value: &'a mut dyn common::Delegate,
19981 ) -> PermissionUpdateCall<'a, C> {
19982 self._delegate = Some(new_value);
19983 self
19984 }
19985
19986 /// Set any additional parameter of the query string used in the request.
19987 /// It should be used to set parameters which are not yet available through their own
19988 /// setters.
19989 ///
19990 /// Please note that this method must not be used to set any of the known parameters
19991 /// which have their own setter method. If done anyway, the request will fail.
19992 ///
19993 /// # Additional Parameters
19994 ///
19995 /// * *$.xgafv* (query-string) - V1 error format.
19996 /// * *access_token* (query-string) - OAuth access token.
19997 /// * *alt* (query-string) - Data format for response.
19998 /// * *callback* (query-string) - JSONP
19999 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20000 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20001 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20002 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20003 /// * *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.
20004 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20005 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20006 pub fn param<T>(mut self, name: T, value: T) -> PermissionUpdateCall<'a, C>
20007 where
20008 T: AsRef<str>,
20009 {
20010 self._additional_params
20011 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20012 self
20013 }
20014
20015 /// Identifies the authorization scope for the method you are building.
20016 ///
20017 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20018 /// [`Scope::Full`].
20019 ///
20020 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20021 /// tokens for more than one scope.
20022 ///
20023 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20024 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20025 /// sufficient, a read-write scope will do as well.
20026 pub fn add_scope<St>(mut self, scope: St) -> PermissionUpdateCall<'a, C>
20027 where
20028 St: AsRef<str>,
20029 {
20030 self._scopes.insert(String::from(scope.as_ref()));
20031 self
20032 }
20033 /// Identifies the authorization scope(s) for the method you are building.
20034 ///
20035 /// See [`Self::add_scope()`] for details.
20036 pub fn add_scopes<I, St>(mut self, scopes: I) -> PermissionUpdateCall<'a, C>
20037 where
20038 I: IntoIterator<Item = St>,
20039 St: AsRef<str>,
20040 {
20041 self._scopes
20042 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20043 self
20044 }
20045
20046 /// Removes all scopes, and no default scope will be used either.
20047 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20048 /// for details).
20049 pub fn clear_scopes(mut self) -> PermissionUpdateCall<'a, C> {
20050 self._scopes.clear();
20051 self
20052 }
20053}
20054
20055/// Creates a reply to a comment. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
20056///
20057/// A builder for the *create* method supported by a *reply* resource.
20058/// It is not used directly, but through a [`ReplyMethods`] instance.
20059///
20060/// # Example
20061///
20062/// Instantiate a resource method builder
20063///
20064/// ```test_harness,no_run
20065/// # extern crate hyper;
20066/// # extern crate hyper_rustls;
20067/// # extern crate google_drive3 as drive3;
20068/// use drive3::api::Reply;
20069/// # async fn dox() {
20070/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20071///
20072/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20073/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20074/// # .with_native_roots()
20075/// # .unwrap()
20076/// # .https_only()
20077/// # .enable_http2()
20078/// # .build();
20079///
20080/// # let executor = hyper_util::rt::TokioExecutor::new();
20081/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20082/// # secret,
20083/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20084/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20085/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20086/// # ),
20087/// # ).build().await.unwrap();
20088///
20089/// # let client = hyper_util::client::legacy::Client::builder(
20090/// # hyper_util::rt::TokioExecutor::new()
20091/// # )
20092/// # .build(
20093/// # hyper_rustls::HttpsConnectorBuilder::new()
20094/// # .with_native_roots()
20095/// # .unwrap()
20096/// # .https_or_http()
20097/// # .enable_http2()
20098/// # .build()
20099/// # );
20100/// # let mut hub = DriveHub::new(client, auth);
20101/// // As the method needs a request, you would usually fill it with the desired information
20102/// // into the respective structure. Some of the parts shown here might not be applicable !
20103/// // Values shown here are possibly random and not representative !
20104/// let mut req = Reply::default();
20105///
20106/// // You can configure optional parameters by calling the respective setters at will, and
20107/// // execute the final call using `doit()`.
20108/// // Values shown here are possibly random and not representative !
20109/// let result = hub.replies().create(req, "fileId", "commentId")
20110/// .doit().await;
20111/// # }
20112/// ```
20113pub struct ReplyCreateCall<'a, C>
20114where
20115 C: 'a,
20116{
20117 hub: &'a DriveHub<C>,
20118 _request: Reply,
20119 _file_id: String,
20120 _comment_id: String,
20121 _delegate: Option<&'a mut dyn common::Delegate>,
20122 _additional_params: HashMap<String, String>,
20123 _scopes: BTreeSet<String>,
20124}
20125
20126impl<'a, C> common::CallBuilder for ReplyCreateCall<'a, C> {}
20127
20128impl<'a, C> ReplyCreateCall<'a, C>
20129where
20130 C: common::Connector,
20131{
20132 /// Perform the operation you have build so far.
20133 pub async fn doit(mut self) -> common::Result<(common::Response, Reply)> {
20134 use std::borrow::Cow;
20135 use std::io::{Read, Seek};
20136
20137 use common::{url::Params, ToParts};
20138 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20139
20140 let mut dd = common::DefaultDelegate;
20141 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20142 dlg.begin(common::MethodInfo {
20143 id: "drive.replies.create",
20144 http_method: hyper::Method::POST,
20145 });
20146
20147 for &field in ["alt", "fileId", "commentId"].iter() {
20148 if self._additional_params.contains_key(field) {
20149 dlg.finished(false);
20150 return Err(common::Error::FieldClash(field));
20151 }
20152 }
20153
20154 let mut params = Params::with_capacity(5 + self._additional_params.len());
20155 params.push("fileId", self._file_id);
20156 params.push("commentId", self._comment_id);
20157
20158 params.extend(self._additional_params.iter());
20159
20160 params.push("alt", "json");
20161 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies";
20162 if self._scopes.is_empty() {
20163 self._scopes.insert(Scope::Full.as_ref().to_string());
20164 }
20165
20166 #[allow(clippy::single_element_loop)]
20167 for &(find_this, param_name) in
20168 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
20169 {
20170 url = params.uri_replacement(url, param_name, find_this, false);
20171 }
20172 {
20173 let to_remove = ["commentId", "fileId"];
20174 params.remove_params(&to_remove);
20175 }
20176
20177 let url = params.parse_with_url(&url);
20178
20179 let mut json_mime_type = mime::APPLICATION_JSON;
20180 let mut request_value_reader = {
20181 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20182 common::remove_json_null_values(&mut value);
20183 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20184 serde_json::to_writer(&mut dst, &value).unwrap();
20185 dst
20186 };
20187 let request_size = request_value_reader
20188 .seek(std::io::SeekFrom::End(0))
20189 .unwrap();
20190 request_value_reader
20191 .seek(std::io::SeekFrom::Start(0))
20192 .unwrap();
20193
20194 loop {
20195 let token = match self
20196 .hub
20197 .auth
20198 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20199 .await
20200 {
20201 Ok(token) => token,
20202 Err(e) => match dlg.token(e) {
20203 Ok(token) => token,
20204 Err(e) => {
20205 dlg.finished(false);
20206 return Err(common::Error::MissingToken(e));
20207 }
20208 },
20209 };
20210 request_value_reader
20211 .seek(std::io::SeekFrom::Start(0))
20212 .unwrap();
20213 let mut req_result = {
20214 let client = &self.hub.client;
20215 dlg.pre_request();
20216 let mut req_builder = hyper::Request::builder()
20217 .method(hyper::Method::POST)
20218 .uri(url.as_str())
20219 .header(USER_AGENT, self.hub._user_agent.clone());
20220
20221 if let Some(token) = token.as_ref() {
20222 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20223 }
20224
20225 let request = req_builder
20226 .header(CONTENT_TYPE, json_mime_type.to_string())
20227 .header(CONTENT_LENGTH, request_size as u64)
20228 .body(common::to_body(
20229 request_value_reader.get_ref().clone().into(),
20230 ));
20231
20232 client.request(request.unwrap()).await
20233 };
20234
20235 match req_result {
20236 Err(err) => {
20237 if let common::Retry::After(d) = dlg.http_error(&err) {
20238 sleep(d).await;
20239 continue;
20240 }
20241 dlg.finished(false);
20242 return Err(common::Error::HttpError(err));
20243 }
20244 Ok(res) => {
20245 let (mut parts, body) = res.into_parts();
20246 let mut body = common::Body::new(body);
20247 if !parts.status.is_success() {
20248 let bytes = common::to_bytes(body).await.unwrap_or_default();
20249 let error = serde_json::from_str(&common::to_string(&bytes));
20250 let response = common::to_response(parts, bytes.into());
20251
20252 if let common::Retry::After(d) =
20253 dlg.http_failure(&response, error.as_ref().ok())
20254 {
20255 sleep(d).await;
20256 continue;
20257 }
20258
20259 dlg.finished(false);
20260
20261 return Err(match error {
20262 Ok(value) => common::Error::BadRequest(value),
20263 _ => common::Error::Failure(response),
20264 });
20265 }
20266 let response = {
20267 let bytes = common::to_bytes(body).await.unwrap_or_default();
20268 let encoded = common::to_string(&bytes);
20269 match serde_json::from_str(&encoded) {
20270 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20271 Err(error) => {
20272 dlg.response_json_decode_error(&encoded, &error);
20273 return Err(common::Error::JsonDecodeError(
20274 encoded.to_string(),
20275 error,
20276 ));
20277 }
20278 }
20279 };
20280
20281 dlg.finished(true);
20282 return Ok(response);
20283 }
20284 }
20285 }
20286 }
20287
20288 ///
20289 /// Sets the *request* property to the given value.
20290 ///
20291 /// Even though the property as already been set when instantiating this call,
20292 /// we provide this method for API completeness.
20293 pub fn request(mut self, new_value: Reply) -> ReplyCreateCall<'a, C> {
20294 self._request = new_value;
20295 self
20296 }
20297 /// The ID of the file.
20298 ///
20299 /// Sets the *file id* path property to the given value.
20300 ///
20301 /// Even though the property as already been set when instantiating this call,
20302 /// we provide this method for API completeness.
20303 pub fn file_id(mut self, new_value: &str) -> ReplyCreateCall<'a, C> {
20304 self._file_id = new_value.to_string();
20305 self
20306 }
20307 /// The ID of the comment.
20308 ///
20309 /// Sets the *comment id* path property to the given value.
20310 ///
20311 /// Even though the property as already been set when instantiating this call,
20312 /// we provide this method for API completeness.
20313 pub fn comment_id(mut self, new_value: &str) -> ReplyCreateCall<'a, C> {
20314 self._comment_id = new_value.to_string();
20315 self
20316 }
20317 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20318 /// while executing the actual API request.
20319 ///
20320 /// ````text
20321 /// It should be used to handle progress information, and to implement a certain level of resilience.
20322 /// ````
20323 ///
20324 /// Sets the *delegate* property to the given value.
20325 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyCreateCall<'a, C> {
20326 self._delegate = Some(new_value);
20327 self
20328 }
20329
20330 /// Set any additional parameter of the query string used in the request.
20331 /// It should be used to set parameters which are not yet available through their own
20332 /// setters.
20333 ///
20334 /// Please note that this method must not be used to set any of the known parameters
20335 /// which have their own setter method. If done anyway, the request will fail.
20336 ///
20337 /// # Additional Parameters
20338 ///
20339 /// * *$.xgafv* (query-string) - V1 error format.
20340 /// * *access_token* (query-string) - OAuth access token.
20341 /// * *alt* (query-string) - Data format for response.
20342 /// * *callback* (query-string) - JSONP
20343 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20344 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20345 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20346 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20347 /// * *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.
20348 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20349 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20350 pub fn param<T>(mut self, name: T, value: T) -> ReplyCreateCall<'a, C>
20351 where
20352 T: AsRef<str>,
20353 {
20354 self._additional_params
20355 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20356 self
20357 }
20358
20359 /// Identifies the authorization scope for the method you are building.
20360 ///
20361 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20362 /// [`Scope::Full`].
20363 ///
20364 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20365 /// tokens for more than one scope.
20366 ///
20367 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20368 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20369 /// sufficient, a read-write scope will do as well.
20370 pub fn add_scope<St>(mut self, scope: St) -> ReplyCreateCall<'a, C>
20371 where
20372 St: AsRef<str>,
20373 {
20374 self._scopes.insert(String::from(scope.as_ref()));
20375 self
20376 }
20377 /// Identifies the authorization scope(s) for the method you are building.
20378 ///
20379 /// See [`Self::add_scope()`] for details.
20380 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyCreateCall<'a, C>
20381 where
20382 I: IntoIterator<Item = St>,
20383 St: AsRef<str>,
20384 {
20385 self._scopes
20386 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20387 self
20388 }
20389
20390 /// Removes all scopes, and no default scope will be used either.
20391 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20392 /// for details).
20393 pub fn clear_scopes(mut self) -> ReplyCreateCall<'a, C> {
20394 self._scopes.clear();
20395 self
20396 }
20397}
20398
20399/// Deletes a reply. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
20400///
20401/// A builder for the *delete* method supported by a *reply* resource.
20402/// It is not used directly, but through a [`ReplyMethods`] instance.
20403///
20404/// # Example
20405///
20406/// Instantiate a resource method builder
20407///
20408/// ```test_harness,no_run
20409/// # extern crate hyper;
20410/// # extern crate hyper_rustls;
20411/// # extern crate google_drive3 as drive3;
20412/// # async fn dox() {
20413/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20414///
20415/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20416/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20417/// # .with_native_roots()
20418/// # .unwrap()
20419/// # .https_only()
20420/// # .enable_http2()
20421/// # .build();
20422///
20423/// # let executor = hyper_util::rt::TokioExecutor::new();
20424/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20425/// # secret,
20426/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20427/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20428/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20429/// # ),
20430/// # ).build().await.unwrap();
20431///
20432/// # let client = hyper_util::client::legacy::Client::builder(
20433/// # hyper_util::rt::TokioExecutor::new()
20434/// # )
20435/// # .build(
20436/// # hyper_rustls::HttpsConnectorBuilder::new()
20437/// # .with_native_roots()
20438/// # .unwrap()
20439/// # .https_or_http()
20440/// # .enable_http2()
20441/// # .build()
20442/// # );
20443/// # let mut hub = DriveHub::new(client, auth);
20444/// // You can configure optional parameters by calling the respective setters at will, and
20445/// // execute the final call using `doit()`.
20446/// // Values shown here are possibly random and not representative !
20447/// let result = hub.replies().delete("fileId", "commentId", "replyId")
20448/// .doit().await;
20449/// # }
20450/// ```
20451pub struct ReplyDeleteCall<'a, C>
20452where
20453 C: 'a,
20454{
20455 hub: &'a DriveHub<C>,
20456 _file_id: String,
20457 _comment_id: String,
20458 _reply_id: String,
20459 _delegate: Option<&'a mut dyn common::Delegate>,
20460 _additional_params: HashMap<String, String>,
20461 _scopes: BTreeSet<String>,
20462}
20463
20464impl<'a, C> common::CallBuilder for ReplyDeleteCall<'a, C> {}
20465
20466impl<'a, C> ReplyDeleteCall<'a, C>
20467where
20468 C: common::Connector,
20469{
20470 /// Perform the operation you have build so far.
20471 pub async fn doit(mut self) -> common::Result<common::Response> {
20472 use std::borrow::Cow;
20473 use std::io::{Read, Seek};
20474
20475 use common::{url::Params, ToParts};
20476 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20477
20478 let mut dd = common::DefaultDelegate;
20479 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20480 dlg.begin(common::MethodInfo {
20481 id: "drive.replies.delete",
20482 http_method: hyper::Method::DELETE,
20483 });
20484
20485 for &field in ["fileId", "commentId", "replyId"].iter() {
20486 if self._additional_params.contains_key(field) {
20487 dlg.finished(false);
20488 return Err(common::Error::FieldClash(field));
20489 }
20490 }
20491
20492 let mut params = Params::with_capacity(4 + self._additional_params.len());
20493 params.push("fileId", self._file_id);
20494 params.push("commentId", self._comment_id);
20495 params.push("replyId", self._reply_id);
20496
20497 params.extend(self._additional_params.iter());
20498
20499 let mut url =
20500 self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}";
20501 if self._scopes.is_empty() {
20502 self._scopes.insert(Scope::Full.as_ref().to_string());
20503 }
20504
20505 #[allow(clippy::single_element_loop)]
20506 for &(find_this, param_name) in [
20507 ("{fileId}", "fileId"),
20508 ("{commentId}", "commentId"),
20509 ("{replyId}", "replyId"),
20510 ]
20511 .iter()
20512 {
20513 url = params.uri_replacement(url, param_name, find_this, false);
20514 }
20515 {
20516 let to_remove = ["replyId", "commentId", "fileId"];
20517 params.remove_params(&to_remove);
20518 }
20519
20520 let url = params.parse_with_url(&url);
20521
20522 loop {
20523 let token = match self
20524 .hub
20525 .auth
20526 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20527 .await
20528 {
20529 Ok(token) => token,
20530 Err(e) => match dlg.token(e) {
20531 Ok(token) => token,
20532 Err(e) => {
20533 dlg.finished(false);
20534 return Err(common::Error::MissingToken(e));
20535 }
20536 },
20537 };
20538 let mut req_result = {
20539 let client = &self.hub.client;
20540 dlg.pre_request();
20541 let mut req_builder = hyper::Request::builder()
20542 .method(hyper::Method::DELETE)
20543 .uri(url.as_str())
20544 .header(USER_AGENT, self.hub._user_agent.clone());
20545
20546 if let Some(token) = token.as_ref() {
20547 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20548 }
20549
20550 let request = req_builder
20551 .header(CONTENT_LENGTH, 0_u64)
20552 .body(common::to_body::<String>(None));
20553
20554 client.request(request.unwrap()).await
20555 };
20556
20557 match req_result {
20558 Err(err) => {
20559 if let common::Retry::After(d) = dlg.http_error(&err) {
20560 sleep(d).await;
20561 continue;
20562 }
20563 dlg.finished(false);
20564 return Err(common::Error::HttpError(err));
20565 }
20566 Ok(res) => {
20567 let (mut parts, body) = res.into_parts();
20568 let mut body = common::Body::new(body);
20569 if !parts.status.is_success() {
20570 let bytes = common::to_bytes(body).await.unwrap_or_default();
20571 let error = serde_json::from_str(&common::to_string(&bytes));
20572 let response = common::to_response(parts, bytes.into());
20573
20574 if let common::Retry::After(d) =
20575 dlg.http_failure(&response, error.as_ref().ok())
20576 {
20577 sleep(d).await;
20578 continue;
20579 }
20580
20581 dlg.finished(false);
20582
20583 return Err(match error {
20584 Ok(value) => common::Error::BadRequest(value),
20585 _ => common::Error::Failure(response),
20586 });
20587 }
20588 let response = common::Response::from_parts(parts, body);
20589
20590 dlg.finished(true);
20591 return Ok(response);
20592 }
20593 }
20594 }
20595 }
20596
20597 /// The ID of the file.
20598 ///
20599 /// Sets the *file id* path property to the given value.
20600 ///
20601 /// Even though the property as already been set when instantiating this call,
20602 /// we provide this method for API completeness.
20603 pub fn file_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, C> {
20604 self._file_id = new_value.to_string();
20605 self
20606 }
20607 /// The ID of the comment.
20608 ///
20609 /// Sets the *comment id* path property to the given value.
20610 ///
20611 /// Even though the property as already been set when instantiating this call,
20612 /// we provide this method for API completeness.
20613 pub fn comment_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, C> {
20614 self._comment_id = new_value.to_string();
20615 self
20616 }
20617 /// The ID of the reply.
20618 ///
20619 /// Sets the *reply id* path property to the given value.
20620 ///
20621 /// Even though the property as already been set when instantiating this call,
20622 /// we provide this method for API completeness.
20623 pub fn reply_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, C> {
20624 self._reply_id = new_value.to_string();
20625 self
20626 }
20627 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20628 /// while executing the actual API request.
20629 ///
20630 /// ````text
20631 /// It should be used to handle progress information, and to implement a certain level of resilience.
20632 /// ````
20633 ///
20634 /// Sets the *delegate* property to the given value.
20635 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyDeleteCall<'a, C> {
20636 self._delegate = Some(new_value);
20637 self
20638 }
20639
20640 /// Set any additional parameter of the query string used in the request.
20641 /// It should be used to set parameters which are not yet available through their own
20642 /// setters.
20643 ///
20644 /// Please note that this method must not be used to set any of the known parameters
20645 /// which have their own setter method. If done anyway, the request will fail.
20646 ///
20647 /// # Additional Parameters
20648 ///
20649 /// * *$.xgafv* (query-string) - V1 error format.
20650 /// * *access_token* (query-string) - OAuth access token.
20651 /// * *alt* (query-string) - Data format for response.
20652 /// * *callback* (query-string) - JSONP
20653 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20654 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20655 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20656 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20657 /// * *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.
20658 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20659 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20660 pub fn param<T>(mut self, name: T, value: T) -> ReplyDeleteCall<'a, C>
20661 where
20662 T: AsRef<str>,
20663 {
20664 self._additional_params
20665 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20666 self
20667 }
20668
20669 /// Identifies the authorization scope for the method you are building.
20670 ///
20671 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20672 /// [`Scope::Full`].
20673 ///
20674 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20675 /// tokens for more than one scope.
20676 ///
20677 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20678 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20679 /// sufficient, a read-write scope will do as well.
20680 pub fn add_scope<St>(mut self, scope: St) -> ReplyDeleteCall<'a, C>
20681 where
20682 St: AsRef<str>,
20683 {
20684 self._scopes.insert(String::from(scope.as_ref()));
20685 self
20686 }
20687 /// Identifies the authorization scope(s) for the method you are building.
20688 ///
20689 /// See [`Self::add_scope()`] for details.
20690 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyDeleteCall<'a, C>
20691 where
20692 I: IntoIterator<Item = St>,
20693 St: AsRef<str>,
20694 {
20695 self._scopes
20696 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20697 self
20698 }
20699
20700 /// Removes all scopes, and no default scope will be used either.
20701 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20702 /// for details).
20703 pub fn clear_scopes(mut self) -> ReplyDeleteCall<'a, C> {
20704 self._scopes.clear();
20705 self
20706 }
20707}
20708
20709/// Gets a reply by ID. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
20710///
20711/// A builder for the *get* method supported by a *reply* resource.
20712/// It is not used directly, but through a [`ReplyMethods`] instance.
20713///
20714/// # Example
20715///
20716/// Instantiate a resource method builder
20717///
20718/// ```test_harness,no_run
20719/// # extern crate hyper;
20720/// # extern crate hyper_rustls;
20721/// # extern crate google_drive3 as drive3;
20722/// # async fn dox() {
20723/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20724///
20725/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20726/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20727/// # .with_native_roots()
20728/// # .unwrap()
20729/// # .https_only()
20730/// # .enable_http2()
20731/// # .build();
20732///
20733/// # let executor = hyper_util::rt::TokioExecutor::new();
20734/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20735/// # secret,
20736/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20737/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20738/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20739/// # ),
20740/// # ).build().await.unwrap();
20741///
20742/// # let client = hyper_util::client::legacy::Client::builder(
20743/// # hyper_util::rt::TokioExecutor::new()
20744/// # )
20745/// # .build(
20746/// # hyper_rustls::HttpsConnectorBuilder::new()
20747/// # .with_native_roots()
20748/// # .unwrap()
20749/// # .https_or_http()
20750/// # .enable_http2()
20751/// # .build()
20752/// # );
20753/// # let mut hub = DriveHub::new(client, auth);
20754/// // You can configure optional parameters by calling the respective setters at will, and
20755/// // execute the final call using `doit()`.
20756/// // Values shown here are possibly random and not representative !
20757/// let result = hub.replies().get("fileId", "commentId", "replyId")
20758/// .include_deleted(false)
20759/// .doit().await;
20760/// # }
20761/// ```
20762pub struct ReplyGetCall<'a, C>
20763where
20764 C: 'a,
20765{
20766 hub: &'a DriveHub<C>,
20767 _file_id: String,
20768 _comment_id: String,
20769 _reply_id: String,
20770 _include_deleted: Option<bool>,
20771 _delegate: Option<&'a mut dyn common::Delegate>,
20772 _additional_params: HashMap<String, String>,
20773 _scopes: BTreeSet<String>,
20774}
20775
20776impl<'a, C> common::CallBuilder for ReplyGetCall<'a, C> {}
20777
20778impl<'a, C> ReplyGetCall<'a, C>
20779where
20780 C: common::Connector,
20781{
20782 /// Perform the operation you have build so far.
20783 pub async fn doit(mut self) -> common::Result<(common::Response, Reply)> {
20784 use std::borrow::Cow;
20785 use std::io::{Read, Seek};
20786
20787 use common::{url::Params, ToParts};
20788 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20789
20790 let mut dd = common::DefaultDelegate;
20791 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20792 dlg.begin(common::MethodInfo {
20793 id: "drive.replies.get",
20794 http_method: hyper::Method::GET,
20795 });
20796
20797 for &field in ["alt", "fileId", "commentId", "replyId", "includeDeleted"].iter() {
20798 if self._additional_params.contains_key(field) {
20799 dlg.finished(false);
20800 return Err(common::Error::FieldClash(field));
20801 }
20802 }
20803
20804 let mut params = Params::with_capacity(6 + self._additional_params.len());
20805 params.push("fileId", self._file_id);
20806 params.push("commentId", self._comment_id);
20807 params.push("replyId", self._reply_id);
20808 if let Some(value) = self._include_deleted.as_ref() {
20809 params.push("includeDeleted", value.to_string());
20810 }
20811
20812 params.extend(self._additional_params.iter());
20813
20814 params.push("alt", "json");
20815 let mut url =
20816 self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}";
20817 if self._scopes.is_empty() {
20818 self._scopes
20819 .insert(Scope::MeetReadonly.as_ref().to_string());
20820 }
20821
20822 #[allow(clippy::single_element_loop)]
20823 for &(find_this, param_name) in [
20824 ("{fileId}", "fileId"),
20825 ("{commentId}", "commentId"),
20826 ("{replyId}", "replyId"),
20827 ]
20828 .iter()
20829 {
20830 url = params.uri_replacement(url, param_name, find_this, false);
20831 }
20832 {
20833 let to_remove = ["replyId", "commentId", "fileId"];
20834 params.remove_params(&to_remove);
20835 }
20836
20837 let url = params.parse_with_url(&url);
20838
20839 loop {
20840 let token = match self
20841 .hub
20842 .auth
20843 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20844 .await
20845 {
20846 Ok(token) => token,
20847 Err(e) => match dlg.token(e) {
20848 Ok(token) => token,
20849 Err(e) => {
20850 dlg.finished(false);
20851 return Err(common::Error::MissingToken(e));
20852 }
20853 },
20854 };
20855 let mut req_result = {
20856 let client = &self.hub.client;
20857 dlg.pre_request();
20858 let mut req_builder = hyper::Request::builder()
20859 .method(hyper::Method::GET)
20860 .uri(url.as_str())
20861 .header(USER_AGENT, self.hub._user_agent.clone());
20862
20863 if let Some(token) = token.as_ref() {
20864 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20865 }
20866
20867 let request = req_builder
20868 .header(CONTENT_LENGTH, 0_u64)
20869 .body(common::to_body::<String>(None));
20870
20871 client.request(request.unwrap()).await
20872 };
20873
20874 match req_result {
20875 Err(err) => {
20876 if let common::Retry::After(d) = dlg.http_error(&err) {
20877 sleep(d).await;
20878 continue;
20879 }
20880 dlg.finished(false);
20881 return Err(common::Error::HttpError(err));
20882 }
20883 Ok(res) => {
20884 let (mut parts, body) = res.into_parts();
20885 let mut body = common::Body::new(body);
20886 if !parts.status.is_success() {
20887 let bytes = common::to_bytes(body).await.unwrap_or_default();
20888 let error = serde_json::from_str(&common::to_string(&bytes));
20889 let response = common::to_response(parts, bytes.into());
20890
20891 if let common::Retry::After(d) =
20892 dlg.http_failure(&response, error.as_ref().ok())
20893 {
20894 sleep(d).await;
20895 continue;
20896 }
20897
20898 dlg.finished(false);
20899
20900 return Err(match error {
20901 Ok(value) => common::Error::BadRequest(value),
20902 _ => common::Error::Failure(response),
20903 });
20904 }
20905 let response = {
20906 let bytes = common::to_bytes(body).await.unwrap_or_default();
20907 let encoded = common::to_string(&bytes);
20908 match serde_json::from_str(&encoded) {
20909 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20910 Err(error) => {
20911 dlg.response_json_decode_error(&encoded, &error);
20912 return Err(common::Error::JsonDecodeError(
20913 encoded.to_string(),
20914 error,
20915 ));
20916 }
20917 }
20918 };
20919
20920 dlg.finished(true);
20921 return Ok(response);
20922 }
20923 }
20924 }
20925 }
20926
20927 /// The ID of the file.
20928 ///
20929 /// Sets the *file id* path property to the given value.
20930 ///
20931 /// Even though the property as already been set when instantiating this call,
20932 /// we provide this method for API completeness.
20933 pub fn file_id(mut self, new_value: &str) -> ReplyGetCall<'a, C> {
20934 self._file_id = new_value.to_string();
20935 self
20936 }
20937 /// The ID of the comment.
20938 ///
20939 /// Sets the *comment id* path property to the given value.
20940 ///
20941 /// Even though the property as already been set when instantiating this call,
20942 /// we provide this method for API completeness.
20943 pub fn comment_id(mut self, new_value: &str) -> ReplyGetCall<'a, C> {
20944 self._comment_id = new_value.to_string();
20945 self
20946 }
20947 /// The ID of the reply.
20948 ///
20949 /// Sets the *reply id* path property to the given value.
20950 ///
20951 /// Even though the property as already been set when instantiating this call,
20952 /// we provide this method for API completeness.
20953 pub fn reply_id(mut self, new_value: &str) -> ReplyGetCall<'a, C> {
20954 self._reply_id = new_value.to_string();
20955 self
20956 }
20957 /// Whether to return deleted replies. Deleted replies don't include their original content.
20958 ///
20959 /// Sets the *include deleted* query property to the given value.
20960 pub fn include_deleted(mut self, new_value: bool) -> ReplyGetCall<'a, C> {
20961 self._include_deleted = Some(new_value);
20962 self
20963 }
20964 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20965 /// while executing the actual API request.
20966 ///
20967 /// ````text
20968 /// It should be used to handle progress information, and to implement a certain level of resilience.
20969 /// ````
20970 ///
20971 /// Sets the *delegate* property to the given value.
20972 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyGetCall<'a, C> {
20973 self._delegate = Some(new_value);
20974 self
20975 }
20976
20977 /// Set any additional parameter of the query string used in the request.
20978 /// It should be used to set parameters which are not yet available through their own
20979 /// setters.
20980 ///
20981 /// Please note that this method must not be used to set any of the known parameters
20982 /// which have their own setter method. If done anyway, the request will fail.
20983 ///
20984 /// # Additional Parameters
20985 ///
20986 /// * *$.xgafv* (query-string) - V1 error format.
20987 /// * *access_token* (query-string) - OAuth access token.
20988 /// * *alt* (query-string) - Data format for response.
20989 /// * *callback* (query-string) - JSONP
20990 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20991 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20992 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20993 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20994 /// * *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.
20995 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20996 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20997 pub fn param<T>(mut self, name: T, value: T) -> ReplyGetCall<'a, C>
20998 where
20999 T: AsRef<str>,
21000 {
21001 self._additional_params
21002 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21003 self
21004 }
21005
21006 /// Identifies the authorization scope for the method you are building.
21007 ///
21008 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21009 /// [`Scope::MeetReadonly`].
21010 ///
21011 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21012 /// tokens for more than one scope.
21013 ///
21014 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21015 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21016 /// sufficient, a read-write scope will do as well.
21017 pub fn add_scope<St>(mut self, scope: St) -> ReplyGetCall<'a, C>
21018 where
21019 St: AsRef<str>,
21020 {
21021 self._scopes.insert(String::from(scope.as_ref()));
21022 self
21023 }
21024 /// Identifies the authorization scope(s) for the method you are building.
21025 ///
21026 /// See [`Self::add_scope()`] for details.
21027 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyGetCall<'a, C>
21028 where
21029 I: IntoIterator<Item = St>,
21030 St: AsRef<str>,
21031 {
21032 self._scopes
21033 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21034 self
21035 }
21036
21037 /// Removes all scopes, and no default scope will be used either.
21038 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21039 /// for details).
21040 pub fn clear_scopes(mut self) -> ReplyGetCall<'a, C> {
21041 self._scopes.clear();
21042 self
21043 }
21044}
21045
21046/// Lists a comment's replies. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
21047///
21048/// A builder for the *list* method supported by a *reply* resource.
21049/// It is not used directly, but through a [`ReplyMethods`] instance.
21050///
21051/// # Example
21052///
21053/// Instantiate a resource method builder
21054///
21055/// ```test_harness,no_run
21056/// # extern crate hyper;
21057/// # extern crate hyper_rustls;
21058/// # extern crate google_drive3 as drive3;
21059/// # async fn dox() {
21060/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21061///
21062/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21063/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21064/// # .with_native_roots()
21065/// # .unwrap()
21066/// # .https_only()
21067/// # .enable_http2()
21068/// # .build();
21069///
21070/// # let executor = hyper_util::rt::TokioExecutor::new();
21071/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21072/// # secret,
21073/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21074/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21075/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21076/// # ),
21077/// # ).build().await.unwrap();
21078///
21079/// # let client = hyper_util::client::legacy::Client::builder(
21080/// # hyper_util::rt::TokioExecutor::new()
21081/// # )
21082/// # .build(
21083/// # hyper_rustls::HttpsConnectorBuilder::new()
21084/// # .with_native_roots()
21085/// # .unwrap()
21086/// # .https_or_http()
21087/// # .enable_http2()
21088/// # .build()
21089/// # );
21090/// # let mut hub = DriveHub::new(client, auth);
21091/// // You can configure optional parameters by calling the respective setters at will, and
21092/// // execute the final call using `doit()`.
21093/// // Values shown here are possibly random and not representative !
21094/// let result = hub.replies().list("fileId", "commentId")
21095/// .page_token("erat")
21096/// .page_size(-31)
21097/// .include_deleted(true)
21098/// .doit().await;
21099/// # }
21100/// ```
21101pub struct ReplyListCall<'a, C>
21102where
21103 C: 'a,
21104{
21105 hub: &'a DriveHub<C>,
21106 _file_id: String,
21107 _comment_id: String,
21108 _page_token: Option<String>,
21109 _page_size: Option<i32>,
21110 _include_deleted: Option<bool>,
21111 _delegate: Option<&'a mut dyn common::Delegate>,
21112 _additional_params: HashMap<String, String>,
21113 _scopes: BTreeSet<String>,
21114}
21115
21116impl<'a, C> common::CallBuilder for ReplyListCall<'a, C> {}
21117
21118impl<'a, C> ReplyListCall<'a, C>
21119where
21120 C: common::Connector,
21121{
21122 /// Perform the operation you have build so far.
21123 pub async fn doit(mut self) -> common::Result<(common::Response, ReplyList)> {
21124 use std::borrow::Cow;
21125 use std::io::{Read, Seek};
21126
21127 use common::{url::Params, ToParts};
21128 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21129
21130 let mut dd = common::DefaultDelegate;
21131 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21132 dlg.begin(common::MethodInfo {
21133 id: "drive.replies.list",
21134 http_method: hyper::Method::GET,
21135 });
21136
21137 for &field in [
21138 "alt",
21139 "fileId",
21140 "commentId",
21141 "pageToken",
21142 "pageSize",
21143 "includeDeleted",
21144 ]
21145 .iter()
21146 {
21147 if self._additional_params.contains_key(field) {
21148 dlg.finished(false);
21149 return Err(common::Error::FieldClash(field));
21150 }
21151 }
21152
21153 let mut params = Params::with_capacity(7 + self._additional_params.len());
21154 params.push("fileId", self._file_id);
21155 params.push("commentId", self._comment_id);
21156 if let Some(value) = self._page_token.as_ref() {
21157 params.push("pageToken", value);
21158 }
21159 if let Some(value) = self._page_size.as_ref() {
21160 params.push("pageSize", value.to_string());
21161 }
21162 if let Some(value) = self._include_deleted.as_ref() {
21163 params.push("includeDeleted", value.to_string());
21164 }
21165
21166 params.extend(self._additional_params.iter());
21167
21168 params.push("alt", "json");
21169 let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies";
21170 if self._scopes.is_empty() {
21171 self._scopes
21172 .insert(Scope::MeetReadonly.as_ref().to_string());
21173 }
21174
21175 #[allow(clippy::single_element_loop)]
21176 for &(find_this, param_name) in
21177 [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
21178 {
21179 url = params.uri_replacement(url, param_name, find_this, false);
21180 }
21181 {
21182 let to_remove = ["commentId", "fileId"];
21183 params.remove_params(&to_remove);
21184 }
21185
21186 let url = params.parse_with_url(&url);
21187
21188 loop {
21189 let token = match self
21190 .hub
21191 .auth
21192 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21193 .await
21194 {
21195 Ok(token) => token,
21196 Err(e) => match dlg.token(e) {
21197 Ok(token) => token,
21198 Err(e) => {
21199 dlg.finished(false);
21200 return Err(common::Error::MissingToken(e));
21201 }
21202 },
21203 };
21204 let mut req_result = {
21205 let client = &self.hub.client;
21206 dlg.pre_request();
21207 let mut req_builder = hyper::Request::builder()
21208 .method(hyper::Method::GET)
21209 .uri(url.as_str())
21210 .header(USER_AGENT, self.hub._user_agent.clone());
21211
21212 if let Some(token) = token.as_ref() {
21213 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21214 }
21215
21216 let request = req_builder
21217 .header(CONTENT_LENGTH, 0_u64)
21218 .body(common::to_body::<String>(None));
21219
21220 client.request(request.unwrap()).await
21221 };
21222
21223 match req_result {
21224 Err(err) => {
21225 if let common::Retry::After(d) = dlg.http_error(&err) {
21226 sleep(d).await;
21227 continue;
21228 }
21229 dlg.finished(false);
21230 return Err(common::Error::HttpError(err));
21231 }
21232 Ok(res) => {
21233 let (mut parts, body) = res.into_parts();
21234 let mut body = common::Body::new(body);
21235 if !parts.status.is_success() {
21236 let bytes = common::to_bytes(body).await.unwrap_or_default();
21237 let error = serde_json::from_str(&common::to_string(&bytes));
21238 let response = common::to_response(parts, bytes.into());
21239
21240 if let common::Retry::After(d) =
21241 dlg.http_failure(&response, error.as_ref().ok())
21242 {
21243 sleep(d).await;
21244 continue;
21245 }
21246
21247 dlg.finished(false);
21248
21249 return Err(match error {
21250 Ok(value) => common::Error::BadRequest(value),
21251 _ => common::Error::Failure(response),
21252 });
21253 }
21254 let response = {
21255 let bytes = common::to_bytes(body).await.unwrap_or_default();
21256 let encoded = common::to_string(&bytes);
21257 match serde_json::from_str(&encoded) {
21258 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21259 Err(error) => {
21260 dlg.response_json_decode_error(&encoded, &error);
21261 return Err(common::Error::JsonDecodeError(
21262 encoded.to_string(),
21263 error,
21264 ));
21265 }
21266 }
21267 };
21268
21269 dlg.finished(true);
21270 return Ok(response);
21271 }
21272 }
21273 }
21274 }
21275
21276 /// The ID of the file.
21277 ///
21278 /// Sets the *file id* path property to the given value.
21279 ///
21280 /// Even though the property as already been set when instantiating this call,
21281 /// we provide this method for API completeness.
21282 pub fn file_id(mut self, new_value: &str) -> ReplyListCall<'a, C> {
21283 self._file_id = new_value.to_string();
21284 self
21285 }
21286 /// The ID of the comment.
21287 ///
21288 /// Sets the *comment id* path property to the given value.
21289 ///
21290 /// Even though the property as already been set when instantiating this call,
21291 /// we provide this method for API completeness.
21292 pub fn comment_id(mut self, new_value: &str) -> ReplyListCall<'a, C> {
21293 self._comment_id = new_value.to_string();
21294 self
21295 }
21296 /// 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.
21297 ///
21298 /// Sets the *page token* query property to the given value.
21299 pub fn page_token(mut self, new_value: &str) -> ReplyListCall<'a, C> {
21300 self._page_token = Some(new_value.to_string());
21301 self
21302 }
21303 /// The maximum number of replies to return per page.
21304 ///
21305 /// Sets the *page size* query property to the given value.
21306 pub fn page_size(mut self, new_value: i32) -> ReplyListCall<'a, C> {
21307 self._page_size = Some(new_value);
21308 self
21309 }
21310 /// Whether to include deleted replies. Deleted replies don't include their original content.
21311 ///
21312 /// Sets the *include deleted* query property to the given value.
21313 pub fn include_deleted(mut self, new_value: bool) -> ReplyListCall<'a, C> {
21314 self._include_deleted = Some(new_value);
21315 self
21316 }
21317 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21318 /// while executing the actual API request.
21319 ///
21320 /// ````text
21321 /// It should be used to handle progress information, and to implement a certain level of resilience.
21322 /// ````
21323 ///
21324 /// Sets the *delegate* property to the given value.
21325 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyListCall<'a, C> {
21326 self._delegate = Some(new_value);
21327 self
21328 }
21329
21330 /// Set any additional parameter of the query string used in the request.
21331 /// It should be used to set parameters which are not yet available through their own
21332 /// setters.
21333 ///
21334 /// Please note that this method must not be used to set any of the known parameters
21335 /// which have their own setter method. If done anyway, the request will fail.
21336 ///
21337 /// # Additional Parameters
21338 ///
21339 /// * *$.xgafv* (query-string) - V1 error format.
21340 /// * *access_token* (query-string) - OAuth access token.
21341 /// * *alt* (query-string) - Data format for response.
21342 /// * *callback* (query-string) - JSONP
21343 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21344 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21345 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21346 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21347 /// * *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.
21348 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21349 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21350 pub fn param<T>(mut self, name: T, value: T) -> ReplyListCall<'a, C>
21351 where
21352 T: AsRef<str>,
21353 {
21354 self._additional_params
21355 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21356 self
21357 }
21358
21359 /// Identifies the authorization scope for the method you are building.
21360 ///
21361 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21362 /// [`Scope::MeetReadonly`].
21363 ///
21364 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21365 /// tokens for more than one scope.
21366 ///
21367 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21368 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21369 /// sufficient, a read-write scope will do as well.
21370 pub fn add_scope<St>(mut self, scope: St) -> ReplyListCall<'a, C>
21371 where
21372 St: AsRef<str>,
21373 {
21374 self._scopes.insert(String::from(scope.as_ref()));
21375 self
21376 }
21377 /// Identifies the authorization scope(s) for the method you are building.
21378 ///
21379 /// See [`Self::add_scope()`] for details.
21380 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyListCall<'a, C>
21381 where
21382 I: IntoIterator<Item = St>,
21383 St: AsRef<str>,
21384 {
21385 self._scopes
21386 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21387 self
21388 }
21389
21390 /// Removes all scopes, and no default scope will be used either.
21391 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21392 /// for details).
21393 pub fn clear_scopes(mut self) -> ReplyListCall<'a, C> {
21394 self._scopes.clear();
21395 self
21396 }
21397}
21398
21399/// Updates a reply with patch semantics. For more information, see [Manage comments and replies](https://developers.google.com/workspace/drive/api/guides/manage-comments).
21400///
21401/// A builder for the *update* method supported by a *reply* resource.
21402/// It is not used directly, but through a [`ReplyMethods`] instance.
21403///
21404/// # Example
21405///
21406/// Instantiate a resource method builder
21407///
21408/// ```test_harness,no_run
21409/// # extern crate hyper;
21410/// # extern crate hyper_rustls;
21411/// # extern crate google_drive3 as drive3;
21412/// use drive3::api::Reply;
21413/// # async fn dox() {
21414/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21415///
21416/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21417/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21418/// # .with_native_roots()
21419/// # .unwrap()
21420/// # .https_only()
21421/// # .enable_http2()
21422/// # .build();
21423///
21424/// # let executor = hyper_util::rt::TokioExecutor::new();
21425/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21426/// # secret,
21427/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21428/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21429/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21430/// # ),
21431/// # ).build().await.unwrap();
21432///
21433/// # let client = hyper_util::client::legacy::Client::builder(
21434/// # hyper_util::rt::TokioExecutor::new()
21435/// # )
21436/// # .build(
21437/// # hyper_rustls::HttpsConnectorBuilder::new()
21438/// # .with_native_roots()
21439/// # .unwrap()
21440/// # .https_or_http()
21441/// # .enable_http2()
21442/// # .build()
21443/// # );
21444/// # let mut hub = DriveHub::new(client, auth);
21445/// // As the method needs a request, you would usually fill it with the desired information
21446/// // into the respective structure. Some of the parts shown here might not be applicable !
21447/// // Values shown here are possibly random and not representative !
21448/// let mut req = Reply::default();
21449///
21450/// // You can configure optional parameters by calling the respective setters at will, and
21451/// // execute the final call using `doit()`.
21452/// // Values shown here are possibly random and not representative !
21453/// let result = hub.replies().update(req, "fileId", "commentId", "replyId")
21454/// .doit().await;
21455/// # }
21456/// ```
21457pub struct ReplyUpdateCall<'a, C>
21458where
21459 C: 'a,
21460{
21461 hub: &'a DriveHub<C>,
21462 _request: Reply,
21463 _file_id: String,
21464 _comment_id: String,
21465 _reply_id: String,
21466 _delegate: Option<&'a mut dyn common::Delegate>,
21467 _additional_params: HashMap<String, String>,
21468 _scopes: BTreeSet<String>,
21469}
21470
21471impl<'a, C> common::CallBuilder for ReplyUpdateCall<'a, C> {}
21472
21473impl<'a, C> ReplyUpdateCall<'a, C>
21474where
21475 C: common::Connector,
21476{
21477 /// Perform the operation you have build so far.
21478 pub async fn doit(mut self) -> common::Result<(common::Response, Reply)> {
21479 use std::borrow::Cow;
21480 use std::io::{Read, Seek};
21481
21482 use common::{url::Params, ToParts};
21483 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21484
21485 let mut dd = common::DefaultDelegate;
21486 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21487 dlg.begin(common::MethodInfo {
21488 id: "drive.replies.update",
21489 http_method: hyper::Method::PATCH,
21490 });
21491
21492 for &field in ["alt", "fileId", "commentId", "replyId"].iter() {
21493 if self._additional_params.contains_key(field) {
21494 dlg.finished(false);
21495 return Err(common::Error::FieldClash(field));
21496 }
21497 }
21498
21499 let mut params = Params::with_capacity(6 + self._additional_params.len());
21500 params.push("fileId", self._file_id);
21501 params.push("commentId", self._comment_id);
21502 params.push("replyId", self._reply_id);
21503
21504 params.extend(self._additional_params.iter());
21505
21506 params.push("alt", "json");
21507 let mut url =
21508 self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}";
21509 if self._scopes.is_empty() {
21510 self._scopes.insert(Scope::Full.as_ref().to_string());
21511 }
21512
21513 #[allow(clippy::single_element_loop)]
21514 for &(find_this, param_name) in [
21515 ("{fileId}", "fileId"),
21516 ("{commentId}", "commentId"),
21517 ("{replyId}", "replyId"),
21518 ]
21519 .iter()
21520 {
21521 url = params.uri_replacement(url, param_name, find_this, false);
21522 }
21523 {
21524 let to_remove = ["replyId", "commentId", "fileId"];
21525 params.remove_params(&to_remove);
21526 }
21527
21528 let url = params.parse_with_url(&url);
21529
21530 let mut json_mime_type = mime::APPLICATION_JSON;
21531 let mut request_value_reader = {
21532 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21533 common::remove_json_null_values(&mut value);
21534 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21535 serde_json::to_writer(&mut dst, &value).unwrap();
21536 dst
21537 };
21538 let request_size = request_value_reader
21539 .seek(std::io::SeekFrom::End(0))
21540 .unwrap();
21541 request_value_reader
21542 .seek(std::io::SeekFrom::Start(0))
21543 .unwrap();
21544
21545 loop {
21546 let token = match self
21547 .hub
21548 .auth
21549 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21550 .await
21551 {
21552 Ok(token) => token,
21553 Err(e) => match dlg.token(e) {
21554 Ok(token) => token,
21555 Err(e) => {
21556 dlg.finished(false);
21557 return Err(common::Error::MissingToken(e));
21558 }
21559 },
21560 };
21561 request_value_reader
21562 .seek(std::io::SeekFrom::Start(0))
21563 .unwrap();
21564 let mut req_result = {
21565 let client = &self.hub.client;
21566 dlg.pre_request();
21567 let mut req_builder = hyper::Request::builder()
21568 .method(hyper::Method::PATCH)
21569 .uri(url.as_str())
21570 .header(USER_AGENT, self.hub._user_agent.clone());
21571
21572 if let Some(token) = token.as_ref() {
21573 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21574 }
21575
21576 let request = req_builder
21577 .header(CONTENT_TYPE, json_mime_type.to_string())
21578 .header(CONTENT_LENGTH, request_size as u64)
21579 .body(common::to_body(
21580 request_value_reader.get_ref().clone().into(),
21581 ));
21582
21583 client.request(request.unwrap()).await
21584 };
21585
21586 match req_result {
21587 Err(err) => {
21588 if let common::Retry::After(d) = dlg.http_error(&err) {
21589 sleep(d).await;
21590 continue;
21591 }
21592 dlg.finished(false);
21593 return Err(common::Error::HttpError(err));
21594 }
21595 Ok(res) => {
21596 let (mut parts, body) = res.into_parts();
21597 let mut body = common::Body::new(body);
21598 if !parts.status.is_success() {
21599 let bytes = common::to_bytes(body).await.unwrap_or_default();
21600 let error = serde_json::from_str(&common::to_string(&bytes));
21601 let response = common::to_response(parts, bytes.into());
21602
21603 if let common::Retry::After(d) =
21604 dlg.http_failure(&response, error.as_ref().ok())
21605 {
21606 sleep(d).await;
21607 continue;
21608 }
21609
21610 dlg.finished(false);
21611
21612 return Err(match error {
21613 Ok(value) => common::Error::BadRequest(value),
21614 _ => common::Error::Failure(response),
21615 });
21616 }
21617 let response = {
21618 let bytes = common::to_bytes(body).await.unwrap_or_default();
21619 let encoded = common::to_string(&bytes);
21620 match serde_json::from_str(&encoded) {
21621 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21622 Err(error) => {
21623 dlg.response_json_decode_error(&encoded, &error);
21624 return Err(common::Error::JsonDecodeError(
21625 encoded.to_string(),
21626 error,
21627 ));
21628 }
21629 }
21630 };
21631
21632 dlg.finished(true);
21633 return Ok(response);
21634 }
21635 }
21636 }
21637 }
21638
21639 ///
21640 /// Sets the *request* property to the given value.
21641 ///
21642 /// Even though the property as already been set when instantiating this call,
21643 /// we provide this method for API completeness.
21644 pub fn request(mut self, new_value: Reply) -> ReplyUpdateCall<'a, C> {
21645 self._request = new_value;
21646 self
21647 }
21648 /// The ID of the file.
21649 ///
21650 /// Sets the *file id* path property to the given value.
21651 ///
21652 /// Even though the property as already been set when instantiating this call,
21653 /// we provide this method for API completeness.
21654 pub fn file_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, C> {
21655 self._file_id = new_value.to_string();
21656 self
21657 }
21658 /// The ID of the comment.
21659 ///
21660 /// Sets the *comment id* path property to the given value.
21661 ///
21662 /// Even though the property as already been set when instantiating this call,
21663 /// we provide this method for API completeness.
21664 pub fn comment_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, C> {
21665 self._comment_id = new_value.to_string();
21666 self
21667 }
21668 /// The ID of the reply.
21669 ///
21670 /// Sets the *reply id* path property to the given value.
21671 ///
21672 /// Even though the property as already been set when instantiating this call,
21673 /// we provide this method for API completeness.
21674 pub fn reply_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, C> {
21675 self._reply_id = new_value.to_string();
21676 self
21677 }
21678 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21679 /// while executing the actual API request.
21680 ///
21681 /// ````text
21682 /// It should be used to handle progress information, and to implement a certain level of resilience.
21683 /// ````
21684 ///
21685 /// Sets the *delegate* property to the given value.
21686 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReplyUpdateCall<'a, C> {
21687 self._delegate = Some(new_value);
21688 self
21689 }
21690
21691 /// Set any additional parameter of the query string used in the request.
21692 /// It should be used to set parameters which are not yet available through their own
21693 /// setters.
21694 ///
21695 /// Please note that this method must not be used to set any of the known parameters
21696 /// which have their own setter method. If done anyway, the request will fail.
21697 ///
21698 /// # Additional Parameters
21699 ///
21700 /// * *$.xgafv* (query-string) - V1 error format.
21701 /// * *access_token* (query-string) - OAuth access token.
21702 /// * *alt* (query-string) - Data format for response.
21703 /// * *callback* (query-string) - JSONP
21704 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21705 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21706 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21707 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21708 /// * *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.
21709 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21710 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21711 pub fn param<T>(mut self, name: T, value: T) -> ReplyUpdateCall<'a, C>
21712 where
21713 T: AsRef<str>,
21714 {
21715 self._additional_params
21716 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21717 self
21718 }
21719
21720 /// Identifies the authorization scope for the method you are building.
21721 ///
21722 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21723 /// [`Scope::Full`].
21724 ///
21725 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21726 /// tokens for more than one scope.
21727 ///
21728 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21729 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21730 /// sufficient, a read-write scope will do as well.
21731 pub fn add_scope<St>(mut self, scope: St) -> ReplyUpdateCall<'a, C>
21732 where
21733 St: AsRef<str>,
21734 {
21735 self._scopes.insert(String::from(scope.as_ref()));
21736 self
21737 }
21738 /// Identifies the authorization scope(s) for the method you are building.
21739 ///
21740 /// See [`Self::add_scope()`] for details.
21741 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReplyUpdateCall<'a, C>
21742 where
21743 I: IntoIterator<Item = St>,
21744 St: AsRef<str>,
21745 {
21746 self._scopes
21747 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21748 self
21749 }
21750
21751 /// Removes all scopes, and no default scope will be used either.
21752 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21753 /// for details).
21754 pub fn clear_scopes(mut self) -> ReplyUpdateCall<'a, C> {
21755 self._scopes.clear();
21756 self
21757 }
21758}
21759
21760/// Permanently deletes a file version. You can only delete revisions for files with binary content in Google Drive, like images or videos. Revisions for other files, like Google Docs or Sheets, and the last remaining file version can't be deleted. For more information, see [Manage file revisions](https://developers.google.com/drive/api/guides/manage-revisions).
21761///
21762/// A builder for the *delete* method supported by a *revision* resource.
21763/// It is not used directly, but through a [`RevisionMethods`] instance.
21764///
21765/// # Example
21766///
21767/// Instantiate a resource method builder
21768///
21769/// ```test_harness,no_run
21770/// # extern crate hyper;
21771/// # extern crate hyper_rustls;
21772/// # extern crate google_drive3 as drive3;
21773/// # async fn dox() {
21774/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21775///
21776/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21777/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21778/// # .with_native_roots()
21779/// # .unwrap()
21780/// # .https_only()
21781/// # .enable_http2()
21782/// # .build();
21783///
21784/// # let executor = hyper_util::rt::TokioExecutor::new();
21785/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21786/// # secret,
21787/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21788/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21789/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21790/// # ),
21791/// # ).build().await.unwrap();
21792///
21793/// # let client = hyper_util::client::legacy::Client::builder(
21794/// # hyper_util::rt::TokioExecutor::new()
21795/// # )
21796/// # .build(
21797/// # hyper_rustls::HttpsConnectorBuilder::new()
21798/// # .with_native_roots()
21799/// # .unwrap()
21800/// # .https_or_http()
21801/// # .enable_http2()
21802/// # .build()
21803/// # );
21804/// # let mut hub = DriveHub::new(client, auth);
21805/// // You can configure optional parameters by calling the respective setters at will, and
21806/// // execute the final call using `doit()`.
21807/// // Values shown here are possibly random and not representative !
21808/// let result = hub.revisions().delete("fileId", "revisionId")
21809/// .doit().await;
21810/// # }
21811/// ```
21812pub struct RevisionDeleteCall<'a, C>
21813where
21814 C: 'a,
21815{
21816 hub: &'a DriveHub<C>,
21817 _file_id: String,
21818 _revision_id: String,
21819 _delegate: Option<&'a mut dyn common::Delegate>,
21820 _additional_params: HashMap<String, String>,
21821 _scopes: BTreeSet<String>,
21822}
21823
21824impl<'a, C> common::CallBuilder for RevisionDeleteCall<'a, C> {}
21825
21826impl<'a, C> RevisionDeleteCall<'a, C>
21827where
21828 C: common::Connector,
21829{
21830 /// Perform the operation you have build so far.
21831 pub async fn doit(mut self) -> common::Result<common::Response> {
21832 use std::borrow::Cow;
21833 use std::io::{Read, Seek};
21834
21835 use common::{url::Params, ToParts};
21836 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21837
21838 let mut dd = common::DefaultDelegate;
21839 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21840 dlg.begin(common::MethodInfo {
21841 id: "drive.revisions.delete",
21842 http_method: hyper::Method::DELETE,
21843 });
21844
21845 for &field in ["fileId", "revisionId"].iter() {
21846 if self._additional_params.contains_key(field) {
21847 dlg.finished(false);
21848 return Err(common::Error::FieldClash(field));
21849 }
21850 }
21851
21852 let mut params = Params::with_capacity(3 + self._additional_params.len());
21853 params.push("fileId", self._file_id);
21854 params.push("revisionId", self._revision_id);
21855
21856 params.extend(self._additional_params.iter());
21857
21858 let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}";
21859 if self._scopes.is_empty() {
21860 self._scopes.insert(Scope::Full.as_ref().to_string());
21861 }
21862
21863 #[allow(clippy::single_element_loop)]
21864 for &(find_this, param_name) in
21865 [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter()
21866 {
21867 url = params.uri_replacement(url, param_name, find_this, false);
21868 }
21869 {
21870 let to_remove = ["revisionId", "fileId"];
21871 params.remove_params(&to_remove);
21872 }
21873
21874 let url = params.parse_with_url(&url);
21875
21876 loop {
21877 let token = match self
21878 .hub
21879 .auth
21880 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21881 .await
21882 {
21883 Ok(token) => token,
21884 Err(e) => match dlg.token(e) {
21885 Ok(token) => token,
21886 Err(e) => {
21887 dlg.finished(false);
21888 return Err(common::Error::MissingToken(e));
21889 }
21890 },
21891 };
21892 let mut req_result = {
21893 let client = &self.hub.client;
21894 dlg.pre_request();
21895 let mut req_builder = hyper::Request::builder()
21896 .method(hyper::Method::DELETE)
21897 .uri(url.as_str())
21898 .header(USER_AGENT, self.hub._user_agent.clone());
21899
21900 if let Some(token) = token.as_ref() {
21901 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21902 }
21903
21904 let request = req_builder
21905 .header(CONTENT_LENGTH, 0_u64)
21906 .body(common::to_body::<String>(None));
21907
21908 client.request(request.unwrap()).await
21909 };
21910
21911 match req_result {
21912 Err(err) => {
21913 if let common::Retry::After(d) = dlg.http_error(&err) {
21914 sleep(d).await;
21915 continue;
21916 }
21917 dlg.finished(false);
21918 return Err(common::Error::HttpError(err));
21919 }
21920 Ok(res) => {
21921 let (mut parts, body) = res.into_parts();
21922 let mut body = common::Body::new(body);
21923 if !parts.status.is_success() {
21924 let bytes = common::to_bytes(body).await.unwrap_or_default();
21925 let error = serde_json::from_str(&common::to_string(&bytes));
21926 let response = common::to_response(parts, bytes.into());
21927
21928 if let common::Retry::After(d) =
21929 dlg.http_failure(&response, error.as_ref().ok())
21930 {
21931 sleep(d).await;
21932 continue;
21933 }
21934
21935 dlg.finished(false);
21936
21937 return Err(match error {
21938 Ok(value) => common::Error::BadRequest(value),
21939 _ => common::Error::Failure(response),
21940 });
21941 }
21942 let response = common::Response::from_parts(parts, body);
21943
21944 dlg.finished(true);
21945 return Ok(response);
21946 }
21947 }
21948 }
21949 }
21950
21951 /// The ID of the file.
21952 ///
21953 /// Sets the *file id* path property to the given value.
21954 ///
21955 /// Even though the property as already been set when instantiating this call,
21956 /// we provide this method for API completeness.
21957 pub fn file_id(mut self, new_value: &str) -> RevisionDeleteCall<'a, C> {
21958 self._file_id = new_value.to_string();
21959 self
21960 }
21961 /// The ID of the revision.
21962 ///
21963 /// Sets the *revision id* path property to the given value.
21964 ///
21965 /// Even though the property as already been set when instantiating this call,
21966 /// we provide this method for API completeness.
21967 pub fn revision_id(mut self, new_value: &str) -> RevisionDeleteCall<'a, C> {
21968 self._revision_id = new_value.to_string();
21969 self
21970 }
21971 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21972 /// while executing the actual API request.
21973 ///
21974 /// ````text
21975 /// It should be used to handle progress information, and to implement a certain level of resilience.
21976 /// ````
21977 ///
21978 /// Sets the *delegate* property to the given value.
21979 pub fn delegate(
21980 mut self,
21981 new_value: &'a mut dyn common::Delegate,
21982 ) -> RevisionDeleteCall<'a, C> {
21983 self._delegate = Some(new_value);
21984 self
21985 }
21986
21987 /// Set any additional parameter of the query string used in the request.
21988 /// It should be used to set parameters which are not yet available through their own
21989 /// setters.
21990 ///
21991 /// Please note that this method must not be used to set any of the known parameters
21992 /// which have their own setter method. If done anyway, the request will fail.
21993 ///
21994 /// # Additional Parameters
21995 ///
21996 /// * *$.xgafv* (query-string) - V1 error format.
21997 /// * *access_token* (query-string) - OAuth access token.
21998 /// * *alt* (query-string) - Data format for response.
21999 /// * *callback* (query-string) - JSONP
22000 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22001 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22002 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22003 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22004 /// * *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.
22005 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22006 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22007 pub fn param<T>(mut self, name: T, value: T) -> RevisionDeleteCall<'a, C>
22008 where
22009 T: AsRef<str>,
22010 {
22011 self._additional_params
22012 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22013 self
22014 }
22015
22016 /// Identifies the authorization scope for the method you are building.
22017 ///
22018 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22019 /// [`Scope::Full`].
22020 ///
22021 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22022 /// tokens for more than one scope.
22023 ///
22024 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22025 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22026 /// sufficient, a read-write scope will do as well.
22027 pub fn add_scope<St>(mut self, scope: St) -> RevisionDeleteCall<'a, C>
22028 where
22029 St: AsRef<str>,
22030 {
22031 self._scopes.insert(String::from(scope.as_ref()));
22032 self
22033 }
22034 /// Identifies the authorization scope(s) for the method you are building.
22035 ///
22036 /// See [`Self::add_scope()`] for details.
22037 pub fn add_scopes<I, St>(mut self, scopes: I) -> RevisionDeleteCall<'a, C>
22038 where
22039 I: IntoIterator<Item = St>,
22040 St: AsRef<str>,
22041 {
22042 self._scopes
22043 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22044 self
22045 }
22046
22047 /// Removes all scopes, and no default scope will be used either.
22048 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22049 /// for details).
22050 pub fn clear_scopes(mut self) -> RevisionDeleteCall<'a, C> {
22051 self._scopes.clear();
22052 self
22053 }
22054}
22055
22056/// Gets a revision's metadata or content by ID. For more information, see [Manage file revisions](https://developers.google.com/workspace/drive/api/guides/manage-revisions).
22057///
22058/// This method supports **media download**. To enable it, adjust the builder like this:
22059/// `.param("alt", "media")`.
22060/// Please note that due to missing multi-part support on the server side, you will only receive the media,
22061/// but not the `Revision` structure that you would usually get. The latter will be a default value.
22062///
22063/// A builder for the *get* method supported by a *revision* resource.
22064/// It is not used directly, but through a [`RevisionMethods`] instance.
22065///
22066/// # Example
22067///
22068/// Instantiate a resource method builder
22069///
22070/// ```test_harness,no_run
22071/// # extern crate hyper;
22072/// # extern crate hyper_rustls;
22073/// # extern crate google_drive3 as drive3;
22074/// # async fn dox() {
22075/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22076///
22077/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22078/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22079/// # .with_native_roots()
22080/// # .unwrap()
22081/// # .https_only()
22082/// # .enable_http2()
22083/// # .build();
22084///
22085/// # let executor = hyper_util::rt::TokioExecutor::new();
22086/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22087/// # secret,
22088/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22089/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22090/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22091/// # ),
22092/// # ).build().await.unwrap();
22093///
22094/// # let client = hyper_util::client::legacy::Client::builder(
22095/// # hyper_util::rt::TokioExecutor::new()
22096/// # )
22097/// # .build(
22098/// # hyper_rustls::HttpsConnectorBuilder::new()
22099/// # .with_native_roots()
22100/// # .unwrap()
22101/// # .https_or_http()
22102/// # .enable_http2()
22103/// # .build()
22104/// # );
22105/// # let mut hub = DriveHub::new(client, auth);
22106/// // You can configure optional parameters by calling the respective setters at will, and
22107/// // execute the final call using `doit()`.
22108/// // Values shown here are possibly random and not representative !
22109/// let result = hub.revisions().get("fileId", "revisionId")
22110/// .acknowledge_abuse(true)
22111/// .doit().await;
22112/// # }
22113/// ```
22114pub struct RevisionGetCall<'a, C>
22115where
22116 C: 'a,
22117{
22118 hub: &'a DriveHub<C>,
22119 _file_id: String,
22120 _revision_id: String,
22121 _acknowledge_abuse: Option<bool>,
22122 _delegate: Option<&'a mut dyn common::Delegate>,
22123 _additional_params: HashMap<String, String>,
22124 _scopes: BTreeSet<String>,
22125}
22126
22127impl<'a, C> common::CallBuilder for RevisionGetCall<'a, C> {}
22128
22129impl<'a, C> RevisionGetCall<'a, C>
22130where
22131 C: common::Connector,
22132{
22133 /// Perform the operation you have build so far.
22134 pub async fn doit(mut self) -> common::Result<(common::Response, Revision)> {
22135 use std::borrow::Cow;
22136 use std::io::{Read, Seek};
22137
22138 use common::{url::Params, ToParts};
22139 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22140
22141 let mut dd = common::DefaultDelegate;
22142 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22143 dlg.begin(common::MethodInfo {
22144 id: "drive.revisions.get",
22145 http_method: hyper::Method::GET,
22146 });
22147
22148 for &field in ["fileId", "revisionId", "acknowledgeAbuse"].iter() {
22149 if self._additional_params.contains_key(field) {
22150 dlg.finished(false);
22151 return Err(common::Error::FieldClash(field));
22152 }
22153 }
22154
22155 let mut params = Params::with_capacity(4 + self._additional_params.len());
22156 params.push("fileId", self._file_id);
22157 params.push("revisionId", self._revision_id);
22158 if let Some(value) = self._acknowledge_abuse.as_ref() {
22159 params.push("acknowledgeAbuse", value.to_string());
22160 }
22161
22162 params.extend(self._additional_params.iter());
22163
22164 let (alt_field_missing, enable_resource_parsing) = {
22165 if let Some(value) = params.get("alt") {
22166 (false, value == "json")
22167 } else {
22168 (true, true)
22169 }
22170 };
22171 if alt_field_missing {
22172 params.push("alt", "json");
22173 }
22174 let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}";
22175 if self._scopes.is_empty() {
22176 self._scopes
22177 .insert(Scope::MeetReadonly.as_ref().to_string());
22178 }
22179
22180 #[allow(clippy::single_element_loop)]
22181 for &(find_this, param_name) in
22182 [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter()
22183 {
22184 url = params.uri_replacement(url, param_name, find_this, false);
22185 }
22186 {
22187 let to_remove = ["revisionId", "fileId"];
22188 params.remove_params(&to_remove);
22189 }
22190
22191 let url = params.parse_with_url(&url);
22192
22193 loop {
22194 let token = match self
22195 .hub
22196 .auth
22197 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22198 .await
22199 {
22200 Ok(token) => token,
22201 Err(e) => match dlg.token(e) {
22202 Ok(token) => token,
22203 Err(e) => {
22204 dlg.finished(false);
22205 return Err(common::Error::MissingToken(e));
22206 }
22207 },
22208 };
22209 let mut req_result = {
22210 let client = &self.hub.client;
22211 dlg.pre_request();
22212 let mut req_builder = hyper::Request::builder()
22213 .method(hyper::Method::GET)
22214 .uri(url.as_str())
22215 .header(USER_AGENT, self.hub._user_agent.clone());
22216
22217 if let Some(token) = token.as_ref() {
22218 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22219 }
22220
22221 let request = req_builder
22222 .header(CONTENT_LENGTH, 0_u64)
22223 .body(common::to_body::<String>(None));
22224
22225 client.request(request.unwrap()).await
22226 };
22227
22228 match req_result {
22229 Err(err) => {
22230 if let common::Retry::After(d) = dlg.http_error(&err) {
22231 sleep(d).await;
22232 continue;
22233 }
22234 dlg.finished(false);
22235 return Err(common::Error::HttpError(err));
22236 }
22237 Ok(res) => {
22238 let (mut parts, body) = res.into_parts();
22239 let mut body = common::Body::new(body);
22240 if !parts.status.is_success() {
22241 let bytes = common::to_bytes(body).await.unwrap_or_default();
22242 let error = serde_json::from_str(&common::to_string(&bytes));
22243 let response = common::to_response(parts, bytes.into());
22244
22245 if let common::Retry::After(d) =
22246 dlg.http_failure(&response, error.as_ref().ok())
22247 {
22248 sleep(d).await;
22249 continue;
22250 }
22251
22252 dlg.finished(false);
22253
22254 return Err(match error {
22255 Ok(value) => common::Error::BadRequest(value),
22256 _ => common::Error::Failure(response),
22257 });
22258 }
22259 let response = if enable_resource_parsing {
22260 let bytes = common::to_bytes(body).await.unwrap_or_default();
22261 let encoded = common::to_string(&bytes);
22262 match serde_json::from_str(&encoded) {
22263 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22264 Err(error) => {
22265 dlg.response_json_decode_error(&encoded, &error);
22266 return Err(common::Error::JsonDecodeError(
22267 encoded.to_string(),
22268 error,
22269 ));
22270 }
22271 }
22272 } else {
22273 (
22274 common::Response::from_parts(parts, body),
22275 Default::default(),
22276 )
22277 };
22278
22279 dlg.finished(true);
22280 return Ok(response);
22281 }
22282 }
22283 }
22284 }
22285
22286 /// The ID of the file.
22287 ///
22288 /// Sets the *file id* path property to the given value.
22289 ///
22290 /// Even though the property as already been set when instantiating this call,
22291 /// we provide this method for API completeness.
22292 pub fn file_id(mut self, new_value: &str) -> RevisionGetCall<'a, C> {
22293 self._file_id = new_value.to_string();
22294 self
22295 }
22296 /// The ID of the revision.
22297 ///
22298 /// Sets the *revision id* path property to the given value.
22299 ///
22300 /// Even though the property as already been set when instantiating this call,
22301 /// we provide this method for API completeness.
22302 pub fn revision_id(mut self, new_value: &str) -> RevisionGetCall<'a, C> {
22303 self._revision_id = new_value.to_string();
22304 self
22305 }
22306 /// 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.
22307 ///
22308 /// Sets the *acknowledge abuse* query property to the given value.
22309 pub fn acknowledge_abuse(mut self, new_value: bool) -> RevisionGetCall<'a, C> {
22310 self._acknowledge_abuse = Some(new_value);
22311 self
22312 }
22313 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22314 /// while executing the actual API request.
22315 ///
22316 /// ````text
22317 /// It should be used to handle progress information, and to implement a certain level of resilience.
22318 /// ````
22319 ///
22320 /// Sets the *delegate* property to the given value.
22321 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> RevisionGetCall<'a, C> {
22322 self._delegate = Some(new_value);
22323 self
22324 }
22325
22326 /// Set any additional parameter of the query string used in the request.
22327 /// It should be used to set parameters which are not yet available through their own
22328 /// setters.
22329 ///
22330 /// Please note that this method must not be used to set any of the known parameters
22331 /// which have their own setter method. If done anyway, the request will fail.
22332 ///
22333 /// # Additional Parameters
22334 ///
22335 /// * *$.xgafv* (query-string) - V1 error format.
22336 /// * *access_token* (query-string) - OAuth access token.
22337 /// * *alt* (query-string) - Data format for response.
22338 /// * *callback* (query-string) - JSONP
22339 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22340 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22341 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22342 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22343 /// * *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.
22344 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22345 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22346 pub fn param<T>(mut self, name: T, value: T) -> RevisionGetCall<'a, C>
22347 where
22348 T: AsRef<str>,
22349 {
22350 self._additional_params
22351 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22352 self
22353 }
22354
22355 /// Identifies the authorization scope for the method you are building.
22356 ///
22357 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22358 /// [`Scope::MeetReadonly`].
22359 ///
22360 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22361 /// tokens for more than one scope.
22362 ///
22363 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22364 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22365 /// sufficient, a read-write scope will do as well.
22366 pub fn add_scope<St>(mut self, scope: St) -> RevisionGetCall<'a, C>
22367 where
22368 St: AsRef<str>,
22369 {
22370 self._scopes.insert(String::from(scope.as_ref()));
22371 self
22372 }
22373 /// Identifies the authorization scope(s) for the method you are building.
22374 ///
22375 /// See [`Self::add_scope()`] for details.
22376 pub fn add_scopes<I, St>(mut self, scopes: I) -> RevisionGetCall<'a, C>
22377 where
22378 I: IntoIterator<Item = St>,
22379 St: AsRef<str>,
22380 {
22381 self._scopes
22382 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22383 self
22384 }
22385
22386 /// Removes all scopes, and no default scope will be used either.
22387 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22388 /// for details).
22389 pub fn clear_scopes(mut self) -> RevisionGetCall<'a, C> {
22390 self._scopes.clear();
22391 self
22392 }
22393}
22394
22395/// Lists a file's revisions. For more information, see [Manage file revisions](https://developers.google.com/workspace/drive/api/guides/manage-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.
22396///
22397/// A builder for the *list* method supported by a *revision* resource.
22398/// It is not used directly, but through a [`RevisionMethods`] instance.
22399///
22400/// # Example
22401///
22402/// Instantiate a resource method builder
22403///
22404/// ```test_harness,no_run
22405/// # extern crate hyper;
22406/// # extern crate hyper_rustls;
22407/// # extern crate google_drive3 as drive3;
22408/// # async fn dox() {
22409/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22410///
22411/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22412/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22413/// # .with_native_roots()
22414/// # .unwrap()
22415/// # .https_only()
22416/// # .enable_http2()
22417/// # .build();
22418///
22419/// # let executor = hyper_util::rt::TokioExecutor::new();
22420/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22421/// # secret,
22422/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22423/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22424/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22425/// # ),
22426/// # ).build().await.unwrap();
22427///
22428/// # let client = hyper_util::client::legacy::Client::builder(
22429/// # hyper_util::rt::TokioExecutor::new()
22430/// # )
22431/// # .build(
22432/// # hyper_rustls::HttpsConnectorBuilder::new()
22433/// # .with_native_roots()
22434/// # .unwrap()
22435/// # .https_or_http()
22436/// # .enable_http2()
22437/// # .build()
22438/// # );
22439/// # let mut hub = DriveHub::new(client, auth);
22440/// // You can configure optional parameters by calling the respective setters at will, and
22441/// // execute the final call using `doit()`.
22442/// // Values shown here are possibly random and not representative !
22443/// let result = hub.revisions().list("fileId")
22444/// .page_token("erat")
22445/// .page_size(-42)
22446/// .doit().await;
22447/// # }
22448/// ```
22449pub struct RevisionListCall<'a, C>
22450where
22451 C: 'a,
22452{
22453 hub: &'a DriveHub<C>,
22454 _file_id: String,
22455 _page_token: Option<String>,
22456 _page_size: Option<i32>,
22457 _delegate: Option<&'a mut dyn common::Delegate>,
22458 _additional_params: HashMap<String, String>,
22459 _scopes: BTreeSet<String>,
22460}
22461
22462impl<'a, C> common::CallBuilder for RevisionListCall<'a, C> {}
22463
22464impl<'a, C> RevisionListCall<'a, C>
22465where
22466 C: common::Connector,
22467{
22468 /// Perform the operation you have build so far.
22469 pub async fn doit(mut self) -> common::Result<(common::Response, RevisionList)> {
22470 use std::borrow::Cow;
22471 use std::io::{Read, Seek};
22472
22473 use common::{url::Params, ToParts};
22474 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22475
22476 let mut dd = common::DefaultDelegate;
22477 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22478 dlg.begin(common::MethodInfo {
22479 id: "drive.revisions.list",
22480 http_method: hyper::Method::GET,
22481 });
22482
22483 for &field in ["alt", "fileId", "pageToken", "pageSize"].iter() {
22484 if self._additional_params.contains_key(field) {
22485 dlg.finished(false);
22486 return Err(common::Error::FieldClash(field));
22487 }
22488 }
22489
22490 let mut params = Params::with_capacity(5 + self._additional_params.len());
22491 params.push("fileId", self._file_id);
22492 if let Some(value) = self._page_token.as_ref() {
22493 params.push("pageToken", value);
22494 }
22495 if let Some(value) = self._page_size.as_ref() {
22496 params.push("pageSize", value.to_string());
22497 }
22498
22499 params.extend(self._additional_params.iter());
22500
22501 params.push("alt", "json");
22502 let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions";
22503 if self._scopes.is_empty() {
22504 self._scopes
22505 .insert(Scope::MeetReadonly.as_ref().to_string());
22506 }
22507
22508 #[allow(clippy::single_element_loop)]
22509 for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
22510 url = params.uri_replacement(url, param_name, find_this, false);
22511 }
22512 {
22513 let to_remove = ["fileId"];
22514 params.remove_params(&to_remove);
22515 }
22516
22517 let url = params.parse_with_url(&url);
22518
22519 loop {
22520 let token = match self
22521 .hub
22522 .auth
22523 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22524 .await
22525 {
22526 Ok(token) => token,
22527 Err(e) => match dlg.token(e) {
22528 Ok(token) => token,
22529 Err(e) => {
22530 dlg.finished(false);
22531 return Err(common::Error::MissingToken(e));
22532 }
22533 },
22534 };
22535 let mut req_result = {
22536 let client = &self.hub.client;
22537 dlg.pre_request();
22538 let mut req_builder = hyper::Request::builder()
22539 .method(hyper::Method::GET)
22540 .uri(url.as_str())
22541 .header(USER_AGENT, self.hub._user_agent.clone());
22542
22543 if let Some(token) = token.as_ref() {
22544 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22545 }
22546
22547 let request = req_builder
22548 .header(CONTENT_LENGTH, 0_u64)
22549 .body(common::to_body::<String>(None));
22550
22551 client.request(request.unwrap()).await
22552 };
22553
22554 match req_result {
22555 Err(err) => {
22556 if let common::Retry::After(d) = dlg.http_error(&err) {
22557 sleep(d).await;
22558 continue;
22559 }
22560 dlg.finished(false);
22561 return Err(common::Error::HttpError(err));
22562 }
22563 Ok(res) => {
22564 let (mut parts, body) = res.into_parts();
22565 let mut body = common::Body::new(body);
22566 if !parts.status.is_success() {
22567 let bytes = common::to_bytes(body).await.unwrap_or_default();
22568 let error = serde_json::from_str(&common::to_string(&bytes));
22569 let response = common::to_response(parts, bytes.into());
22570
22571 if let common::Retry::After(d) =
22572 dlg.http_failure(&response, error.as_ref().ok())
22573 {
22574 sleep(d).await;
22575 continue;
22576 }
22577
22578 dlg.finished(false);
22579
22580 return Err(match error {
22581 Ok(value) => common::Error::BadRequest(value),
22582 _ => common::Error::Failure(response),
22583 });
22584 }
22585 let response = {
22586 let bytes = common::to_bytes(body).await.unwrap_or_default();
22587 let encoded = common::to_string(&bytes);
22588 match serde_json::from_str(&encoded) {
22589 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22590 Err(error) => {
22591 dlg.response_json_decode_error(&encoded, &error);
22592 return Err(common::Error::JsonDecodeError(
22593 encoded.to_string(),
22594 error,
22595 ));
22596 }
22597 }
22598 };
22599
22600 dlg.finished(true);
22601 return Ok(response);
22602 }
22603 }
22604 }
22605 }
22606
22607 /// The ID of the file.
22608 ///
22609 /// Sets the *file id* path property to the given value.
22610 ///
22611 /// Even though the property as already been set when instantiating this call,
22612 /// we provide this method for API completeness.
22613 pub fn file_id(mut self, new_value: &str) -> RevisionListCall<'a, C> {
22614 self._file_id = new_value.to_string();
22615 self
22616 }
22617 /// 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.
22618 ///
22619 /// Sets the *page token* query property to the given value.
22620 pub fn page_token(mut self, new_value: &str) -> RevisionListCall<'a, C> {
22621 self._page_token = Some(new_value.to_string());
22622 self
22623 }
22624 /// The maximum number of revisions to return per page.
22625 ///
22626 /// Sets the *page size* query property to the given value.
22627 pub fn page_size(mut self, new_value: i32) -> RevisionListCall<'a, C> {
22628 self._page_size = Some(new_value);
22629 self
22630 }
22631 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22632 /// while executing the actual API request.
22633 ///
22634 /// ````text
22635 /// It should be used to handle progress information, and to implement a certain level of resilience.
22636 /// ````
22637 ///
22638 /// Sets the *delegate* property to the given value.
22639 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> RevisionListCall<'a, C> {
22640 self._delegate = Some(new_value);
22641 self
22642 }
22643
22644 /// Set any additional parameter of the query string used in the request.
22645 /// It should be used to set parameters which are not yet available through their own
22646 /// setters.
22647 ///
22648 /// Please note that this method must not be used to set any of the known parameters
22649 /// which have their own setter method. If done anyway, the request will fail.
22650 ///
22651 /// # Additional Parameters
22652 ///
22653 /// * *$.xgafv* (query-string) - V1 error format.
22654 /// * *access_token* (query-string) - OAuth access token.
22655 /// * *alt* (query-string) - Data format for response.
22656 /// * *callback* (query-string) - JSONP
22657 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22658 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22659 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22660 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22661 /// * *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.
22662 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22663 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22664 pub fn param<T>(mut self, name: T, value: T) -> RevisionListCall<'a, C>
22665 where
22666 T: AsRef<str>,
22667 {
22668 self._additional_params
22669 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22670 self
22671 }
22672
22673 /// Identifies the authorization scope for the method you are building.
22674 ///
22675 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22676 /// [`Scope::MeetReadonly`].
22677 ///
22678 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22679 /// tokens for more than one scope.
22680 ///
22681 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22682 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22683 /// sufficient, a read-write scope will do as well.
22684 pub fn add_scope<St>(mut self, scope: St) -> RevisionListCall<'a, C>
22685 where
22686 St: AsRef<str>,
22687 {
22688 self._scopes.insert(String::from(scope.as_ref()));
22689 self
22690 }
22691 /// Identifies the authorization scope(s) for the method you are building.
22692 ///
22693 /// See [`Self::add_scope()`] for details.
22694 pub fn add_scopes<I, St>(mut self, scopes: I) -> RevisionListCall<'a, C>
22695 where
22696 I: IntoIterator<Item = St>,
22697 St: AsRef<str>,
22698 {
22699 self._scopes
22700 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22701 self
22702 }
22703
22704 /// Removes all scopes, and no default scope will be used either.
22705 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22706 /// for details).
22707 pub fn clear_scopes(mut self) -> RevisionListCall<'a, C> {
22708 self._scopes.clear();
22709 self
22710 }
22711}
22712
22713/// Updates a revision with patch semantics. For more information, see [Manage file revisions](https://developers.google.com/workspace/drive/api/guides/manage-revisions).
22714///
22715/// A builder for the *update* method supported by a *revision* resource.
22716/// It is not used directly, but through a [`RevisionMethods`] instance.
22717///
22718/// # Example
22719///
22720/// Instantiate a resource method builder
22721///
22722/// ```test_harness,no_run
22723/// # extern crate hyper;
22724/// # extern crate hyper_rustls;
22725/// # extern crate google_drive3 as drive3;
22726/// use drive3::api::Revision;
22727/// # async fn dox() {
22728/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22729///
22730/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22731/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22732/// # .with_native_roots()
22733/// # .unwrap()
22734/// # .https_only()
22735/// # .enable_http2()
22736/// # .build();
22737///
22738/// # let executor = hyper_util::rt::TokioExecutor::new();
22739/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22740/// # secret,
22741/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22742/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22743/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22744/// # ),
22745/// # ).build().await.unwrap();
22746///
22747/// # let client = hyper_util::client::legacy::Client::builder(
22748/// # hyper_util::rt::TokioExecutor::new()
22749/// # )
22750/// # .build(
22751/// # hyper_rustls::HttpsConnectorBuilder::new()
22752/// # .with_native_roots()
22753/// # .unwrap()
22754/// # .https_or_http()
22755/// # .enable_http2()
22756/// # .build()
22757/// # );
22758/// # let mut hub = DriveHub::new(client, auth);
22759/// // As the method needs a request, you would usually fill it with the desired information
22760/// // into the respective structure. Some of the parts shown here might not be applicable !
22761/// // Values shown here are possibly random and not representative !
22762/// let mut req = Revision::default();
22763///
22764/// // You can configure optional parameters by calling the respective setters at will, and
22765/// // execute the final call using `doit()`.
22766/// // Values shown here are possibly random and not representative !
22767/// let result = hub.revisions().update(req, "fileId", "revisionId")
22768/// .doit().await;
22769/// # }
22770/// ```
22771pub struct RevisionUpdateCall<'a, C>
22772where
22773 C: 'a,
22774{
22775 hub: &'a DriveHub<C>,
22776 _request: Revision,
22777 _file_id: String,
22778 _revision_id: String,
22779 _delegate: Option<&'a mut dyn common::Delegate>,
22780 _additional_params: HashMap<String, String>,
22781 _scopes: BTreeSet<String>,
22782}
22783
22784impl<'a, C> common::CallBuilder for RevisionUpdateCall<'a, C> {}
22785
22786impl<'a, C> RevisionUpdateCall<'a, C>
22787where
22788 C: common::Connector,
22789{
22790 /// Perform the operation you have build so far.
22791 pub async fn doit(mut self) -> common::Result<(common::Response, Revision)> {
22792 use std::borrow::Cow;
22793 use std::io::{Read, Seek};
22794
22795 use common::{url::Params, ToParts};
22796 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22797
22798 let mut dd = common::DefaultDelegate;
22799 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22800 dlg.begin(common::MethodInfo {
22801 id: "drive.revisions.update",
22802 http_method: hyper::Method::PATCH,
22803 });
22804
22805 for &field in ["alt", "fileId", "revisionId"].iter() {
22806 if self._additional_params.contains_key(field) {
22807 dlg.finished(false);
22808 return Err(common::Error::FieldClash(field));
22809 }
22810 }
22811
22812 let mut params = Params::with_capacity(5 + self._additional_params.len());
22813 params.push("fileId", self._file_id);
22814 params.push("revisionId", self._revision_id);
22815
22816 params.extend(self._additional_params.iter());
22817
22818 params.push("alt", "json");
22819 let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}";
22820 if self._scopes.is_empty() {
22821 self._scopes.insert(Scope::Full.as_ref().to_string());
22822 }
22823
22824 #[allow(clippy::single_element_loop)]
22825 for &(find_this, param_name) in
22826 [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter()
22827 {
22828 url = params.uri_replacement(url, param_name, find_this, false);
22829 }
22830 {
22831 let to_remove = ["revisionId", "fileId"];
22832 params.remove_params(&to_remove);
22833 }
22834
22835 let url = params.parse_with_url(&url);
22836
22837 let mut json_mime_type = mime::APPLICATION_JSON;
22838 let mut request_value_reader = {
22839 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22840 common::remove_json_null_values(&mut value);
22841 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22842 serde_json::to_writer(&mut dst, &value).unwrap();
22843 dst
22844 };
22845 let request_size = request_value_reader
22846 .seek(std::io::SeekFrom::End(0))
22847 .unwrap();
22848 request_value_reader
22849 .seek(std::io::SeekFrom::Start(0))
22850 .unwrap();
22851
22852 loop {
22853 let token = match self
22854 .hub
22855 .auth
22856 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22857 .await
22858 {
22859 Ok(token) => token,
22860 Err(e) => match dlg.token(e) {
22861 Ok(token) => token,
22862 Err(e) => {
22863 dlg.finished(false);
22864 return Err(common::Error::MissingToken(e));
22865 }
22866 },
22867 };
22868 request_value_reader
22869 .seek(std::io::SeekFrom::Start(0))
22870 .unwrap();
22871 let mut req_result = {
22872 let client = &self.hub.client;
22873 dlg.pre_request();
22874 let mut req_builder = hyper::Request::builder()
22875 .method(hyper::Method::PATCH)
22876 .uri(url.as_str())
22877 .header(USER_AGENT, self.hub._user_agent.clone());
22878
22879 if let Some(token) = token.as_ref() {
22880 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22881 }
22882
22883 let request = req_builder
22884 .header(CONTENT_TYPE, json_mime_type.to_string())
22885 .header(CONTENT_LENGTH, request_size as u64)
22886 .body(common::to_body(
22887 request_value_reader.get_ref().clone().into(),
22888 ));
22889
22890 client.request(request.unwrap()).await
22891 };
22892
22893 match req_result {
22894 Err(err) => {
22895 if let common::Retry::After(d) = dlg.http_error(&err) {
22896 sleep(d).await;
22897 continue;
22898 }
22899 dlg.finished(false);
22900 return Err(common::Error::HttpError(err));
22901 }
22902 Ok(res) => {
22903 let (mut parts, body) = res.into_parts();
22904 let mut body = common::Body::new(body);
22905 if !parts.status.is_success() {
22906 let bytes = common::to_bytes(body).await.unwrap_or_default();
22907 let error = serde_json::from_str(&common::to_string(&bytes));
22908 let response = common::to_response(parts, bytes.into());
22909
22910 if let common::Retry::After(d) =
22911 dlg.http_failure(&response, error.as_ref().ok())
22912 {
22913 sleep(d).await;
22914 continue;
22915 }
22916
22917 dlg.finished(false);
22918
22919 return Err(match error {
22920 Ok(value) => common::Error::BadRequest(value),
22921 _ => common::Error::Failure(response),
22922 });
22923 }
22924 let response = {
22925 let bytes = common::to_bytes(body).await.unwrap_or_default();
22926 let encoded = common::to_string(&bytes);
22927 match serde_json::from_str(&encoded) {
22928 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22929 Err(error) => {
22930 dlg.response_json_decode_error(&encoded, &error);
22931 return Err(common::Error::JsonDecodeError(
22932 encoded.to_string(),
22933 error,
22934 ));
22935 }
22936 }
22937 };
22938
22939 dlg.finished(true);
22940 return Ok(response);
22941 }
22942 }
22943 }
22944 }
22945
22946 ///
22947 /// Sets the *request* property to the given value.
22948 ///
22949 /// Even though the property as already been set when instantiating this call,
22950 /// we provide this method for API completeness.
22951 pub fn request(mut self, new_value: Revision) -> RevisionUpdateCall<'a, C> {
22952 self._request = new_value;
22953 self
22954 }
22955 /// The ID of the file.
22956 ///
22957 /// Sets the *file id* path property to the given value.
22958 ///
22959 /// Even though the property as already been set when instantiating this call,
22960 /// we provide this method for API completeness.
22961 pub fn file_id(mut self, new_value: &str) -> RevisionUpdateCall<'a, C> {
22962 self._file_id = new_value.to_string();
22963 self
22964 }
22965 /// The ID of the revision.
22966 ///
22967 /// Sets the *revision id* path property to the given value.
22968 ///
22969 /// Even though the property as already been set when instantiating this call,
22970 /// we provide this method for API completeness.
22971 pub fn revision_id(mut self, new_value: &str) -> RevisionUpdateCall<'a, C> {
22972 self._revision_id = new_value.to_string();
22973 self
22974 }
22975 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22976 /// while executing the actual API request.
22977 ///
22978 /// ````text
22979 /// It should be used to handle progress information, and to implement a certain level of resilience.
22980 /// ````
22981 ///
22982 /// Sets the *delegate* property to the given value.
22983 pub fn delegate(
22984 mut self,
22985 new_value: &'a mut dyn common::Delegate,
22986 ) -> RevisionUpdateCall<'a, C> {
22987 self._delegate = Some(new_value);
22988 self
22989 }
22990
22991 /// Set any additional parameter of the query string used in the request.
22992 /// It should be used to set parameters which are not yet available through their own
22993 /// setters.
22994 ///
22995 /// Please note that this method must not be used to set any of the known parameters
22996 /// which have their own setter method. If done anyway, the request will fail.
22997 ///
22998 /// # Additional Parameters
22999 ///
23000 /// * *$.xgafv* (query-string) - V1 error format.
23001 /// * *access_token* (query-string) - OAuth access token.
23002 /// * *alt* (query-string) - Data format for response.
23003 /// * *callback* (query-string) - JSONP
23004 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23005 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23006 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23007 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23008 /// * *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.
23009 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23010 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23011 pub fn param<T>(mut self, name: T, value: T) -> RevisionUpdateCall<'a, C>
23012 where
23013 T: AsRef<str>,
23014 {
23015 self._additional_params
23016 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23017 self
23018 }
23019
23020 /// Identifies the authorization scope for the method you are building.
23021 ///
23022 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23023 /// [`Scope::Full`].
23024 ///
23025 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23026 /// tokens for more than one scope.
23027 ///
23028 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23029 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23030 /// sufficient, a read-write scope will do as well.
23031 pub fn add_scope<St>(mut self, scope: St) -> RevisionUpdateCall<'a, C>
23032 where
23033 St: AsRef<str>,
23034 {
23035 self._scopes.insert(String::from(scope.as_ref()));
23036 self
23037 }
23038 /// Identifies the authorization scope(s) for the method you are building.
23039 ///
23040 /// See [`Self::add_scope()`] for details.
23041 pub fn add_scopes<I, St>(mut self, scopes: I) -> RevisionUpdateCall<'a, C>
23042 where
23043 I: IntoIterator<Item = St>,
23044 St: AsRef<str>,
23045 {
23046 self._scopes
23047 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23048 self
23049 }
23050
23051 /// Removes all scopes, and no default scope will be used either.
23052 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23053 /// for details).
23054 pub fn clear_scopes(mut self) -> RevisionUpdateCall<'a, C> {
23055 self._scopes.clear();
23056 self
23057 }
23058}
23059
23060/// Deprecated: Use `drives.create` instead.
23061///
23062/// A builder for the *create* method supported by a *teamdrive* resource.
23063/// It is not used directly, but through a [`TeamdriveMethods`] instance.
23064///
23065/// # Example
23066///
23067/// Instantiate a resource method builder
23068///
23069/// ```test_harness,no_run
23070/// # extern crate hyper;
23071/// # extern crate hyper_rustls;
23072/// # extern crate google_drive3 as drive3;
23073/// use drive3::api::TeamDrive;
23074/// # async fn dox() {
23075/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23076///
23077/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23078/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23079/// # .with_native_roots()
23080/// # .unwrap()
23081/// # .https_only()
23082/// # .enable_http2()
23083/// # .build();
23084///
23085/// # let executor = hyper_util::rt::TokioExecutor::new();
23086/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23087/// # secret,
23088/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23089/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23090/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23091/// # ),
23092/// # ).build().await.unwrap();
23093///
23094/// # let client = hyper_util::client::legacy::Client::builder(
23095/// # hyper_util::rt::TokioExecutor::new()
23096/// # )
23097/// # .build(
23098/// # hyper_rustls::HttpsConnectorBuilder::new()
23099/// # .with_native_roots()
23100/// # .unwrap()
23101/// # .https_or_http()
23102/// # .enable_http2()
23103/// # .build()
23104/// # );
23105/// # let mut hub = DriveHub::new(client, auth);
23106/// // As the method needs a request, you would usually fill it with the desired information
23107/// // into the respective structure. Some of the parts shown here might not be applicable !
23108/// // Values shown here are possibly random and not representative !
23109/// let mut req = TeamDrive::default();
23110///
23111/// // You can configure optional parameters by calling the respective setters at will, and
23112/// // execute the final call using `doit()`.
23113/// // Values shown here are possibly random and not representative !
23114/// let result = hub.teamdrives().create(req, "requestId")
23115/// .doit().await;
23116/// # }
23117/// ```
23118pub struct TeamdriveCreateCall<'a, C>
23119where
23120 C: 'a,
23121{
23122 hub: &'a DriveHub<C>,
23123 _request: TeamDrive,
23124 _request_id: String,
23125 _delegate: Option<&'a mut dyn common::Delegate>,
23126 _additional_params: HashMap<String, String>,
23127 _scopes: BTreeSet<String>,
23128}
23129
23130impl<'a, C> common::CallBuilder for TeamdriveCreateCall<'a, C> {}
23131
23132impl<'a, C> TeamdriveCreateCall<'a, C>
23133where
23134 C: common::Connector,
23135{
23136 /// Perform the operation you have build so far.
23137 pub async fn doit(mut self) -> common::Result<(common::Response, TeamDrive)> {
23138 use std::borrow::Cow;
23139 use std::io::{Read, Seek};
23140
23141 use common::{url::Params, ToParts};
23142 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23143
23144 let mut dd = common::DefaultDelegate;
23145 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23146 dlg.begin(common::MethodInfo {
23147 id: "drive.teamdrives.create",
23148 http_method: hyper::Method::POST,
23149 });
23150
23151 for &field in ["alt", "requestId"].iter() {
23152 if self._additional_params.contains_key(field) {
23153 dlg.finished(false);
23154 return Err(common::Error::FieldClash(field));
23155 }
23156 }
23157
23158 let mut params = Params::with_capacity(4 + self._additional_params.len());
23159 params.push("requestId", self._request_id);
23160
23161 params.extend(self._additional_params.iter());
23162
23163 params.push("alt", "json");
23164 let mut url = self.hub._base_url.clone() + "teamdrives";
23165 if self._scopes.is_empty() {
23166 self._scopes.insert(Scope::Full.as_ref().to_string());
23167 }
23168
23169 let url = params.parse_with_url(&url);
23170
23171 let mut json_mime_type = mime::APPLICATION_JSON;
23172 let mut request_value_reader = {
23173 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23174 common::remove_json_null_values(&mut value);
23175 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23176 serde_json::to_writer(&mut dst, &value).unwrap();
23177 dst
23178 };
23179 let request_size = request_value_reader
23180 .seek(std::io::SeekFrom::End(0))
23181 .unwrap();
23182 request_value_reader
23183 .seek(std::io::SeekFrom::Start(0))
23184 .unwrap();
23185
23186 loop {
23187 let token = match self
23188 .hub
23189 .auth
23190 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23191 .await
23192 {
23193 Ok(token) => token,
23194 Err(e) => match dlg.token(e) {
23195 Ok(token) => token,
23196 Err(e) => {
23197 dlg.finished(false);
23198 return Err(common::Error::MissingToken(e));
23199 }
23200 },
23201 };
23202 request_value_reader
23203 .seek(std::io::SeekFrom::Start(0))
23204 .unwrap();
23205 let mut req_result = {
23206 let client = &self.hub.client;
23207 dlg.pre_request();
23208 let mut req_builder = hyper::Request::builder()
23209 .method(hyper::Method::POST)
23210 .uri(url.as_str())
23211 .header(USER_AGENT, self.hub._user_agent.clone());
23212
23213 if let Some(token) = token.as_ref() {
23214 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23215 }
23216
23217 let request = req_builder
23218 .header(CONTENT_TYPE, json_mime_type.to_string())
23219 .header(CONTENT_LENGTH, request_size as u64)
23220 .body(common::to_body(
23221 request_value_reader.get_ref().clone().into(),
23222 ));
23223
23224 client.request(request.unwrap()).await
23225 };
23226
23227 match req_result {
23228 Err(err) => {
23229 if let common::Retry::After(d) = dlg.http_error(&err) {
23230 sleep(d).await;
23231 continue;
23232 }
23233 dlg.finished(false);
23234 return Err(common::Error::HttpError(err));
23235 }
23236 Ok(res) => {
23237 let (mut parts, body) = res.into_parts();
23238 let mut body = common::Body::new(body);
23239 if !parts.status.is_success() {
23240 let bytes = common::to_bytes(body).await.unwrap_or_default();
23241 let error = serde_json::from_str(&common::to_string(&bytes));
23242 let response = common::to_response(parts, bytes.into());
23243
23244 if let common::Retry::After(d) =
23245 dlg.http_failure(&response, error.as_ref().ok())
23246 {
23247 sleep(d).await;
23248 continue;
23249 }
23250
23251 dlg.finished(false);
23252
23253 return Err(match error {
23254 Ok(value) => common::Error::BadRequest(value),
23255 _ => common::Error::Failure(response),
23256 });
23257 }
23258 let response = {
23259 let bytes = common::to_bytes(body).await.unwrap_or_default();
23260 let encoded = common::to_string(&bytes);
23261 match serde_json::from_str(&encoded) {
23262 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23263 Err(error) => {
23264 dlg.response_json_decode_error(&encoded, &error);
23265 return Err(common::Error::JsonDecodeError(
23266 encoded.to_string(),
23267 error,
23268 ));
23269 }
23270 }
23271 };
23272
23273 dlg.finished(true);
23274 return Ok(response);
23275 }
23276 }
23277 }
23278 }
23279
23280 ///
23281 /// Sets the *request* property to the given value.
23282 ///
23283 /// Even though the property as already been set when instantiating this call,
23284 /// we provide this method for API completeness.
23285 pub fn request(mut self, new_value: TeamDrive) -> TeamdriveCreateCall<'a, C> {
23286 self._request = new_value;
23287 self
23288 }
23289 /// 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.
23290 ///
23291 /// Sets the *request id* query property to the given value.
23292 ///
23293 /// Even though the property as already been set when instantiating this call,
23294 /// we provide this method for API completeness.
23295 pub fn request_id(mut self, new_value: &str) -> TeamdriveCreateCall<'a, C> {
23296 self._request_id = new_value.to_string();
23297 self
23298 }
23299 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23300 /// while executing the actual API request.
23301 ///
23302 /// ````text
23303 /// It should be used to handle progress information, and to implement a certain level of resilience.
23304 /// ````
23305 ///
23306 /// Sets the *delegate* property to the given value.
23307 pub fn delegate(
23308 mut self,
23309 new_value: &'a mut dyn common::Delegate,
23310 ) -> TeamdriveCreateCall<'a, C> {
23311 self._delegate = Some(new_value);
23312 self
23313 }
23314
23315 /// Set any additional parameter of the query string used in the request.
23316 /// It should be used to set parameters which are not yet available through their own
23317 /// setters.
23318 ///
23319 /// Please note that this method must not be used to set any of the known parameters
23320 /// which have their own setter method. If done anyway, the request will fail.
23321 ///
23322 /// # Additional Parameters
23323 ///
23324 /// * *$.xgafv* (query-string) - V1 error format.
23325 /// * *access_token* (query-string) - OAuth access token.
23326 /// * *alt* (query-string) - Data format for response.
23327 /// * *callback* (query-string) - JSONP
23328 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23329 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23330 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23331 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23332 /// * *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.
23333 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23334 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23335 pub fn param<T>(mut self, name: T, value: T) -> TeamdriveCreateCall<'a, C>
23336 where
23337 T: AsRef<str>,
23338 {
23339 self._additional_params
23340 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23341 self
23342 }
23343
23344 /// Identifies the authorization scope for the method you are building.
23345 ///
23346 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23347 /// [`Scope::Full`].
23348 ///
23349 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23350 /// tokens for more than one scope.
23351 ///
23352 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23353 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23354 /// sufficient, a read-write scope will do as well.
23355 pub fn add_scope<St>(mut self, scope: St) -> TeamdriveCreateCall<'a, C>
23356 where
23357 St: AsRef<str>,
23358 {
23359 self._scopes.insert(String::from(scope.as_ref()));
23360 self
23361 }
23362 /// Identifies the authorization scope(s) for the method you are building.
23363 ///
23364 /// See [`Self::add_scope()`] for details.
23365 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamdriveCreateCall<'a, C>
23366 where
23367 I: IntoIterator<Item = St>,
23368 St: AsRef<str>,
23369 {
23370 self._scopes
23371 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23372 self
23373 }
23374
23375 /// Removes all scopes, and no default scope will be used either.
23376 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23377 /// for details).
23378 pub fn clear_scopes(mut self) -> TeamdriveCreateCall<'a, C> {
23379 self._scopes.clear();
23380 self
23381 }
23382}
23383
23384/// Deprecated: Use `drives.delete` instead.
23385///
23386/// A builder for the *delete* method supported by a *teamdrive* resource.
23387/// It is not used directly, but through a [`TeamdriveMethods`] instance.
23388///
23389/// # Example
23390///
23391/// Instantiate a resource method builder
23392///
23393/// ```test_harness,no_run
23394/// # extern crate hyper;
23395/// # extern crate hyper_rustls;
23396/// # extern crate google_drive3 as drive3;
23397/// # async fn dox() {
23398/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23399///
23400/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23401/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23402/// # .with_native_roots()
23403/// # .unwrap()
23404/// # .https_only()
23405/// # .enable_http2()
23406/// # .build();
23407///
23408/// # let executor = hyper_util::rt::TokioExecutor::new();
23409/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23410/// # secret,
23411/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23412/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23413/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23414/// # ),
23415/// # ).build().await.unwrap();
23416///
23417/// # let client = hyper_util::client::legacy::Client::builder(
23418/// # hyper_util::rt::TokioExecutor::new()
23419/// # )
23420/// # .build(
23421/// # hyper_rustls::HttpsConnectorBuilder::new()
23422/// # .with_native_roots()
23423/// # .unwrap()
23424/// # .https_or_http()
23425/// # .enable_http2()
23426/// # .build()
23427/// # );
23428/// # let mut hub = DriveHub::new(client, auth);
23429/// // You can configure optional parameters by calling the respective setters at will, and
23430/// // execute the final call using `doit()`.
23431/// // Values shown here are possibly random and not representative !
23432/// let result = hub.teamdrives().delete("teamDriveId")
23433/// .doit().await;
23434/// # }
23435/// ```
23436pub struct TeamdriveDeleteCall<'a, C>
23437where
23438 C: 'a,
23439{
23440 hub: &'a DriveHub<C>,
23441 _team_drive_id: String,
23442 _delegate: Option<&'a mut dyn common::Delegate>,
23443 _additional_params: HashMap<String, String>,
23444 _scopes: BTreeSet<String>,
23445}
23446
23447impl<'a, C> common::CallBuilder for TeamdriveDeleteCall<'a, C> {}
23448
23449impl<'a, C> TeamdriveDeleteCall<'a, C>
23450where
23451 C: common::Connector,
23452{
23453 /// Perform the operation you have build so far.
23454 pub async fn doit(mut self) -> common::Result<common::Response> {
23455 use std::borrow::Cow;
23456 use std::io::{Read, Seek};
23457
23458 use common::{url::Params, ToParts};
23459 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23460
23461 let mut dd = common::DefaultDelegate;
23462 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23463 dlg.begin(common::MethodInfo {
23464 id: "drive.teamdrives.delete",
23465 http_method: hyper::Method::DELETE,
23466 });
23467
23468 for &field in ["teamDriveId"].iter() {
23469 if self._additional_params.contains_key(field) {
23470 dlg.finished(false);
23471 return Err(common::Error::FieldClash(field));
23472 }
23473 }
23474
23475 let mut params = Params::with_capacity(2 + self._additional_params.len());
23476 params.push("teamDriveId", self._team_drive_id);
23477
23478 params.extend(self._additional_params.iter());
23479
23480 let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}";
23481 if self._scopes.is_empty() {
23482 self._scopes.insert(Scope::Full.as_ref().to_string());
23483 }
23484
23485 #[allow(clippy::single_element_loop)]
23486 for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() {
23487 url = params.uri_replacement(url, param_name, find_this, false);
23488 }
23489 {
23490 let to_remove = ["teamDriveId"];
23491 params.remove_params(&to_remove);
23492 }
23493
23494 let url = params.parse_with_url(&url);
23495
23496 loop {
23497 let token = match self
23498 .hub
23499 .auth
23500 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23501 .await
23502 {
23503 Ok(token) => token,
23504 Err(e) => match dlg.token(e) {
23505 Ok(token) => token,
23506 Err(e) => {
23507 dlg.finished(false);
23508 return Err(common::Error::MissingToken(e));
23509 }
23510 },
23511 };
23512 let mut req_result = {
23513 let client = &self.hub.client;
23514 dlg.pre_request();
23515 let mut req_builder = hyper::Request::builder()
23516 .method(hyper::Method::DELETE)
23517 .uri(url.as_str())
23518 .header(USER_AGENT, self.hub._user_agent.clone());
23519
23520 if let Some(token) = token.as_ref() {
23521 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23522 }
23523
23524 let request = req_builder
23525 .header(CONTENT_LENGTH, 0_u64)
23526 .body(common::to_body::<String>(None));
23527
23528 client.request(request.unwrap()).await
23529 };
23530
23531 match req_result {
23532 Err(err) => {
23533 if let common::Retry::After(d) = dlg.http_error(&err) {
23534 sleep(d).await;
23535 continue;
23536 }
23537 dlg.finished(false);
23538 return Err(common::Error::HttpError(err));
23539 }
23540 Ok(res) => {
23541 let (mut parts, body) = res.into_parts();
23542 let mut body = common::Body::new(body);
23543 if !parts.status.is_success() {
23544 let bytes = common::to_bytes(body).await.unwrap_or_default();
23545 let error = serde_json::from_str(&common::to_string(&bytes));
23546 let response = common::to_response(parts, bytes.into());
23547
23548 if let common::Retry::After(d) =
23549 dlg.http_failure(&response, error.as_ref().ok())
23550 {
23551 sleep(d).await;
23552 continue;
23553 }
23554
23555 dlg.finished(false);
23556
23557 return Err(match error {
23558 Ok(value) => common::Error::BadRequest(value),
23559 _ => common::Error::Failure(response),
23560 });
23561 }
23562 let response = common::Response::from_parts(parts, body);
23563
23564 dlg.finished(true);
23565 return Ok(response);
23566 }
23567 }
23568 }
23569 }
23570
23571 /// The ID of the Team Drive
23572 ///
23573 /// Sets the *team drive id* path property to the given value.
23574 ///
23575 /// Even though the property as already been set when instantiating this call,
23576 /// we provide this method for API completeness.
23577 pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveDeleteCall<'a, C> {
23578 self._team_drive_id = new_value.to_string();
23579 self
23580 }
23581 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23582 /// while executing the actual API request.
23583 ///
23584 /// ````text
23585 /// It should be used to handle progress information, and to implement a certain level of resilience.
23586 /// ````
23587 ///
23588 /// Sets the *delegate* property to the given value.
23589 pub fn delegate(
23590 mut self,
23591 new_value: &'a mut dyn common::Delegate,
23592 ) -> TeamdriveDeleteCall<'a, C> {
23593 self._delegate = Some(new_value);
23594 self
23595 }
23596
23597 /// Set any additional parameter of the query string used in the request.
23598 /// It should be used to set parameters which are not yet available through their own
23599 /// setters.
23600 ///
23601 /// Please note that this method must not be used to set any of the known parameters
23602 /// which have their own setter method. If done anyway, the request will fail.
23603 ///
23604 /// # Additional Parameters
23605 ///
23606 /// * *$.xgafv* (query-string) - V1 error format.
23607 /// * *access_token* (query-string) - OAuth access token.
23608 /// * *alt* (query-string) - Data format for response.
23609 /// * *callback* (query-string) - JSONP
23610 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23611 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23612 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23613 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23614 /// * *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.
23615 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23616 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23617 pub fn param<T>(mut self, name: T, value: T) -> TeamdriveDeleteCall<'a, C>
23618 where
23619 T: AsRef<str>,
23620 {
23621 self._additional_params
23622 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23623 self
23624 }
23625
23626 /// Identifies the authorization scope for the method you are building.
23627 ///
23628 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23629 /// [`Scope::Full`].
23630 ///
23631 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23632 /// tokens for more than one scope.
23633 ///
23634 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23635 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23636 /// sufficient, a read-write scope will do as well.
23637 pub fn add_scope<St>(mut self, scope: St) -> TeamdriveDeleteCall<'a, C>
23638 where
23639 St: AsRef<str>,
23640 {
23641 self._scopes.insert(String::from(scope.as_ref()));
23642 self
23643 }
23644 /// Identifies the authorization scope(s) for the method you are building.
23645 ///
23646 /// See [`Self::add_scope()`] for details.
23647 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamdriveDeleteCall<'a, C>
23648 where
23649 I: IntoIterator<Item = St>,
23650 St: AsRef<str>,
23651 {
23652 self._scopes
23653 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23654 self
23655 }
23656
23657 /// Removes all scopes, and no default scope will be used either.
23658 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23659 /// for details).
23660 pub fn clear_scopes(mut self) -> TeamdriveDeleteCall<'a, C> {
23661 self._scopes.clear();
23662 self
23663 }
23664}
23665
23666/// Deprecated: Use `drives.get` instead.
23667///
23668/// A builder for the *get* method supported by a *teamdrive* resource.
23669/// It is not used directly, but through a [`TeamdriveMethods`] instance.
23670///
23671/// # Example
23672///
23673/// Instantiate a resource method builder
23674///
23675/// ```test_harness,no_run
23676/// # extern crate hyper;
23677/// # extern crate hyper_rustls;
23678/// # extern crate google_drive3 as drive3;
23679/// # async fn dox() {
23680/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23681///
23682/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23683/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23684/// # .with_native_roots()
23685/// # .unwrap()
23686/// # .https_only()
23687/// # .enable_http2()
23688/// # .build();
23689///
23690/// # let executor = hyper_util::rt::TokioExecutor::new();
23691/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23692/// # secret,
23693/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23694/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23695/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23696/// # ),
23697/// # ).build().await.unwrap();
23698///
23699/// # let client = hyper_util::client::legacy::Client::builder(
23700/// # hyper_util::rt::TokioExecutor::new()
23701/// # )
23702/// # .build(
23703/// # hyper_rustls::HttpsConnectorBuilder::new()
23704/// # .with_native_roots()
23705/// # .unwrap()
23706/// # .https_or_http()
23707/// # .enable_http2()
23708/// # .build()
23709/// # );
23710/// # let mut hub = DriveHub::new(client, auth);
23711/// // You can configure optional parameters by calling the respective setters at will, and
23712/// // execute the final call using `doit()`.
23713/// // Values shown here are possibly random and not representative !
23714/// let result = hub.teamdrives().get("teamDriveId")
23715/// .use_domain_admin_access(false)
23716/// .doit().await;
23717/// # }
23718/// ```
23719pub struct TeamdriveGetCall<'a, C>
23720where
23721 C: 'a,
23722{
23723 hub: &'a DriveHub<C>,
23724 _team_drive_id: String,
23725 _use_domain_admin_access: Option<bool>,
23726 _delegate: Option<&'a mut dyn common::Delegate>,
23727 _additional_params: HashMap<String, String>,
23728 _scopes: BTreeSet<String>,
23729}
23730
23731impl<'a, C> common::CallBuilder for TeamdriveGetCall<'a, C> {}
23732
23733impl<'a, C> TeamdriveGetCall<'a, C>
23734where
23735 C: common::Connector,
23736{
23737 /// Perform the operation you have build so far.
23738 pub async fn doit(mut self) -> common::Result<(common::Response, TeamDrive)> {
23739 use std::borrow::Cow;
23740 use std::io::{Read, Seek};
23741
23742 use common::{url::Params, ToParts};
23743 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23744
23745 let mut dd = common::DefaultDelegate;
23746 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23747 dlg.begin(common::MethodInfo {
23748 id: "drive.teamdrives.get",
23749 http_method: hyper::Method::GET,
23750 });
23751
23752 for &field in ["alt", "teamDriveId", "useDomainAdminAccess"].iter() {
23753 if self._additional_params.contains_key(field) {
23754 dlg.finished(false);
23755 return Err(common::Error::FieldClash(field));
23756 }
23757 }
23758
23759 let mut params = Params::with_capacity(4 + self._additional_params.len());
23760 params.push("teamDriveId", self._team_drive_id);
23761 if let Some(value) = self._use_domain_admin_access.as_ref() {
23762 params.push("useDomainAdminAccess", value.to_string());
23763 }
23764
23765 params.extend(self._additional_params.iter());
23766
23767 params.push("alt", "json");
23768 let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}";
23769 if self._scopes.is_empty() {
23770 self._scopes.insert(Scope::Readonly.as_ref().to_string());
23771 }
23772
23773 #[allow(clippy::single_element_loop)]
23774 for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() {
23775 url = params.uri_replacement(url, param_name, find_this, false);
23776 }
23777 {
23778 let to_remove = ["teamDriveId"];
23779 params.remove_params(&to_remove);
23780 }
23781
23782 let url = params.parse_with_url(&url);
23783
23784 loop {
23785 let token = match self
23786 .hub
23787 .auth
23788 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23789 .await
23790 {
23791 Ok(token) => token,
23792 Err(e) => match dlg.token(e) {
23793 Ok(token) => token,
23794 Err(e) => {
23795 dlg.finished(false);
23796 return Err(common::Error::MissingToken(e));
23797 }
23798 },
23799 };
23800 let mut req_result = {
23801 let client = &self.hub.client;
23802 dlg.pre_request();
23803 let mut req_builder = hyper::Request::builder()
23804 .method(hyper::Method::GET)
23805 .uri(url.as_str())
23806 .header(USER_AGENT, self.hub._user_agent.clone());
23807
23808 if let Some(token) = token.as_ref() {
23809 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23810 }
23811
23812 let request = req_builder
23813 .header(CONTENT_LENGTH, 0_u64)
23814 .body(common::to_body::<String>(None));
23815
23816 client.request(request.unwrap()).await
23817 };
23818
23819 match req_result {
23820 Err(err) => {
23821 if let common::Retry::After(d) = dlg.http_error(&err) {
23822 sleep(d).await;
23823 continue;
23824 }
23825 dlg.finished(false);
23826 return Err(common::Error::HttpError(err));
23827 }
23828 Ok(res) => {
23829 let (mut parts, body) = res.into_parts();
23830 let mut body = common::Body::new(body);
23831 if !parts.status.is_success() {
23832 let bytes = common::to_bytes(body).await.unwrap_or_default();
23833 let error = serde_json::from_str(&common::to_string(&bytes));
23834 let response = common::to_response(parts, bytes.into());
23835
23836 if let common::Retry::After(d) =
23837 dlg.http_failure(&response, error.as_ref().ok())
23838 {
23839 sleep(d).await;
23840 continue;
23841 }
23842
23843 dlg.finished(false);
23844
23845 return Err(match error {
23846 Ok(value) => common::Error::BadRequest(value),
23847 _ => common::Error::Failure(response),
23848 });
23849 }
23850 let response = {
23851 let bytes = common::to_bytes(body).await.unwrap_or_default();
23852 let encoded = common::to_string(&bytes);
23853 match serde_json::from_str(&encoded) {
23854 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23855 Err(error) => {
23856 dlg.response_json_decode_error(&encoded, &error);
23857 return Err(common::Error::JsonDecodeError(
23858 encoded.to_string(),
23859 error,
23860 ));
23861 }
23862 }
23863 };
23864
23865 dlg.finished(true);
23866 return Ok(response);
23867 }
23868 }
23869 }
23870 }
23871
23872 /// The ID of the Team Drive
23873 ///
23874 /// Sets the *team drive id* path property to the given value.
23875 ///
23876 /// Even though the property as already been set when instantiating this call,
23877 /// we provide this method for API completeness.
23878 pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveGetCall<'a, C> {
23879 self._team_drive_id = new_value.to_string();
23880 self
23881 }
23882 /// 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.
23883 ///
23884 /// Sets the *use domain admin access* query property to the given value.
23885 pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveGetCall<'a, C> {
23886 self._use_domain_admin_access = Some(new_value);
23887 self
23888 }
23889 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23890 /// while executing the actual API request.
23891 ///
23892 /// ````text
23893 /// It should be used to handle progress information, and to implement a certain level of resilience.
23894 /// ````
23895 ///
23896 /// Sets the *delegate* property to the given value.
23897 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TeamdriveGetCall<'a, C> {
23898 self._delegate = Some(new_value);
23899 self
23900 }
23901
23902 /// Set any additional parameter of the query string used in the request.
23903 /// It should be used to set parameters which are not yet available through their own
23904 /// setters.
23905 ///
23906 /// Please note that this method must not be used to set any of the known parameters
23907 /// which have their own setter method. If done anyway, the request will fail.
23908 ///
23909 /// # Additional Parameters
23910 ///
23911 /// * *$.xgafv* (query-string) - V1 error format.
23912 /// * *access_token* (query-string) - OAuth access token.
23913 /// * *alt* (query-string) - Data format for response.
23914 /// * *callback* (query-string) - JSONP
23915 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23916 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23917 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23918 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23919 /// * *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.
23920 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23921 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23922 pub fn param<T>(mut self, name: T, value: T) -> TeamdriveGetCall<'a, C>
23923 where
23924 T: AsRef<str>,
23925 {
23926 self._additional_params
23927 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23928 self
23929 }
23930
23931 /// Identifies the authorization scope for the method you are building.
23932 ///
23933 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23934 /// [`Scope::Readonly`].
23935 ///
23936 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23937 /// tokens for more than one scope.
23938 ///
23939 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23940 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23941 /// sufficient, a read-write scope will do as well.
23942 pub fn add_scope<St>(mut self, scope: St) -> TeamdriveGetCall<'a, C>
23943 where
23944 St: AsRef<str>,
23945 {
23946 self._scopes.insert(String::from(scope.as_ref()));
23947 self
23948 }
23949 /// Identifies the authorization scope(s) for the method you are building.
23950 ///
23951 /// See [`Self::add_scope()`] for details.
23952 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamdriveGetCall<'a, C>
23953 where
23954 I: IntoIterator<Item = St>,
23955 St: AsRef<str>,
23956 {
23957 self._scopes
23958 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23959 self
23960 }
23961
23962 /// Removes all scopes, and no default scope will be used either.
23963 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23964 /// for details).
23965 pub fn clear_scopes(mut self) -> TeamdriveGetCall<'a, C> {
23966 self._scopes.clear();
23967 self
23968 }
23969}
23970
23971/// Deprecated: Use `drives.list` instead.
23972///
23973/// A builder for the *list* method supported by a *teamdrive* resource.
23974/// It is not used directly, but through a [`TeamdriveMethods`] instance.
23975///
23976/// # Example
23977///
23978/// Instantiate a resource method builder
23979///
23980/// ```test_harness,no_run
23981/// # extern crate hyper;
23982/// # extern crate hyper_rustls;
23983/// # extern crate google_drive3 as drive3;
23984/// # async fn dox() {
23985/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23986///
23987/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23988/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23989/// # .with_native_roots()
23990/// # .unwrap()
23991/// # .https_only()
23992/// # .enable_http2()
23993/// # .build();
23994///
23995/// # let executor = hyper_util::rt::TokioExecutor::new();
23996/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23997/// # secret,
23998/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23999/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24000/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24001/// # ),
24002/// # ).build().await.unwrap();
24003///
24004/// # let client = hyper_util::client::legacy::Client::builder(
24005/// # hyper_util::rt::TokioExecutor::new()
24006/// # )
24007/// # .build(
24008/// # hyper_rustls::HttpsConnectorBuilder::new()
24009/// # .with_native_roots()
24010/// # .unwrap()
24011/// # .https_or_http()
24012/// # .enable_http2()
24013/// # .build()
24014/// # );
24015/// # let mut hub = DriveHub::new(client, auth);
24016/// // You can configure optional parameters by calling the respective setters at will, and
24017/// // execute the final call using `doit()`.
24018/// // Values shown here are possibly random and not representative !
24019/// let result = hub.teamdrives().list()
24020/// .use_domain_admin_access(false)
24021/// .q("ipsum")
24022/// .page_token("ea")
24023/// .page_size(-27)
24024/// .doit().await;
24025/// # }
24026/// ```
24027pub struct TeamdriveListCall<'a, C>
24028where
24029 C: 'a,
24030{
24031 hub: &'a DriveHub<C>,
24032 _use_domain_admin_access: Option<bool>,
24033 _q: Option<String>,
24034 _page_token: Option<String>,
24035 _page_size: Option<i32>,
24036 _delegate: Option<&'a mut dyn common::Delegate>,
24037 _additional_params: HashMap<String, String>,
24038 _scopes: BTreeSet<String>,
24039}
24040
24041impl<'a, C> common::CallBuilder for TeamdriveListCall<'a, C> {}
24042
24043impl<'a, C> TeamdriveListCall<'a, C>
24044where
24045 C: common::Connector,
24046{
24047 /// Perform the operation you have build so far.
24048 pub async fn doit(mut self) -> common::Result<(common::Response, TeamDriveList)> {
24049 use std::borrow::Cow;
24050 use std::io::{Read, Seek};
24051
24052 use common::{url::Params, ToParts};
24053 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24054
24055 let mut dd = common::DefaultDelegate;
24056 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24057 dlg.begin(common::MethodInfo {
24058 id: "drive.teamdrives.list",
24059 http_method: hyper::Method::GET,
24060 });
24061
24062 for &field in ["alt", "useDomainAdminAccess", "q", "pageToken", "pageSize"].iter() {
24063 if self._additional_params.contains_key(field) {
24064 dlg.finished(false);
24065 return Err(common::Error::FieldClash(field));
24066 }
24067 }
24068
24069 let mut params = Params::with_capacity(6 + self._additional_params.len());
24070 if let Some(value) = self._use_domain_admin_access.as_ref() {
24071 params.push("useDomainAdminAccess", value.to_string());
24072 }
24073 if let Some(value) = self._q.as_ref() {
24074 params.push("q", value);
24075 }
24076 if let Some(value) = self._page_token.as_ref() {
24077 params.push("pageToken", value);
24078 }
24079 if let Some(value) = self._page_size.as_ref() {
24080 params.push("pageSize", value.to_string());
24081 }
24082
24083 params.extend(self._additional_params.iter());
24084
24085 params.push("alt", "json");
24086 let mut url = self.hub._base_url.clone() + "teamdrives";
24087 if self._scopes.is_empty() {
24088 self._scopes.insert(Scope::Readonly.as_ref().to_string());
24089 }
24090
24091 let url = params.parse_with_url(&url);
24092
24093 loop {
24094 let token = match self
24095 .hub
24096 .auth
24097 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24098 .await
24099 {
24100 Ok(token) => token,
24101 Err(e) => match dlg.token(e) {
24102 Ok(token) => token,
24103 Err(e) => {
24104 dlg.finished(false);
24105 return Err(common::Error::MissingToken(e));
24106 }
24107 },
24108 };
24109 let mut req_result = {
24110 let client = &self.hub.client;
24111 dlg.pre_request();
24112 let mut req_builder = hyper::Request::builder()
24113 .method(hyper::Method::GET)
24114 .uri(url.as_str())
24115 .header(USER_AGENT, self.hub._user_agent.clone());
24116
24117 if let Some(token) = token.as_ref() {
24118 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24119 }
24120
24121 let request = req_builder
24122 .header(CONTENT_LENGTH, 0_u64)
24123 .body(common::to_body::<String>(None));
24124
24125 client.request(request.unwrap()).await
24126 };
24127
24128 match req_result {
24129 Err(err) => {
24130 if let common::Retry::After(d) = dlg.http_error(&err) {
24131 sleep(d).await;
24132 continue;
24133 }
24134 dlg.finished(false);
24135 return Err(common::Error::HttpError(err));
24136 }
24137 Ok(res) => {
24138 let (mut parts, body) = res.into_parts();
24139 let mut body = common::Body::new(body);
24140 if !parts.status.is_success() {
24141 let bytes = common::to_bytes(body).await.unwrap_or_default();
24142 let error = serde_json::from_str(&common::to_string(&bytes));
24143 let response = common::to_response(parts, bytes.into());
24144
24145 if let common::Retry::After(d) =
24146 dlg.http_failure(&response, error.as_ref().ok())
24147 {
24148 sleep(d).await;
24149 continue;
24150 }
24151
24152 dlg.finished(false);
24153
24154 return Err(match error {
24155 Ok(value) => common::Error::BadRequest(value),
24156 _ => common::Error::Failure(response),
24157 });
24158 }
24159 let response = {
24160 let bytes = common::to_bytes(body).await.unwrap_or_default();
24161 let encoded = common::to_string(&bytes);
24162 match serde_json::from_str(&encoded) {
24163 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24164 Err(error) => {
24165 dlg.response_json_decode_error(&encoded, &error);
24166 return Err(common::Error::JsonDecodeError(
24167 encoded.to_string(),
24168 error,
24169 ));
24170 }
24171 }
24172 };
24173
24174 dlg.finished(true);
24175 return Ok(response);
24176 }
24177 }
24178 }
24179 }
24180
24181 /// 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.
24182 ///
24183 /// Sets the *use domain admin access* query property to the given value.
24184 pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveListCall<'a, C> {
24185 self._use_domain_admin_access = Some(new_value);
24186 self
24187 }
24188 /// Query string for searching Team Drives.
24189 ///
24190 /// Sets the *q* query property to the given value.
24191 pub fn q(mut self, new_value: &str) -> TeamdriveListCall<'a, C> {
24192 self._q = Some(new_value.to_string());
24193 self
24194 }
24195 /// Page token for Team Drives.
24196 ///
24197 /// Sets the *page token* query property to the given value.
24198 pub fn page_token(mut self, new_value: &str) -> TeamdriveListCall<'a, C> {
24199 self._page_token = Some(new_value.to_string());
24200 self
24201 }
24202 /// Maximum number of Team Drives to return.
24203 ///
24204 /// Sets the *page size* query property to the given value.
24205 pub fn page_size(mut self, new_value: i32) -> TeamdriveListCall<'a, C> {
24206 self._page_size = Some(new_value);
24207 self
24208 }
24209 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24210 /// while executing the actual API request.
24211 ///
24212 /// ````text
24213 /// It should be used to handle progress information, and to implement a certain level of resilience.
24214 /// ````
24215 ///
24216 /// Sets the *delegate* property to the given value.
24217 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TeamdriveListCall<'a, C> {
24218 self._delegate = Some(new_value);
24219 self
24220 }
24221
24222 /// Set any additional parameter of the query string used in the request.
24223 /// It should be used to set parameters which are not yet available through their own
24224 /// setters.
24225 ///
24226 /// Please note that this method must not be used to set any of the known parameters
24227 /// which have their own setter method. If done anyway, the request will fail.
24228 ///
24229 /// # Additional Parameters
24230 ///
24231 /// * *$.xgafv* (query-string) - V1 error format.
24232 /// * *access_token* (query-string) - OAuth access token.
24233 /// * *alt* (query-string) - Data format for response.
24234 /// * *callback* (query-string) - JSONP
24235 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24236 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
24237 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24238 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24239 /// * *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.
24240 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24241 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24242 pub fn param<T>(mut self, name: T, value: T) -> TeamdriveListCall<'a, C>
24243 where
24244 T: AsRef<str>,
24245 {
24246 self._additional_params
24247 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24248 self
24249 }
24250
24251 /// Identifies the authorization scope for the method you are building.
24252 ///
24253 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24254 /// [`Scope::Readonly`].
24255 ///
24256 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24257 /// tokens for more than one scope.
24258 ///
24259 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24260 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24261 /// sufficient, a read-write scope will do as well.
24262 pub fn add_scope<St>(mut self, scope: St) -> TeamdriveListCall<'a, C>
24263 where
24264 St: AsRef<str>,
24265 {
24266 self._scopes.insert(String::from(scope.as_ref()));
24267 self
24268 }
24269 /// Identifies the authorization scope(s) for the method you are building.
24270 ///
24271 /// See [`Self::add_scope()`] for details.
24272 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamdriveListCall<'a, C>
24273 where
24274 I: IntoIterator<Item = St>,
24275 St: AsRef<str>,
24276 {
24277 self._scopes
24278 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24279 self
24280 }
24281
24282 /// Removes all scopes, and no default scope will be used either.
24283 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24284 /// for details).
24285 pub fn clear_scopes(mut self) -> TeamdriveListCall<'a, C> {
24286 self._scopes.clear();
24287 self
24288 }
24289}
24290
24291/// Deprecated: Use `drives.update` instead.
24292///
24293/// A builder for the *update* method supported by a *teamdrive* resource.
24294/// It is not used directly, but through a [`TeamdriveMethods`] instance.
24295///
24296/// # Example
24297///
24298/// Instantiate a resource method builder
24299///
24300/// ```test_harness,no_run
24301/// # extern crate hyper;
24302/// # extern crate hyper_rustls;
24303/// # extern crate google_drive3 as drive3;
24304/// use drive3::api::TeamDrive;
24305/// # async fn dox() {
24306/// # use drive3::{DriveHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24307///
24308/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24309/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24310/// # .with_native_roots()
24311/// # .unwrap()
24312/// # .https_only()
24313/// # .enable_http2()
24314/// # .build();
24315///
24316/// # let executor = hyper_util::rt::TokioExecutor::new();
24317/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24318/// # secret,
24319/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24320/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24321/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24322/// # ),
24323/// # ).build().await.unwrap();
24324///
24325/// # let client = hyper_util::client::legacy::Client::builder(
24326/// # hyper_util::rt::TokioExecutor::new()
24327/// # )
24328/// # .build(
24329/// # hyper_rustls::HttpsConnectorBuilder::new()
24330/// # .with_native_roots()
24331/// # .unwrap()
24332/// # .https_or_http()
24333/// # .enable_http2()
24334/// # .build()
24335/// # );
24336/// # let mut hub = DriveHub::new(client, auth);
24337/// // As the method needs a request, you would usually fill it with the desired information
24338/// // into the respective structure. Some of the parts shown here might not be applicable !
24339/// // Values shown here are possibly random and not representative !
24340/// let mut req = TeamDrive::default();
24341///
24342/// // You can configure optional parameters by calling the respective setters at will, and
24343/// // execute the final call using `doit()`.
24344/// // Values shown here are possibly random and not representative !
24345/// let result = hub.teamdrives().update(req, "teamDriveId")
24346/// .use_domain_admin_access(false)
24347/// .doit().await;
24348/// # }
24349/// ```
24350pub struct TeamdriveUpdateCall<'a, C>
24351where
24352 C: 'a,
24353{
24354 hub: &'a DriveHub<C>,
24355 _request: TeamDrive,
24356 _team_drive_id: String,
24357 _use_domain_admin_access: Option<bool>,
24358 _delegate: Option<&'a mut dyn common::Delegate>,
24359 _additional_params: HashMap<String, String>,
24360 _scopes: BTreeSet<String>,
24361}
24362
24363impl<'a, C> common::CallBuilder for TeamdriveUpdateCall<'a, C> {}
24364
24365impl<'a, C> TeamdriveUpdateCall<'a, C>
24366where
24367 C: common::Connector,
24368{
24369 /// Perform the operation you have build so far.
24370 pub async fn doit(mut self) -> common::Result<(common::Response, TeamDrive)> {
24371 use std::borrow::Cow;
24372 use std::io::{Read, Seek};
24373
24374 use common::{url::Params, ToParts};
24375 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24376
24377 let mut dd = common::DefaultDelegate;
24378 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24379 dlg.begin(common::MethodInfo {
24380 id: "drive.teamdrives.update",
24381 http_method: hyper::Method::PATCH,
24382 });
24383
24384 for &field in ["alt", "teamDriveId", "useDomainAdminAccess"].iter() {
24385 if self._additional_params.contains_key(field) {
24386 dlg.finished(false);
24387 return Err(common::Error::FieldClash(field));
24388 }
24389 }
24390
24391 let mut params = Params::with_capacity(5 + self._additional_params.len());
24392 params.push("teamDriveId", self._team_drive_id);
24393 if let Some(value) = self._use_domain_admin_access.as_ref() {
24394 params.push("useDomainAdminAccess", value.to_string());
24395 }
24396
24397 params.extend(self._additional_params.iter());
24398
24399 params.push("alt", "json");
24400 let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}";
24401 if self._scopes.is_empty() {
24402 self._scopes.insert(Scope::Full.as_ref().to_string());
24403 }
24404
24405 #[allow(clippy::single_element_loop)]
24406 for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() {
24407 url = params.uri_replacement(url, param_name, find_this, false);
24408 }
24409 {
24410 let to_remove = ["teamDriveId"];
24411 params.remove_params(&to_remove);
24412 }
24413
24414 let url = params.parse_with_url(&url);
24415
24416 let mut json_mime_type = mime::APPLICATION_JSON;
24417 let mut request_value_reader = {
24418 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24419 common::remove_json_null_values(&mut value);
24420 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24421 serde_json::to_writer(&mut dst, &value).unwrap();
24422 dst
24423 };
24424 let request_size = request_value_reader
24425 .seek(std::io::SeekFrom::End(0))
24426 .unwrap();
24427 request_value_reader
24428 .seek(std::io::SeekFrom::Start(0))
24429 .unwrap();
24430
24431 loop {
24432 let token = match self
24433 .hub
24434 .auth
24435 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24436 .await
24437 {
24438 Ok(token) => token,
24439 Err(e) => match dlg.token(e) {
24440 Ok(token) => token,
24441 Err(e) => {
24442 dlg.finished(false);
24443 return Err(common::Error::MissingToken(e));
24444 }
24445 },
24446 };
24447 request_value_reader
24448 .seek(std::io::SeekFrom::Start(0))
24449 .unwrap();
24450 let mut req_result = {
24451 let client = &self.hub.client;
24452 dlg.pre_request();
24453 let mut req_builder = hyper::Request::builder()
24454 .method(hyper::Method::PATCH)
24455 .uri(url.as_str())
24456 .header(USER_AGENT, self.hub._user_agent.clone());
24457
24458 if let Some(token) = token.as_ref() {
24459 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24460 }
24461
24462 let request = req_builder
24463 .header(CONTENT_TYPE, json_mime_type.to_string())
24464 .header(CONTENT_LENGTH, request_size as u64)
24465 .body(common::to_body(
24466 request_value_reader.get_ref().clone().into(),
24467 ));
24468
24469 client.request(request.unwrap()).await
24470 };
24471
24472 match req_result {
24473 Err(err) => {
24474 if let common::Retry::After(d) = dlg.http_error(&err) {
24475 sleep(d).await;
24476 continue;
24477 }
24478 dlg.finished(false);
24479 return Err(common::Error::HttpError(err));
24480 }
24481 Ok(res) => {
24482 let (mut parts, body) = res.into_parts();
24483 let mut body = common::Body::new(body);
24484 if !parts.status.is_success() {
24485 let bytes = common::to_bytes(body).await.unwrap_or_default();
24486 let error = serde_json::from_str(&common::to_string(&bytes));
24487 let response = common::to_response(parts, bytes.into());
24488
24489 if let common::Retry::After(d) =
24490 dlg.http_failure(&response, error.as_ref().ok())
24491 {
24492 sleep(d).await;
24493 continue;
24494 }
24495
24496 dlg.finished(false);
24497
24498 return Err(match error {
24499 Ok(value) => common::Error::BadRequest(value),
24500 _ => common::Error::Failure(response),
24501 });
24502 }
24503 let response = {
24504 let bytes = common::to_bytes(body).await.unwrap_or_default();
24505 let encoded = common::to_string(&bytes);
24506 match serde_json::from_str(&encoded) {
24507 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24508 Err(error) => {
24509 dlg.response_json_decode_error(&encoded, &error);
24510 return Err(common::Error::JsonDecodeError(
24511 encoded.to_string(),
24512 error,
24513 ));
24514 }
24515 }
24516 };
24517
24518 dlg.finished(true);
24519 return Ok(response);
24520 }
24521 }
24522 }
24523 }
24524
24525 ///
24526 /// Sets the *request* property to the given value.
24527 ///
24528 /// Even though the property as already been set when instantiating this call,
24529 /// we provide this method for API completeness.
24530 pub fn request(mut self, new_value: TeamDrive) -> TeamdriveUpdateCall<'a, C> {
24531 self._request = new_value;
24532 self
24533 }
24534 /// The ID of the Team Drive
24535 ///
24536 /// Sets the *team drive id* path property to the given value.
24537 ///
24538 /// Even though the property as already been set when instantiating this call,
24539 /// we provide this method for API completeness.
24540 pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveUpdateCall<'a, C> {
24541 self._team_drive_id = new_value.to_string();
24542 self
24543 }
24544 /// 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.
24545 ///
24546 /// Sets the *use domain admin access* query property to the given value.
24547 pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveUpdateCall<'a, C> {
24548 self._use_domain_admin_access = Some(new_value);
24549 self
24550 }
24551 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24552 /// while executing the actual API request.
24553 ///
24554 /// ````text
24555 /// It should be used to handle progress information, and to implement a certain level of resilience.
24556 /// ````
24557 ///
24558 /// Sets the *delegate* property to the given value.
24559 pub fn delegate(
24560 mut self,
24561 new_value: &'a mut dyn common::Delegate,
24562 ) -> TeamdriveUpdateCall<'a, C> {
24563 self._delegate = Some(new_value);
24564 self
24565 }
24566
24567 /// Set any additional parameter of the query string used in the request.
24568 /// It should be used to set parameters which are not yet available through their own
24569 /// setters.
24570 ///
24571 /// Please note that this method must not be used to set any of the known parameters
24572 /// which have their own setter method. If done anyway, the request will fail.
24573 ///
24574 /// # Additional Parameters
24575 ///
24576 /// * *$.xgafv* (query-string) - V1 error format.
24577 /// * *access_token* (query-string) - OAuth access token.
24578 /// * *alt* (query-string) - Data format for response.
24579 /// * *callback* (query-string) - JSONP
24580 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24581 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
24582 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24583 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24584 /// * *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.
24585 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24586 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24587 pub fn param<T>(mut self, name: T, value: T) -> TeamdriveUpdateCall<'a, C>
24588 where
24589 T: AsRef<str>,
24590 {
24591 self._additional_params
24592 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24593 self
24594 }
24595
24596 /// Identifies the authorization scope for the method you are building.
24597 ///
24598 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24599 /// [`Scope::Full`].
24600 ///
24601 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24602 /// tokens for more than one scope.
24603 ///
24604 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24605 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24606 /// sufficient, a read-write scope will do as well.
24607 pub fn add_scope<St>(mut self, scope: St) -> TeamdriveUpdateCall<'a, C>
24608 where
24609 St: AsRef<str>,
24610 {
24611 self._scopes.insert(String::from(scope.as_ref()));
24612 self
24613 }
24614 /// Identifies the authorization scope(s) for the method you are building.
24615 ///
24616 /// See [`Self::add_scope()`] for details.
24617 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamdriveUpdateCall<'a, C>
24618 where
24619 I: IntoIterator<Item = St>,
24620 St: AsRef<str>,
24621 {
24622 self._scopes
24623 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24624 self
24625 }
24626
24627 /// Removes all scopes, and no default scope will be used either.
24628 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24629 /// for details).
24630 pub fn clear_scopes(mut self) -> TeamdriveUpdateCall<'a, C> {
24631 self._scopes.clear();
24632 self
24633 }
24634}