UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

109 lines • 3.98 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseWebhooks = /* @__PURE__ */ (() => { class BaseWebhooks extends APIResource { /** * Creates a new webhook destination. * * @example * ```ts * const webhook = * await client.alerting.destinations.webhooks.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * name: 'Slack Webhook', * url: 'https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/alerting/v3/destinations/webhooks`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Update a webhook destination. * * @example * ```ts * const webhook = * await client.alerting.destinations.webhooks.update( * 'b115d5ec15c641ee8b7692c449b5227b', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * name: 'Slack Webhook', * url: 'https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd', * }, * ); * ``` */ update(webhookID, params, options) { const { account_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/alerting/v3/destinations/webhooks/${webhookID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Gets a list of all configured webhook destinations. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const webhooks of client.alerting.destinations.webhooks.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id } = params; return this._client.getAPIList(path `/accounts/${account_id}/alerting/v3/destinations/webhooks`, (SinglePage), options); } /** * Delete a configured webhook destination. * * @example * ```ts * const webhook = * await client.alerting.destinations.webhooks.delete( * 'b115d5ec15c641ee8b7692c449b5227b', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(webhookID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/alerting/v3/destinations/webhooks/${webhookID}`, options); } /** * Get details for a single webhooks destination. * * @example * ```ts * const webhooks = * await client.alerting.destinations.webhooks.get( * 'b115d5ec15c641ee8b7692c449b5227b', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(webhookID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/alerting/v3/destinations/webhooks/${webhookID}`, options)._thenUnwrap((obj) => obj.result); } } BaseWebhooks._key = Object.freeze([ 'alerting', 'destinations', 'webhooks', ]); return BaseWebhooks; })(); export class Webhooks extends BaseWebhooks { } //# sourceMappingURL=webhooks.mjs.map