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 { paperformAuth } from '../common/auth';
import { paperformCommon } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
import { PaperformSpace, PaperformUpdateSpaceResponse } from '../common/types';
import { paperformCommonProps } from '../common/props';

export const updateSpace = createAction({
  auth: paperformAuth,
  name: 'updateSpace',
  displayName: 'Update Space',
  description: 'Updates an existing space.',
  audience: 'both',
  aiMetadata: { description: 'Renames an existing Paperform space, identified by its space ID, to the supplied name. Use to update a workspace label; repeating with the same input yields the same end state, so it is idempotent.', idempotent: true },
  props: {
    spaceId: paperformCommonProps.spaceId,
    name: Property.ShortText({
      displayName: 'Space Name',
      required: true,
    }),
  },
  async run({ auth, propsValue }) {
    const { spaceId, name } = propsValue;

    try {
      const response =
        await paperformCommon.apiCall<PaperformUpdateSpaceResponse>({
          method: HttpMethod.PUT,
          url: `/spaces/${spaceId}`,
          body: {
            name,
          },
          auth: auth.secret_text,
        });

      return response.results.space;
    } catch (error: any) {
      throw new Error(`Failed to update space: ${error.message}`);
    }
  },
});