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

2.3 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 { EvseDowntimePeriodUpdateResponse } from '../../../models/responses';

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

// Endpoint: PATCH /public-api/resources/evse-downtime-periods/v1.0/{evseDowntimePeriod}

export const evseDowntimePeriodUpdateAction = createAction({
  auth: ampecoAuth,
  name: 'evseDowntimePeriodUpdate',
  displayName: 'Resources - Evse Downtime Periods - Update',
  description: 'Update EVSE Downtime Period.',
  audience: 'both',
  aiMetadata: { description: 'Update an existing EVSE downtime period by its numeric ID, changing its notice, start, or end time. Editing start/end is only allowed for periods with type "exempt" and entryMode "manual". Idempotent: re-applying the same values yields the same end state.', idempotent: true },
  props: {
        
  evseDowntimePeriod: Property.Number({
    displayName: 'Evse Downtime Period',
    description: '',
    required: true,
  }),

  noticeId: Property.Number({
    displayName: 'Notice Id',
    description: '',
    required: false,
  }),

  startedAt: Property.DateTime({
    displayName: 'Started At',
    description: 'Allowed only for downtime period with `type = exempt AND entryMode = manual`',
    required: false,
  }),

  endedAt: Property.DateTime({
    displayName: 'Ended At',
    description: 'Allowed only for downtime period with `type = exempt AND entryMode = manual`',
    required: false,
  }),
  },
  async run(context): Promise<EvseDowntimePeriodUpdateResponse> {
    try {
      const url = processPathParameters('/public-api/resources/evse-downtime-periods/v1.0/{evseDowntimePeriod}', context.propsValue);
      
      const queryParams = prepareQueryParams(context.propsValue, []);
      
      const body = prepareRequestBody(context.propsValue,
        ['noticeId', 'startedAt', 'endedAt']
      );

      
      return await makeAmpecoApiCall(
        context.auth,
        url,
        HttpMethod.PATCH,
        body,
        queryParams
      ) as EvseDowntimePeriodUpdateResponse;

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