|
1 | 1 | import { googleDriveAuth } from '../../index';
|
2 |
| -import { Property, createAction } from "@activepieces/pieces-framework"; |
| 2 | +import { Property, createAction } from '@activepieces/pieces-framework'; |
3 | 3 | import { google } from 'googleapis';
|
4 | 4 | import { OAuth2Client } from 'googleapis-common';
|
5 | 5 | import { common } from '../common';
|
6 | 6 |
|
7 | 7 | export const googleDriveGetResourceById = createAction({
|
8 |
| - auth: googleDriveAuth, |
9 |
| - name: 'get-file-or-folder-by-id', |
10 |
| - displayName: 'Get File', |
11 |
| - description: 'Get a file folder for files/sub-folders', |
12 |
| - props: { |
13 |
| - id: Property.ShortText({ |
14 |
| - displayName: 'File / Folder Id', |
15 |
| - description: 'The Id of the file/folder to search for.', |
16 |
| - required: true, |
17 |
| - }) |
18 |
| - }, |
19 |
| - async run(context) { |
20 |
| - const authClient = new OAuth2Client(); |
21 |
| - authClient.setCredentials(context.auth) |
22 |
| - const drive = google.drive({ version: 'v3', auth: authClient }); |
23 |
| - const response = await drive.files.get({ fileId: context.propsValue.id }); |
| 8 | + auth: googleDriveAuth, |
| 9 | + name: 'get-file-or-folder-by-id', |
| 10 | + displayName: 'Get File', |
| 11 | + description: 'Get a file folder for files/sub-folders', |
| 12 | + props: { |
| 13 | + id: Property.ShortText({ |
| 14 | + displayName: 'File / Folder Id', |
| 15 | + description: 'The Id of the file/folder to search for.', |
| 16 | + required: true, |
| 17 | + }), |
| 18 | + include_team_drives: common.properties.include_team_drives, |
| 19 | + }, |
| 20 | + async run(context) { |
| 21 | + const authClient = new OAuth2Client(); |
| 22 | + authClient.setCredentials(context.auth); |
| 23 | + const drive = google.drive({ version: 'v3', auth: authClient }); |
| 24 | + const response = await drive.files.get({ |
| 25 | + fileId: context.propsValue.id, |
| 26 | + supportsAllDrives: context.propsValue.include_team_drives, |
| 27 | + }); |
24 | 28 |
|
25 |
| - if (response.data) { |
26 |
| - return response.data; |
27 |
| - } else { |
28 |
| - console.log('The specified ID corresponds to a folder. Returning null.'); |
29 |
| - return null; |
30 |
| - } |
31 |
| - |
| 29 | + if (response.data) { |
| 30 | + return response.data; |
| 31 | + } else { |
| 32 | + console.log('The specified ID corresponds to a folder. Returning null.'); |
| 33 | + return null; |
32 | 34 | }
|
| 35 | + }, |
33 | 36 | });
|
0 commit comments