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.3 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { googleDriveAuth, createGoogleClient } from '../auth';
import { drive as googleDrive } from '@googleapis/drive';

export const driveDeleteFile = createAction({
  auth: googleDriveAuth,
  name: 'drive_delete_file',
  classification: 'DESTRUCTIVE',
  displayName: 'Delete File Permanently',
  description: 'Permanently delete a Drive file by ID, bypassing the trash.',
  audience: 'ai',
  aiMetadata: {
    description:
      'Permanently deletes a file by ID, bypassing the trash — unrecoverable. Use only when permanent removal is intended; for reversible deletion prefer drive_trash_file. A repeat call fails because the file no longer exists.',
    idempotent: false,
  },
  props: {
    file_id: Property.ShortText({
      displayName: 'File ID',
      description:
        'The ID of the file to permanently delete. Resolve it via drive_search_files or drive_get_file.',
      required: true,
    }),
  },
  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.file_id,
      supportsAllDrives: true,
    });

    return response.data;
  },
});