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

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

// Endpoint: PATCH /public-api/resources/charge-point-downtime-periods/v1.0/{chargePointDowntimePeriod}

export const chargePointDowntimePeriodUpdateAction = createAction({
  auth: ampecoAuth,
  name: 'chargePointDowntimePeriodUpdate',
  displayName: 'Resources - Charge Point Downtime Periods - Update',
  description: 'Update Charge Point Downtime Period.',
  audience: 'both',
  aiMetadata: { description: 'Update an existing charge-point downtime period identified by its numeric ID, changing its notice and optionally its start/end times. Idempotent: re-applying the same values yields the same state. Editing startedAt/endedAt is only allowed for manual exempt periods (type = exempt and entryMode = manual).', idempotent: true },
  props: {
        
  chargePointDowntimePeriod: Property.Number({
    displayName: 'Charge Point Downtime Period',
    required: true,
  }),

  noticeId: Property.Number({
    displayName: 'Notice Id',
    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<ChargePointDowntimePeriodUpdateResponse> {
    try {
      const url = processPathParameters('/public-api/resources/charge-point-downtime-periods/v1.0/{chargePointDowntimePeriod}', 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 ChargePointDowntimePeriodUpdateResponse;

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