import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { ampecoAuth } from '../../../common/auth';
import { handleApiError, makeAmpecoApiCall, prepareQueryParams, processPathParameters } from '../../../common/utils';

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

// Endpoint: POST /public-api/resources/provisioning-certificates/v2.0

export const deletePcIdAction = createAction({
  auth: ampecoAuth,
  name: 'deletePcId',
  displayName: 'Resources - Provisioning Certificates - Delete Pc Id',
  description: 'Delete a provisioning certificate.',
  audience: 'both',
  aiMetadata: { description: 'Permanently delete an AMPECO provisioning certificate by its numeric ID. Destructive and not reversible; a repeat call on an already-deleted certificate will fail. Verify the ID via get or list pc ids before deleting.', idempotent: false },
  props: {
        
  provisioningCertificate: Property.Number({
    displayName: 'Provisioning Certificate',
    description: '',
    required: true,
  }),
  },
  async run(context): Promise<unknown> {
    try {
      const url = processPathParameters('/public-api/resources/provisioning-certificates/v2.0/{provisioningCertificate}', context.propsValue);
      
      const queryParams = prepareQueryParams(context.propsValue, []);
      
      const body = undefined;

      
      return await makeAmpecoApiCall(
        context.auth,
        url,
        HttpMethod.DELETE,
        body,
        queryParams
      ) as unknown;

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