UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

114 lines • 4.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Webhooks = exports.BaseWebhooks = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../core/resource.js"); const pagination_1 = require("../../../core/pagination.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseWebhooks = /* @__PURE__ */ (() => { class BaseWebhooks extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/alerting/v3/destinations/webhooks`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/alerting/v3/destinations/webhooks/${webhookID}`, options)._thenUnwrap((obj) => obj.result); } } BaseWebhooks._key = Object.freeze([ 'alerting', 'destinations', 'webhooks', ]); return BaseWebhooks; })(); exports.BaseWebhooks = BaseWebhooks; class Webhooks extends BaseWebhooks { } exports.Webhooks = Webhooks; //# sourceMappingURL=webhooks.js.map