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.9 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import {
  httpClient,
  HttpRequest,
  HttpMethod,
} from '@activepieces/pieces-common';
import { trelloCommon } from '../../common';
import { trelloAuth } from '../../..';

export const deleteCardAttachment = createAction({
  auth: trelloAuth,
  name: 'delete_card_attachment',
  classification: 'DESTRUCTIVE',
  displayName: 'Delete Card Attachment',
  description: 'Deletes an attachment from a card.',
  audience: 'both',
  aiMetadata: { description: 'Permanently removes a specific attachment from a Trello card, identified by both card_id and attachment_id. Use to delete a file or link from a card. Requires both ids; deleting the same attachment again returns an error once it no longer exists.', idempotent: false },
  propertyGroups: [
    { key: 'attachment', display: 'section', label: 'Attachment', icon: 'paperclip', props: ['card_id', 'attachment_id'] },
  ],
  props: {
    card_id: Property.ShortText({
      description: "From an earlier step, or the code after /c/ in the card's URL.",
      displayName: 'Card ID',
      placeholder: 'aBcD1234',
      required: true,
      width: 'half',
    }),
    attachment_id: Property.ShortText({
      description: 'From Get All Card Attachments or an earlier step.',
      displayName: 'Attachment ID',
      required: true,
      width: 'half',
    }),
  },

  async run(context) {
    const request: HttpRequest = {
      method: HttpMethod.DELETE,
      url:
        `${trelloCommon.baseUrl}cards/${context.propsValue['card_id']}/attachments/${context.propsValue['attachment_id']}` +
        `?key=` +
        context.auth.username +
        `&token=` +
        context.auth.password,
      headers: {
        Accept: 'application/json',
      },
      queryParams: {},
    };
    
    const response = await httpClient.sendRequest(request);

    return response.body;
  },
});