Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.4 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { googleDriveAuth, createGoogleClient } from '../auth';
import { common } from '../common';
import { drive as googleDrive } from '@googleapis/drive';

export const googleDriveDeleteFile = createAction({
  auth: googleDriveAuth,
  name: 'delete_gdrive_file',
  classification: 'DESTRUCTIVE',
  description: 'Permanently delete a file, skipping the bin.',
  audience: 'human',
  aiMetadata: { description: 'Permanently deletes a file from Google Drive by its ID, bypassing the trash and making it unrecoverable. Use only when permanent removal is intended; prefer Trash file for reversible deletion. Requires the file ID. Not idempotent: a repeat call fails because the file no longer exists.', idempotent: false },
  displayName: 'Delete File',
  props: {
    fileId: Property.ShortText({
      displayName: 'File ID',
      description: 'The ID of the file to delete. This cannot be undone.',
      required: true,
      placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
    }),
    include_team_drives: common.properties.include_team_drives,
  },
  async run(context) {
    const authClient = await createGoogleClient(context.auth);

    const drive = googleDrive({ version: 'v3', auth: authClient });

    const response = await drive.files.delete({
      fileId: context.propsValue.fileId,
      supportsAllDrives: context.propsValue.include_team_drives,
    });

    return response.data;
  },
});