forked from tanaikech/ToolsForMCPServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanagement_drive.js
More file actions
758 lines (715 loc) · 28 KB
/
management_drive.js
File metadata and controls
758 lines (715 loc) · 28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
/**
* Management of Google Drive
* Updated on 20250818 15:26
*/
/**
* This function searches files in Google Drive.
* @private
*/
function search_file_in_google_drive(object = {}) {
const { query } = object;
let result;
try {
if (query) {
const fileList = [];
let pageToken = "";
const options = { q: query, corpora: "allDrives", includeItemsFromAllDrives: true, supportsAllDrives: true, pageSize: 1000, fields: "nextPageToken,files(mimeType,id,name,createdTime,modifiedTime,webViewLink)" };
do {
const { files, nextPageToken } = Drive.Files.list(options);
fileList.push(...files);
pageToken = nextPageToken;
options.pageToken = pageToken;
} while (pageToken);
if (fileList.length > 0) {
const jsonSchema = {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string", "description": "Filename." },
"mimeType": { "type": "string", "description": "MimeType of the file." },
"id": { "type": "string", "description": "File ID of the file." },
"webViewLink": { "type": "string", "description": "File URL of the file." },
"createdTime": { "type": "string", "description": "The created time of the file." },
"modifiedTime": { "type": "string", "description": "The modified time of the file." },
},
"required": ["filename", "mimeType", "fileId", "fileUrl"]
}
};
const text = [
`${fileList.length} files were found.`,
`The file lsit of the files are put in "FileList" of a JSON array.`,
`<FileList>${JSON.stringify(fileList)}</FileList>`,
`The JSON schema of "FileList" is as follows. Understand "FileList" using this JSON schema.`,
`<JSONSchema>${JSON.stringify(jsonSchema)}</JSONSchema>`,
].join("\n");
result = { content: [{ type: "text", text }], isError: false };
} else {
result = { content: [{ type: "text", text: `No files were returned.` }], isError: false };
}
} else {
result = { content: [{ type: "text", text: `Invalid arguments.` }], isError: false };
}
} catch ({ stack }) {
result = { content: [{ type: "text", text: stack }], isError: true };
}
console.log(result); // Check response.
return { jsonrpc: "2.0", result };
}
/**
* This function gets file from Google Drive.
* @private
*/
function get_file_from_google_drive(object = {}) {
const { filename } = object;
let result;
try {
const files = DriveApp.searchFiles(`title contains '${filename}' and trashed=false`);
if (files.hasNext()) {
const file = files.next();
const filename = file.getName();
const mimeType = file.getMimeType();
const type = mimeType.split("/")[0];
result = {
content: [
{
type: "text",
text: `${filename} (${mimeType}) was downloaded.`,
},
{
type,
data: Utilities.base64Encode(file.getBlob().getBytes()),
mimeType,
},
],
isError: false,
};
/**
* Another approach.
*/
// const base64Data = Utilities.base64Encode(file.getBlob().getBytes());
// const retObj = {
// text: `${filename} (${mimeType}) was downloaded.`,
// fileContent: base64Data,
// fileMimeType: mimeType,
// filename,
// };
// const jsonSchema = {
// type: "object",
// description: "Information of the file and the file content of base64 data.",
// properties: {
// text: { type: "string", description: "Information of the file." },
// fileContent: { type: "string", description: "Base64 data converted from the file content." },
// filename: { type: "string", description: "Filename the file content." },
// fileMimeType: { type: "string", description: "MimeType of the file content." },
// }
// };
// const text = [
// `The response file information is as follows.`,
// `<ResponseData>${JSON.stringify(retObj)}</ResponseData>`,
// `JSON schema of "ResponseData" is as follows.`,
// `<jsonSchema>${JSON.stringify(jsonSchema)}</jsonSchema>`,
// ].join("\n");
// result = {
// content: [
// { type: "text", text },
// { type, data: base64Data, mimeType },
// ],
// isError: false
// };
} else {
result = { content: [{ type: "text", text: `There is no file of "${filename}".` }], isError: false };
}
} catch ({ stack }) {
result = { content: [{ type: "text", text: stack }], isError: true };
}
console.log(result); // Check response.
return { jsonrpc: "2.0", result };
}
/**
* This function puts data as a file to Google Drive.
* @private
*/
function put_file_to_google_drive(object = {}) {
const { filename, base64Data, mimeType } = object;
let result;
try {
if (filename && base64Data && mimeType) {
const blob = Utilities.newBlob(Utilities.base64Decode(base64Data), mimeType, filename);
const file = DriveApp.createFile(blob);
result = { content: [{ type: "text", text: `The data was successfully uploaded to the root folder of Google Drive as a file. The file URL is "${file.getUrl()}".` }], isError: false };
} else {
result = { content: [{ type: "text", text: `Invalid arguments.` }], isError: false };
}
} catch ({ stack }) {
result = { content: [{ type: "text", text: stack }], isError: true };
}
console.log(result); // Check response.
return { jsonrpc: "2.0", result };
}
/**
* This function creates a file to Google Drive.
* @private
*/
function create_file_to_google_drive(object = {}) {
const { filename, mimeType } = object;
let result;
/**
* Check API.
*/
const apiName = "Drive";
if (isAPIAtAdvancedGoogleServices_(apiName).api == "disable") {
result = { content: [{ type: "text", text: `${apiName} API is disabled. Please enable ${apiName} API in the Advanced Google services.` }], isError: true };
return { jsonrpc: "2.0", result };
}
try {
if (filename && mimeType) {
const { webViewLink } = Drive.Files.create({ name: filename, mimeType }, null, { fields: "webViewLink" });
result = { content: [{ type: "text", text: `A file was created on the root folder. The file URL is "${webViewLink}".` }], isError: false };
} else {
result = { content: [{ type: "text", text: `Invalid arguments.` }], isError: true };
}
} catch ({ stack }) {
result = { content: [{ type: "text", text: stack }], isError: true };
}
console.log(result); // Check response.
return { jsonrpc: "2.0", result };
}
/**
* This function renames files on Google Drive.
* @private
*/
function rename_files_on_google_drive(object = {}) {
const { fileList } = object;
let result;
try {
if (fileList && Array.isArray(fileList) && fileList.length > 0) {
const text = fileList.map(({ fileId, newName }) => {
try {
const file = DriveApp.getFileById(fileId);
const oldFilename = file.getName();
file.setName(newName);
return `FileId: "${fileId}". Renamed successfully from "${oldFilename}" to "${newName}".`;
} catch ({ message }) {
return `FileId: "${fileId}". Error: ${message}.`;
}
}).join("\n");
result = { content: [{ type: "text", text }], isError: false };
} else {
result = { content: [{ type: "text", text: `Invalid arguments.` }], isError: true };
}
} catch ({ stack }) {
result = { content: [{ type: "text", text: stack }], isError: true };
}
console.log(result); // Check response.
return { jsonrpc: "2.0", result };
}
/**
* This function moves files on Google Drive.
* @private
*/
function move_files_on_google_drive(object = {}) {
const { fileList } = object;
let result;
try {
if (fileList && Array.isArray(fileList) && fileList.length > 0) {
const text = fileList.map(({ srcId, dstId }) => {
try {
const src = DriveApp.getFileById(srcId);
const dst = DriveApp.getFileById(dstId);
if (dst.getMimeType() == MimeType.FOLDER) {
if (src.getMimeType() == MimeType.FOLDER) {
MoveFolder.run({ srcFolderId: srcId, dstFolderId: dstId });
return `Folder "${src.getName()}" was moved to the folder "${dst.getName()}".`;
}
src.moveTo(DriveApp.getFolderById(dstId));
return `File "${src.getName()}" was moved to the folder "${dst.getName()}".`;
}
return `dstId is not the folder ID of the folder.`;
} catch ({ message }) {
return `FileId: "${fileId}". Error: ${message}.`;
}
}).join("\n");
result = { content: [{ type: "text", text }], isError: false };
} else {
result = { content: [{ type: "text", text: `Invalid arguments.` }], isError: true };
}
} catch ({ stack }) {
result = { content: [{ type: "text", text: stack }], isError: true };
}
console.log(result); // Check response.
return { jsonrpc: "2.0", result };
}
/**
* This function convers the mimeType of the file on Google Drive.
* @private
*/
function convert_mimetype_of_file_on_google_drive(object = {}) {
const { fileIds = [], dstMimeType = null } = object;
let result;
try {
if (Array.isArray(fileIds) && fileIds.length > 0 && dstMimeType) {
const ar = new MimeTypeApp().setFileIds(fileIds).getAs({ mimeType: dstMimeType });
const text = ar.map((e, i) => {
if (e.toString() == "Blob") {
return `The mimeType of "${fileIds[i]}" was converted to "${dstMimeType}". The new file ID is "${DriveApp.createFile(blob).getId()}".`;
}
try {
DriveApp.getFileById(e);
return `The mimeType of "${fileIds[i]}" was converted to "${dstMimeType}". The new file ID is "${e}".`;
} catch ({ message }) {
console.log(message);
return `The mimeType of "${fileIds[i]}" was not converted to "${dstMimeType}". Message: ${e}`;
}
}).join("\n");
result = { content: [{ type: "text", text }], isError: false };
} else {
result = { content: [{ type: "text", text: `No file IDs or the destination mimeType.` }], isError: true };
}
} catch ({ stack }) {
result = { content: [{ type: "text", text: stack }], isError: true };
}
console.log(result); // Check response.
return { jsonrpc: "2.0", result };
}
/**
* This function changes the permission of a file or folder on Google Drive.
* @private
*/
function change_permission_of_file_on_google_drive(object = {}) {
const { fileId, email, role } = object;
let result;
try {
if (!fileId || !email || !role) {
throw new Error("Missing required parameters. Please provide 'fileId', 'email', and 'role'.");
}
const normalizedRole = role.toLowerCase();
if (!['viewer', 'commenter', 'editor'].includes(normalizedRole)) {
throw new Error("Invalid role specified. The role must be one of 'viewer', 'commenter', or 'editor'.");
}
let item;
let itemType;
try {
item = DriveApp.getFileById(fileId);
itemType = "file";
} catch (e) {
try {
item = DriveApp.getFolderById(fileId);
itemType = "folder";
} catch (f) {
throw new Error(`Could not find a file or folder with the ID '${fileId}'.`);
}
}
switch (normalizedRole) {
case 'editor':
item.addEditor(email);
break;
case 'commenter':
item.addCommenter(email);
break;
case 'viewer':
item.addViewer(email);
break;
}
result = { content: [{ type: "text", text: `Permission for the ${itemType} '${item.getName()}' (ID: ${fileId}) was successfully updated. User '${email}' has been granted '${normalizedRole}' access.` }], isError: false };
} catch ({ stack }) {
result = { content: [{ type: "text", text: stack }], isError: true };
}
console.log(result); // Check response.
return { jsonrpc: "2.0", result };
}
/**
* This function creates Google Docs by converting the markdown format.
* @private
*/
function create_google_docs_from_markdown_on_google_drive(object = {}) {
const { name = "sample name", markdown = "", html = "", text = "" } = object;
let result;
/**
* Check API.
*/
const apiName = "Drive";
if (isAPIAtAdvancedGoogleServices_(apiName).api == "disable") {
result = { content: [{ type: "text", text: `${apiName} API is disabled. Please enable ${apiName} API in the Advanced Google services.` }], isError: true };
return { jsonrpc: "2.0", result };
}
try {
if (markdown || html || text) {
let params = [];
if (markdown) {
params = [markdown, "text/markdown", name];
} else if (html) {
params = [html, MimeType.HTML, name];
} else {
params = [text, MimeType.PLAIN_TEXT, name];
}
const blob = Utilities.newBlob(...params);
const obj = Drive.Files.create({ mimeType: MimeType.GOOGLE_DOCS, name }, blob);
const url = `https://docs.google.com/document/d/${obj.id}/edit`;
result = { content: [{ type: "text", text: `The Google Docs file was created successfully. The file ID and URL of the created Google Docs are "${obj.id}" and "${url}", respectively.` }], isError: false };
} else {
result = { content: [{ type: "text", text: `No data. Please provide markdown, html, or text as a text data.` }], isError: true };
}
} catch ({ stack }) {
result = { content: [{ type: "text", text: stack }], isError: true };
}
console.log(result); // Check response.
return { jsonrpc: "2.0", result };
}
// REST Resource: comments: https://developers.google.com/workspace/drive/api/reference/rest/v3/comments
function comments_drive_api_list(object = {}) {
/**
* Check API
*/
const check = checkAPI_("Drive");
if (check.result) {
return check;
}
const { pathParameters, queryParameters = {} } = object;
queryParameters.fields = "*";
const { fileId } = pathParameters;
return for_google_apis.list({ func: Drive.Comments.list, args: [fileId, queryParameters], jsonSchema: jsonSchemaDrive.Comment, itemName: "comments" });
}
function comments_drive_api_remove(object = {}) {
/**
* Check API
*/
const check = checkAPI_("Drive");
if (check.result) {
return check;
}
return for_google_apis.remove({ func: Drive.Comments.remove, args: [object.pathParameters?.fileId, object.pathParameters?.commentId] });
}
// REST Resource: revisions: https://developers.google.com/workspace/drive/api/reference/rest/v3/revisions
function revisions_drive_api_list(object = {}) {
/**
* Check API
*/
const check = checkAPI_("Drive");
if (check.result) {
return check;
}
const { pathParameters, queryParameters = {}, count = 10 } = object;
queryParameters.fields = "*";
const { fileId } = pathParameters;
return for_google_apis.list({ func: Drive.Revisions.list, args: [fileId, queryParameters], jsonSchema: jsonSchemaDrive.Revision, itemName: "revisions", count });
}
// REST Resource: activity: https://developers.google.com/workspace/drive/activity/v2/reference/rest/v2/activity
function drive_activity_api_query(object = {}) {
/**
* Check API
*/
const check = checkAPI_("DriveActivity");
if (check.result) {
return check;
}
let result;
try {
const { requestBody = {}, count = 10 } = object;
const itemName = "activities";
const ar = [];
let pageToken;
do {
const obj = DriveActivity.Activity.query(requestBody);
if (obj[itemName]) {
ar.push(...obj[itemName]);
}
pageToken = obj.nextPageToken;
requestBody.pageToken = pageToken;
} while (pageToken);
const itemJsonSchema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "JSON schema for the response value.",
"type": "object",
"properties": {
[itemName]: {
"description": `${itemName} that match the list request.`,
"type": "array",
"items": jsonSchemaDrive.DriveActivity
}
},
"required": [itemName],
};
const arr = ar.splice(0, count);
const text = [
`Retrieved values are as follows.`,
`<Values>${arr.length == 0 ? "No values." : JSON.stringify({ [itemName]: arr })}</Values>`,
`JSON schema of "Values" is as follows.`,
`<JSONSchema>${JSON.stringify(itemJsonSchema)}</JSONSchema>`,
].join("\n");
result = { content: [{ type: "text", text }], isError: false };
} catch ({ stack }) {
result = { content: [{ type: "text", text: stack }], isError: true };
}
console.log(result); // Check response.
return { jsonrpc: "2.0", result };
}
// Descriptions of the functions.
const descriptions_management_drive = {
search_file_in_google_drive: {
description: "Use this to search files in Google Drive by providing a search query. For example, the filename can be converted to the file ID. But, in the case of Google Drive, the file IDs are unique values. But, the same filenames can exist in the same folder. So, when a filename is searched, multiple file IDs might be returned. At that time, it is required to confirm which file the user wants to use.",
parameters: {
type: "object",
properties: {
query: {
type: "string",
description: `Search query. In this case, the files are searched using "Method: files.list" of Drive API v3. "https://developers.google.com/workspace/drive/api/reference/rest/v3/files/list" The official document of "Search query terms and operators" is "https://developers.google.com/workspace/drive/api/guides/ref-search-terms".`
}
},
required: ["query"]
}
},
get_file_from_google_drive: {
description: "Use this to get and download a file from Google Drive by giving a filename. When you use this function, the returned data is base64 data. So, you are required to decode base64 data.",
parameters: {
type: "object",
properties: {
filename: {
type: "string",
description: "Filename of the file on Google Drive."
}
},
required: ["filename"]
}
},
put_file_to_google_drive: {
description: "Use this to put and upload data to Google Drive as a file. When you use this function, please provide the file content converted to base64 data. So, you are required to encode the file content as base64 data.",
parameters: {
type: "object",
properties: {
filename: {
type: "string",
description: "Filename of the file on Google Drive."
},
base64Data: {
type: "string",
description: "Base64 data of the file content."
},
mimeType: {
type: "string",
description: "MimeType of data of the file content."
},
},
required: ["filename", "base64Data", "mimeType"]
}
},
create_file_to_google_drive: {
description: "Use this to create an empty file to Google Drive.",
parameters: {
type: "object",
properties: {
filename: {
type: "string",
description: "Filename of the file on Google Drive."
},
mimeType: {
type: "string",
description: "MimeType of data of the file content."
},
},
required: ["filename", "mimeType"]
}
},
rename_files_on_google_drive: {
description: "Use this to rename the files on Google Drive.",
parameters: {
type: "object",
properties: {
fileList: {
type: "array",
items: {
type: "object",
properties: {
fileId: { type: "string", description: "File ID of the file on Google Drive." },
newName: { type: "string", description: "New filename by renaming the file." },
},
required: ["fileId", "newName"]
},
},
},
required: ["fileList"]
}
},
move_files_on_google_drive: {
description: "Use this to move the files and the folders into other folder on Google Drive.",
parameters: {
type: "object",
properties: {
fileList: {
type: "array",
items: {
type: "object",
properties: {
srcId: { type: "string", description: "File ID or folder ID of the source file or folder." },
dstId: { type: "string", description: "Destination folder ID." },
},
required: ["srcId", "dstId"]
},
},
},
required: ["fileList"]
}
},
convert_mimetype_of_file_on_google_drive: {
description: "Use this to convert the mimeType of files on Google Drive.",
parameters: {
type: "object",
properties: {
fileIds: { type: "array", items: { type: "string", description: "File ID of the file on Google Drive. The mimeType of this file is converted." } },
dstMimeType: { type: "string", description: "Destination mimeType." },
},
required: ["fileIds", "dstMimeType"]
}
},
change_permission_of_file_on_google_drive: {
description: "Use to change the permission of a file or folder on Google Drive for a specific user by providing the item ID, user email, and desired role. As a sample situation, when URLs of the files are included in an email, it is required to add the permission to the recipient user to allow the user to read or write the file.",
parameters: {
type: "object",
properties: {
fileId: {
description: "The ID of the file or folder on Google Drive whose permissions need to be changed.",
type: "string"
},
email: {
description: "The email address of the user to whom the permission will be granted.",
type: "string"
},
role: {
description: "The permission level to grant. Accepted values are 'viewer', 'commenter', or 'editor'.",
type: "string"
},
},
required: ["fileId", "email", "role"]
}
},
create_google_docs_from_markdown_on_google_drive: {
description: "Use to create a Google Document from a markdown format.",
parameters: {
type: "object",
properties: {
name: { description: "Google Document name.", type: "string" },
markdown: { description: "Text as a markdown format.", type: "string" },
html: { description: "Text as a markdown format.", type: "string" },
text: { description: "Text as a markdown format.", type: "string" },
}
}
},
comments_drive_api_list: {
title: "Lists a file's comments",
description: "Use to get a list of a file's comments on Google Drive.",
parameters: {
type: "object",
properties: {
pathParameters: {
type: "object",
properties: {
fileId: { type: "string", description: "The ID of the file on Google Drive." },
},
required: ["fileId"]
},
queryParameters: {
type: "object",
properties: {
includeDeleted: {
type: "boolean",
description: "Whether to include deleted comments. Deleted comments will not include their original content."
},
startModifiedTime: {
type: "string",
description: "The minimum value of 'modifiedTime' for the result comments (RFC 3339 date-time)."
},
}
}
},
required: ["pathParameters"]
}
},
comments_drive_api_remove: {
title: "Deletes a comment",
description: `Use to delete a comment using the "comments.delete" method of Google Drive API.`,
parameters: {
type: "object",
properties: {
pathParameters: {
type: "object",
properties: {
fileId: { type: "string", description: "The ID of the file on Google Drive." },
commentId: { type: "string", description: "The ID of the comment." },
},
required: ["fileId", "commentId"]
}
},
required: ["pathParameters"]
}
},
revisions_drive_api_list: {
title: "Lists a file's revisions",
description: "Use to get a list of a file's revisions on Google Drive.",
parameters: {
type: "object",
properties: {
pathParameters: {
type: "object",
properties: {
fileId: { type: "string", description: "The ID of the file on Google Drive. The file ID is also the same as the Document ID, Spreadsheet ID, Presentation ID, Form ID, and so on.." },
},
required: ["fileId"]
},
count: { type: "number", description: "Number of items. The default is 10." },
},
required: ["pathParameters"]
}
},
drive_activity_api_query: {
title: "Query past activity in Google Drive",
description: "Use to query past activity in Google Drive. The activities of the files and folders in Google Drive are retrieved.",
parameters: {
type: "object",
properties: {
requestBody: {
"type": "object",
"properties": {
"consolidationStrategy": {
"description": "Details on how to consolidate related actions that make up the activity. If not set, then related actions aren't consolidated.",
"type": "object",
"properties": {
"legacy": {
"description": "The individual activities are consolidated using the legacy strategy.",
"type": "object",
"properties": {}
}
}
},
"filter": {
"description": [
`The filtering for items returned from this query request. The format of the filter string is a sequence of expressions, joined by an optional "AND", where each expression is of the form "field operator value".`,
`Supported fields:`,
``,
`- time: Uses numerical operators on date values either in terms of milliseconds since Jan 1, 1970 or in RFC 3339 format. Examples:`,
` time > 1452409200000 AND time <= 1492812924310`,
` time >= "2016-01-10T01:02:03-05:00"`,
``,
`- detail.action_detail_case: Uses the "has" operator (:) and either a singular value or a list of allowed action types enclosed in parentheses, separated by a space. To exclude a result from the response, prepend a hyphen (-) to the beginning of the filter string. Examples:`,
` detail.action_detail_case:RENAME`,
` detail.action_detail_case:(CREATE RESTORE)`,
` -detail.action_detail_case:MOVE`,
].join("\n"),
"type": "string"
},
"itemName": {
"description": "Return activities for this Drive item. The format is items/ITEM_ID. ITEM_ID is the file ID. The file ID is the same with Spreadsheet ID, Document ID, Preasentation ID, Form ID and so on.",
"type": "string"
},
"ancestorName": {
"description": "Return activities for this Drive folder, plus all children and descendants. The format is items/ITEM_ID. ITEM_ID is the folder ID.",
"type": "string"
}
},
"oneOf": [{ "required": ["itemName"] }, { "required": ["ancestorName"] }]
},
count: { type: "number", description: "Number of items. The default is 10." },
},
required: ["requestBody"],
}
},
};