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.6 KB
Raw Blame
import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { ampecoAuth } from '../../../common/auth';
import { handleApiError, makeAmpecoApiCall, prepareQueryParams, prepareRequestBody, processPathParameters } from '../../../common/utils';
import { CreateUtilityResponse } from '../../../models/responses';

/**
 * Generated from API version: 3.96.4
 */

// Endpoint: POST /public-api/resources/utilities/v1.0

export const createUtilityAction = createAction({
  auth: ampecoAuth,
  name: 'createUtility',
  displayName: 'Resources - Utilities - Create Utility',
  description: 'Create Utility.',
  audience: 'both',
  aiMetadata: { description: 'Create a new AMPECO utility (electricity provider) record with a name. Not idempotent: each call adds another utility, so re-running creates duplicates. Use the update utility action to rename an existing one.', idempotent: false },
  props: {
        
  name: Property.ShortText({
    displayName: 'Name',
    description: '',
    required: true,
  }),
  },
  async run(context): Promise<CreateUtilityResponse> {
    try {
      const url = processPathParameters('/public-api/resources/utilities/v1.0', context.propsValue);
      
      const queryParams = prepareQueryParams(context.propsValue, []);
      
      const body = prepareRequestBody(context.propsValue,
        ['name']
      );

      
      return await makeAmpecoApiCall(
        context.auth,
        url,
        HttpMethod.POST,
        body,
        queryParams
      ) as CreateUtilityResponse;

    } catch (error) {
      handleApiError(error);
    }
  },
});