UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

98 lines • 3.49 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 BaseSilences = /* @__PURE__ */ (() => { class BaseSilences extends APIResource { /** * Creates a new silence for an account. * * @example * ```ts * const silence = await client.alerting.silences.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * body: [{}], * }); * ``` */ create(params, options) { const { account_id, body } = params; return this._client.post(path `/accounts/${account_id}/alerting/v3/silences`, { body: body, ...options }); } /** * Updates existing silences for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const silenceUpdateResponse of client.alerting.silences.update( * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * body: [{}], * }, * )) { * // ... * } * ``` */ update(params, options) { const { account_id, body } = params; return this._client.getAPIList(path `/accounts/${account_id}/alerting/v3/silences`, (SinglePage), { body: body, method: 'put', ...options }); } /** * Gets a list of silences for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const silenceListResponse of client.alerting.silences.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id } = params; return this._client.getAPIList(path `/accounts/${account_id}/alerting/v3/silences`, (SinglePage), options); } /** * Deletes an existing silence for an account. * * @example * ```ts * const silence = await client.alerting.silences.delete( * 'f878e90c23f44126ae3cfc399f646977', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(silenceID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/alerting/v3/silences/${silenceID}`, options); } /** * Gets a specific silence for an account. * * @example * ```ts * const silence = await client.alerting.silences.get( * 'f878e90c23f44126ae3cfc399f646977', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(silenceID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/alerting/v3/silences/${silenceID}`, options)._thenUnwrap((obj) => obj.result); } } BaseSilences._key = Object.freeze([ 'alerting', 'silences', ]); return BaseSilences; })(); export class Silences extends BaseSilences { } //# sourceMappingURL=silences.mjs.map