cloudflare
Version:
The official TypeScript library for the Cloudflare API
103 lines • 3.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Silences = exports.BaseSilences = 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 BaseSilences = /* @__PURE__ */ (() => {
class BaseSilences extends resource_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/alerting/v3/silences`, (pagination_1.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((0, path_1.path) `/accounts/${account_id}/alerting/v3/silences`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/alerting/v3/silences/${silenceID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseSilences._key = Object.freeze([
'alerting',
'silences',
]);
return BaseSilences;
})();
exports.BaseSilences = BaseSilences;
class Silences extends BaseSilences {
}
exports.Silences = Silences;
//# sourceMappingURL=silences.js.map