Files
portainer/app/react/docker/services/webhooks/removeWebhook.ts
T
2025-12-17 13:02:19 +02:00

26 lines
774 B
TypeScript

import axios, { parseAxiosError } from '@CE/portainer/services/axios';
import { EnvironmentId } from '@CE/react/portainer/environments/types';
import { promiseSequence } from '@CE/portainer/helpers/promise-utils';
import { getWebhooks } from './getWebhooks';
import { Webhook } from './types';
import { buildUrl } from './build-url';
export async function removeWebhooksForService(
environmentId: EnvironmentId,
serviceId: string
) {
const webhooks = await getWebhooks(environmentId, serviceId);
return promiseSequence(
webhooks.map((webhook) => () => removeWebhook(webhook.Id))
);
}
export async function removeWebhook(webhookId: Webhook['Id']) {
try {
await axios.delete(buildUrl(webhookId));
} catch (err) {
throw parseAxiosError(err);
}
}