google_drive/files.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct Files {
5 pub client: Client,
6}
7
8impl Files {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 Files { client }
12 }
13
14 /**
15 * This function performs a `GET` to the `/files` endpoint.
16 *
17 * Lists or searches files.
18 *
19 * **Parameters:**
20 *
21 * * `corpora: &str` -- Groupings of files to which the query applies. Supported groupings are: 'user' (files created by, opened by, or shared directly with the user), 'drive' (files in the specified shared drive as indicated by the 'driveId'), 'domain' (files shared to the user's domain), and 'allDrives' (A combination of 'user' and 'drive' for all drives where the user is a member). When able, use 'user' or 'drive', instead of 'allDrives', for efficiency.
22 * * `corpus: crate::types::Corpus` -- The source of files to list. Deprecated: use 'corpora' instead.
23 * * `drive_id: &str` -- A link to this theme's background image.
24 * * `include_items_from_all_drives: bool` -- Whether both My Drive and shared drive items should be included in results.
25 * * `include_permissions_for_view: &str` -- Specifies which additional view's permissions to include in the response. Only 'published' is supported.
26 * * `include_team_drive_items: bool` -- Whether the user has installed the requesting app.
27 * * `order_by: &str` -- A comma-separated list of sort keys. Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each key sorts ascending by default, but may be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored.
28 * * `page_size: i64` -- 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.
29 * * `page_token: &str` -- 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.
30 * * `q: &str` -- A query for filtering the file results. See the "Search for Files" guide for supported syntax.
31 * * `spaces: &str` -- A comma-separated list of spaces to query within the corpus. Supported values are 'drive' and 'appDataFolder'.
32 * * `supports_all_drives: bool` -- Whether the requesting application supports both My Drives and shared drives.
33 * * `supports_team_drives: bool` -- Whether the user has installed the requesting app.
34 * * `team_drive_id: &str` -- A link to this theme's background image.
35 */
36 pub async fn list(
37 &self,
38 corpora: &str,
39 drive_id: &str,
40 include_items_from_all_drives: bool,
41 include_permissions_for_view: &str,
42 include_team_drive_items: bool,
43 order_by: &str,
44 page_size: i64,
45 page_token: &str,
46 q: &str,
47 spaces: &str,
48 supports_all_drives: bool,
49 supports_team_drives: bool,
50 team_drive_id: &str,
51 ) -> ClientResult<crate::Response<Vec<crate::types::File>>> {
52 let mut query_args: Vec<(String, String)> = Default::default();
53 if !corpora.is_empty() {
54 query_args.push(("corpora".to_string(), corpora.to_string()));
55 }
56 if !drive_id.is_empty() {
57 query_args.push(("driveId".to_string(), drive_id.to_string()));
58 }
59 if include_items_from_all_drives {
60 query_args.push((
61 "includeItemsFromAllDrives".to_string(),
62 include_items_from_all_drives.to_string(),
63 ));
64 }
65 if !include_permissions_for_view.is_empty() {
66 query_args.push((
67 "includePermissionsForView".to_string(),
68 include_permissions_for_view.to_string(),
69 ));
70 }
71 if include_team_drive_items {
72 query_args.push((
73 "includeTeamDriveItems".to_string(),
74 include_team_drive_items.to_string(),
75 ));
76 }
77 if !order_by.is_empty() {
78 query_args.push(("orderBy".to_string(), order_by.to_string()));
79 }
80 if page_size > 0 {
81 query_args.push(("pageSize".to_string(), page_size.to_string()));
82 }
83 if !page_token.is_empty() {
84 query_args.push(("pageToken".to_string(), page_token.to_string()));
85 }
86 if !q.is_empty() {
87 query_args.push(("q".to_string(), q.to_string()));
88 }
89 if !spaces.is_empty() {
90 query_args.push(("spaces".to_string(), spaces.to_string()));
91 }
92 if supports_all_drives {
93 query_args.push((
94 "supportsAllDrives".to_string(),
95 supports_all_drives.to_string(),
96 ));
97 }
98 if supports_team_drives {
99 query_args.push((
100 "supportsTeamDrives".to_string(),
101 supports_team_drives.to_string(),
102 ));
103 }
104 if !team_drive_id.is_empty() {
105 query_args.push(("teamDriveId".to_string(), team_drive_id.to_string()));
106 }
107 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
108 let url = self.client.url(&format!("/files?{}", query_), None);
109 let resp: crate::Response<crate::types::FileList> = self
110 .client
111 .get(
112 &url,
113 crate::Message {
114 body: None,
115 content_type: None,
116 },
117 )
118 .await?;
119
120 // Return our response data.
121 Ok(crate::Response::new(
122 resp.status,
123 resp.headers,
124 resp.body.files.to_vec(),
125 ))
126 }
127 /**
128 * This function performs a `GET` to the `/files` endpoint.
129 *
130 * As opposed to `list`, this function returns all the pages of the request at once.
131 *
132 * Lists or searches files.
133 */
134 pub async fn list_all(
135 &self,
136 corpora: &str,
137 drive_id: &str,
138 include_items_from_all_drives: bool,
139 include_permissions_for_view: &str,
140 include_team_drive_items: bool,
141 order_by: &str,
142 q: &str,
143 spaces: &str,
144 supports_all_drives: bool,
145 supports_team_drives: bool,
146 team_drive_id: &str,
147 ) -> ClientResult<crate::Response<Vec<crate::types::File>>> {
148 let mut query_args: Vec<(String, String)> = Default::default();
149 if !corpora.is_empty() {
150 query_args.push(("corpora".to_string(), corpora.to_string()));
151 }
152 if !drive_id.is_empty() {
153 query_args.push(("driveId".to_string(), drive_id.to_string()));
154 }
155 if include_items_from_all_drives {
156 query_args.push((
157 "includeItemsFromAllDrives".to_string(),
158 include_items_from_all_drives.to_string(),
159 ));
160 }
161 if !include_permissions_for_view.is_empty() {
162 query_args.push((
163 "includePermissionsForView".to_string(),
164 include_permissions_for_view.to_string(),
165 ));
166 }
167 if include_team_drive_items {
168 query_args.push((
169 "includeTeamDriveItems".to_string(),
170 include_team_drive_items.to_string(),
171 ));
172 }
173 if !order_by.is_empty() {
174 query_args.push(("orderBy".to_string(), order_by.to_string()));
175 }
176 if !q.is_empty() {
177 query_args.push(("q".to_string(), q.to_string()));
178 }
179 if !spaces.is_empty() {
180 query_args.push(("spaces".to_string(), spaces.to_string()));
181 }
182 if supports_all_drives {
183 query_args.push((
184 "supportsAllDrives".to_string(),
185 supports_all_drives.to_string(),
186 ));
187 }
188 if supports_team_drives {
189 query_args.push((
190 "supportsTeamDrives".to_string(),
191 supports_team_drives.to_string(),
192 ));
193 }
194 if !team_drive_id.is_empty() {
195 query_args.push(("teamDriveId".to_string(), team_drive_id.to_string()));
196 }
197 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
198 let url = self.client.url(&format!("/files?{}", query_), None);
199 let crate::Response::<crate::types::FileList> {
200 mut status,
201 mut headers,
202 mut body,
203 } = self
204 .client
205 .get(
206 &url,
207 crate::Message {
208 body: None,
209 content_type: None,
210 },
211 )
212 .await?;
213
214 let mut files = body.files;
215 let mut page = body.next_page_token;
216
217 // Paginate if we should.
218 while !page.is_empty() {
219 if !url.contains('?') {
220 crate::Response::<crate::types::FileList> {
221 status,
222 headers,
223 body,
224 } = self
225 .client
226 .get(
227 &format!("{}?pageToken={}", url, page),
228 crate::Message {
229 body: None,
230 content_type: None,
231 },
232 )
233 .await?;
234 } else {
235 crate::Response::<crate::types::FileList> {
236 status,
237 headers,
238 body,
239 } = self
240 .client
241 .get(
242 &format!("{}&pageToken={}", url, page),
243 crate::Message {
244 body: None,
245 content_type: None,
246 },
247 )
248 .await?;
249 }
250
251 files.append(&mut body.files);
252
253 if !body.next_page_token.is_empty() && body.next_page_token != page {
254 page = body.next_page_token.to_string();
255 } else {
256 page = "".to_string();
257 }
258 }
259
260 // Return our response data.
261 Ok(crate::Response::new(status, headers, files))
262 }
263 /**
264 * This function performs a `POST` to the `/files` endpoint.
265 *
266 * Creates a new file.
267 *
268 * **Parameters:**
269 *
270 * * `enforce_single_parent: bool` -- Deprecated. Creating files in multiple folders is no longer supported.
271 * * `ignore_default_visibility: bool` -- 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.
272 * * `include_permissions_for_view: &str` -- Specifies which additional view's permissions to include in the response. Only 'published' is supported.
273 * * `keep_revision_forever: bool` -- 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.
274 * * `ocr_language: &str` -- A language hint for OCR processing during image import (ISO 639-1 code).
275 * * `supports_all_drives: bool` -- Whether the requesting application supports both My Drives and shared drives.
276 * * `supports_team_drives: bool` -- Whether the user has installed the requesting app.
277 * * `use_content_as_indexable_text: bool` -- Whether to use the uploaded content as indexable text.
278 */
279 pub async fn create(
280 &self,
281 ignore_default_visibility: bool,
282 include_permissions_for_view: &str,
283 keep_revision_forever: bool,
284 ocr_language: &str,
285 supports_all_drives: bool,
286 supports_team_drives: bool,
287 use_content_as_indexable_text: bool,
288 body: &crate::types::File,
289 ) -> ClientResult<crate::Response<crate::types::File>> {
290 let mut query_args: Vec<(String, String)> = Default::default();
291 if ignore_default_visibility {
292 query_args.push((
293 "ignoreDefaultVisibility".to_string(),
294 ignore_default_visibility.to_string(),
295 ));
296 }
297 if !include_permissions_for_view.is_empty() {
298 query_args.push((
299 "includePermissionsForView".to_string(),
300 include_permissions_for_view.to_string(),
301 ));
302 }
303 if keep_revision_forever {
304 query_args.push((
305 "keepRevisionForever".to_string(),
306 keep_revision_forever.to_string(),
307 ));
308 }
309 if !ocr_language.is_empty() {
310 query_args.push(("ocrLanguage".to_string(), ocr_language.to_string()));
311 }
312 if supports_all_drives {
313 query_args.push((
314 "supportsAllDrives".to_string(),
315 supports_all_drives.to_string(),
316 ));
317 }
318 if supports_team_drives {
319 query_args.push((
320 "supportsTeamDrives".to_string(),
321 supports_team_drives.to_string(),
322 ));
323 }
324 if use_content_as_indexable_text {
325 query_args.push((
326 "useContentAsIndexableText".to_string(),
327 use_content_as_indexable_text.to_string(),
328 ));
329 }
330 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
331 let url = self.client.url(&format!("/files?{}", query_), None);
332 self.client
333 .post(
334 &url,
335 crate::Message {
336 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
337 content_type: Some("application/octet-stream".to_string()),
338 },
339 )
340 .await
341 }
342 /**
343 * This function performs a `GET` to the `/files/generateIds` endpoint.
344 *
345 * Generates a set of file IDs which can be provided in create or copy requests.
346 *
347 * **Parameters:**
348 *
349 * * `count: i64` -- A map of maximum import sizes by MIME type, in bytes.
350 * * `space: &str` -- The space in which the IDs can be used to create new files. Supported values are 'drive' and 'appDataFolder'. (Default: 'drive').
351 * * `type_: &str` -- 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').
352 */
353 pub async fn generate_id(
354 &self,
355 count: i64,
356 space: &str,
357 type_: &str,
358 ) -> ClientResult<crate::Response<crate::types::GeneratedIds>> {
359 let mut query_args: Vec<(String, String)> = Default::default();
360 if count > 0 {
361 query_args.push(("count".to_string(), count.to_string()));
362 }
363 if !space.is_empty() {
364 query_args.push(("space".to_string(), space.to_string()));
365 }
366 if !type_.is_empty() {
367 query_args.push(("type".to_string(), type_.to_string()));
368 }
369 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
370 let url = self
371 .client
372 .url(&format!("/files/generateIds?{}", query_), None);
373 self.client
374 .get(
375 &url,
376 crate::Message {
377 body: None,
378 content_type: None,
379 },
380 )
381 .await
382 }
383 /**
384 * This function performs a `DELETE` to the `/files/trash` endpoint.
385 *
386 * Permanently deletes all of the user's trashed files.
387 *
388 * **Parameters:**
389 *
390 * * `enforce_single_parent: bool` -- Deprecated. If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item will be placed under its owner's root.
391 */
392 pub async fn empty_trash(&self) -> ClientResult<crate::Response<()>> {
393 let url = self.client.url("/files/trash", None);
394 self.client
395 .delete(
396 &url,
397 crate::Message {
398 body: None,
399 content_type: None,
400 },
401 )
402 .await
403 }
404 /**
405 * This function performs a `GET` to the `/files/{fileId}` endpoint.
406 *
407 * Gets a file's metadata or content by ID.
408 *
409 * **Parameters:**
410 *
411 * * `file_id: &str` -- A link to this theme's background image.
412 * * `acknowledge_abuse: bool` -- Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.
413 * * `include_permissions_for_view: &str` -- Specifies which additional view's permissions to include in the response. Only 'published' is supported.
414 * * `supports_all_drives: bool` -- Whether the requesting application supports both My Drives and shared drives.
415 * * `supports_team_drives: bool` -- Whether the user has installed the requesting app.
416 */
417 pub async fn get(
418 &self,
419 file_id: &str,
420 acknowledge_abuse: bool,
421 include_permissions_for_view: &str,
422 supports_all_drives: bool,
423 supports_team_drives: bool,
424 ) -> ClientResult<crate::Response<crate::types::File>> {
425 let mut query_args: Vec<(String, String)> = Default::default();
426 if acknowledge_abuse {
427 query_args.push((
428 "acknowledgeAbuse".to_string(),
429 acknowledge_abuse.to_string(),
430 ));
431 }
432 if !include_permissions_for_view.is_empty() {
433 query_args.push((
434 "includePermissionsForView".to_string(),
435 include_permissions_for_view.to_string(),
436 ));
437 }
438 if supports_all_drives {
439 query_args.push((
440 "supportsAllDrives".to_string(),
441 supports_all_drives.to_string(),
442 ));
443 }
444 if supports_team_drives {
445 query_args.push((
446 "supportsTeamDrives".to_string(),
447 supports_team_drives.to_string(),
448 ));
449 }
450 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
451 let url = self.client.url(
452 &format!(
453 "/files/{}?{}",
454 crate::progenitor_support::encode_path(file_id),
455 query_
456 ),
457 None,
458 );
459 self.client
460 .get(
461 &url,
462 crate::Message {
463 body: None,
464 content_type: None,
465 },
466 )
467 .await
468 }
469 /**
470 * This function performs a `DELETE` to the `/files/{fileId}` endpoint.
471 *
472 * Permanently deletes a file owned by the user without moving it to the trash. If the file belongs to a shared drive the user must be an organizer on the parent. If the target is a folder, all descendants owned by the user are also deleted.
473 *
474 * **Parameters:**
475 *
476 * * `file_id: &str` -- A link to this theme's background image.
477 * * `enforce_single_parent: bool` -- Deprecated. If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item will be placed under its owner's root.
478 * * `supports_all_drives: bool` -- Whether the requesting application supports both My Drives and shared drives.
479 * * `supports_team_drives: bool` -- Whether the user has installed the requesting app.
480 */
481 pub async fn delete(
482 &self,
483 file_id: &str,
484 supports_all_drives: bool,
485 supports_team_drives: bool,
486 ) -> ClientResult<crate::Response<()>> {
487 let mut query_args: Vec<(String, String)> = Default::default();
488 if supports_all_drives {
489 query_args.push((
490 "supportsAllDrives".to_string(),
491 supports_all_drives.to_string(),
492 ));
493 }
494 if supports_team_drives {
495 query_args.push((
496 "supportsTeamDrives".to_string(),
497 supports_team_drives.to_string(),
498 ));
499 }
500 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
501 let url = self.client.url(
502 &format!(
503 "/files/{}?{}",
504 crate::progenitor_support::encode_path(file_id),
505 query_
506 ),
507 None,
508 );
509 self.client
510 .delete(
511 &url,
512 crate::Message {
513 body: None,
514 content_type: None,
515 },
516 )
517 .await
518 }
519 /**
520 * This function performs a `PATCH` to the `/files/{fileId}` endpoint.
521 *
522 * Updates a file's metadata and/or content. This method supports patch semantics.
523 *
524 * **Parameters:**
525 *
526 * * `file_id: &str` -- A link to this theme's background image.
527 * * `add_parents: &str` -- A comma-separated list of parent IDs to add.
528 * * `enforce_single_parent: bool` -- Deprecated. Adding files to multiple folders is no longer supported. Use shortcuts instead.
529 * * `include_permissions_for_view: &str` -- Specifies which additional view's permissions to include in the response. Only 'published' is supported.
530 * * `keep_revision_forever: bool` -- 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.
531 * * `ocr_language: &str` -- A language hint for OCR processing during image import (ISO 639-1 code).
532 * * `remove_parents: &str` -- A comma-separated list of parent IDs to remove.
533 * * `supports_all_drives: bool` -- Whether the requesting application supports both My Drives and shared drives.
534 * * `supports_team_drives: bool` -- Whether the user has installed the requesting app.
535 * * `use_content_as_indexable_text: bool` -- Whether to use the uploaded content as indexable text.
536 */
537 pub async fn update(
538 &self,
539 file_id: &str,
540 add_parents: &str,
541 include_permissions_for_view: &str,
542 keep_revision_forever: bool,
543 ocr_language: &str,
544 remove_parents: &str,
545 supports_all_drives: bool,
546 supports_team_drives: bool,
547 use_content_as_indexable_text: bool,
548 body: &crate::types::File,
549 ) -> ClientResult<crate::Response<crate::types::File>> {
550 let mut query_args: Vec<(String, String)> = Default::default();
551 if !add_parents.is_empty() {
552 query_args.push(("addParents".to_string(), add_parents.to_string()));
553 }
554 if !include_permissions_for_view.is_empty() {
555 query_args.push((
556 "includePermissionsForView".to_string(),
557 include_permissions_for_view.to_string(),
558 ));
559 }
560 if keep_revision_forever {
561 query_args.push((
562 "keepRevisionForever".to_string(),
563 keep_revision_forever.to_string(),
564 ));
565 }
566 if !ocr_language.is_empty() {
567 query_args.push(("ocrLanguage".to_string(), ocr_language.to_string()));
568 }
569 if !remove_parents.is_empty() {
570 query_args.push(("removeParents".to_string(), remove_parents.to_string()));
571 }
572 if supports_all_drives {
573 query_args.push((
574 "supportsAllDrives".to_string(),
575 supports_all_drives.to_string(),
576 ));
577 }
578 if supports_team_drives {
579 query_args.push((
580 "supportsTeamDrives".to_string(),
581 supports_team_drives.to_string(),
582 ));
583 }
584 if use_content_as_indexable_text {
585 query_args.push((
586 "useContentAsIndexableText".to_string(),
587 use_content_as_indexable_text.to_string(),
588 ));
589 }
590 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
591 let url = self.client.url(
592 &format!(
593 "/files/{}?{}",
594 crate::progenitor_support::encode_path(file_id),
595 query_
596 ),
597 None,
598 );
599 self.client
600 .patch(
601 &url,
602 crate::Message {
603 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
604 content_type: Some("application/octet-stream".to_string()),
605 },
606 )
607 .await
608 }
609 /**
610 * This function performs a `POST` to the `/files/{fileId}/copy` endpoint.
611 *
612 * Creates a copy of a file and applies any requested updates with patch semantics. Folders cannot be copied.
613 *
614 * **Parameters:**
615 *
616 * * `file_id: &str` -- A link to this theme's background image.
617 * * `enforce_single_parent: bool` -- Deprecated. Copying files into multiple folders is no longer supported. Use shortcuts instead.
618 * * `ignore_default_visibility: bool` -- 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.
619 * * `include_permissions_for_view: &str` -- Specifies which additional view's permissions to include in the response. Only 'published' is supported.
620 * * `keep_revision_forever: bool` -- 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.
621 * * `ocr_language: &str` -- A language hint for OCR processing during image import (ISO 639-1 code).
622 * * `supports_all_drives: bool` -- Whether the requesting application supports both My Drives and shared drives.
623 * * `supports_team_drives: bool` -- Whether the user has installed the requesting app.
624 */
625 pub async fn copy(
626 &self,
627 file_id: &str,
628 ignore_default_visibility: bool,
629 include_permissions_for_view: &str,
630 keep_revision_forever: bool,
631 ocr_language: &str,
632 supports_all_drives: bool,
633 supports_team_drives: bool,
634 body: &crate::types::File,
635 ) -> ClientResult<crate::Response<crate::types::File>> {
636 let mut query_args: Vec<(String, String)> = Default::default();
637 if ignore_default_visibility {
638 query_args.push((
639 "ignoreDefaultVisibility".to_string(),
640 ignore_default_visibility.to_string(),
641 ));
642 }
643 if !include_permissions_for_view.is_empty() {
644 query_args.push((
645 "includePermissionsForView".to_string(),
646 include_permissions_for_view.to_string(),
647 ));
648 }
649 if keep_revision_forever {
650 query_args.push((
651 "keepRevisionForever".to_string(),
652 keep_revision_forever.to_string(),
653 ));
654 }
655 if !ocr_language.is_empty() {
656 query_args.push(("ocrLanguage".to_string(), ocr_language.to_string()));
657 }
658 if supports_all_drives {
659 query_args.push((
660 "supportsAllDrives".to_string(),
661 supports_all_drives.to_string(),
662 ));
663 }
664 if supports_team_drives {
665 query_args.push((
666 "supportsTeamDrives".to_string(),
667 supports_team_drives.to_string(),
668 ));
669 }
670 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
671 let url = self.client.url(
672 &format!(
673 "/files/{}/copy?{}",
674 crate::progenitor_support::encode_path(file_id),
675 query_
676 ),
677 None,
678 );
679 self.client
680 .post(
681 &url,
682 crate::Message {
683 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
684 content_type: Some("application/json".to_string()),
685 },
686 )
687 .await
688 }
689 /**
690 * This function performs a `GET` to the `/files/{fileId}/export` endpoint.
691 *
692 * Exports a Google Doc to the requested MIME type and returns the exported content. Please note that the exported content is limited to 10MB.
693 *
694 * **Parameters:**
695 *
696 * * `file_id: &str` -- A link to this theme's background image.
697 * * `mime_type: &str` -- The MIME type of the format requested for this export.
698 */
699 pub async fn export(
700 &self,
701 file_id: &str,
702 mime_type: &str,
703 ) -> ClientResult<crate::Response<()>> {
704 let mut query_args: Vec<(String, String)> = Default::default();
705 if !mime_type.is_empty() {
706 query_args.push(("mimeType".to_string(), mime_type.to_string()));
707 }
708 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
709 let url = self.client.url(
710 &format!(
711 "/files/{}/export?{}",
712 crate::progenitor_support::encode_path(file_id),
713 query_
714 ),
715 None,
716 );
717 self.client
718 .get(
719 &url,
720 crate::Message {
721 body: None,
722 content_type: None,
723 },
724 )
725 .await
726 }
727 /**
728 * This function performs a `POST` to the `/files/{fileId}/watch` endpoint.
729 *
730 * Subscribes to changes to a file
731 *
732 * **Parameters:**
733 *
734 * * `file_id: &str` -- A link to this theme's background image.
735 * * `acknowledge_abuse: bool` -- Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.
736 * * `include_permissions_for_view: &str` -- Specifies which additional view's permissions to include in the response. Only 'published' is supported.
737 * * `supports_all_drives: bool` -- Whether the requesting application supports both My Drives and shared drives.
738 * * `supports_team_drives: bool` -- Whether the user has installed the requesting app.
739 */
740 pub async fn watch(
741 &self,
742 file_id: &str,
743 acknowledge_abuse: bool,
744 include_permissions_for_view: &str,
745 supports_all_drives: bool,
746 supports_team_drives: bool,
747 body: &crate::types::Channel,
748 ) -> ClientResult<crate::Response<crate::types::Channel>> {
749 let mut query_args: Vec<(String, String)> = Default::default();
750 if acknowledge_abuse {
751 query_args.push((
752 "acknowledgeAbuse".to_string(),
753 acknowledge_abuse.to_string(),
754 ));
755 }
756 if !include_permissions_for_view.is_empty() {
757 query_args.push((
758 "includePermissionsForView".to_string(),
759 include_permissions_for_view.to_string(),
760 ));
761 }
762 if supports_all_drives {
763 query_args.push((
764 "supportsAllDrives".to_string(),
765 supports_all_drives.to_string(),
766 ));
767 }
768 if supports_team_drives {
769 query_args.push((
770 "supportsTeamDrives".to_string(),
771 supports_team_drives.to_string(),
772 ));
773 }
774 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
775 let url = self.client.url(
776 &format!(
777 "/files/{}/watch?{}",
778 crate::progenitor_support::encode_path(file_id),
779 query_
780 ),
781 None,
782 );
783 self.client
784 .post(
785 &url,
786 crate::Message {
787 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
788 content_type: Some("application/json".to_string()),
789 },
790 )
791 .await
792 }
793}