cloudflare
Version:
The official TypeScript library for the Cloudflare API
102 lines • 3.58 kB
JavaScript
// 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 BasePolicies = /* @__PURE__ */ (() => {
class BasePolicies extends APIResource {
/**
* Creates a new Notification policy.
*
* @example
* ```ts
* const policy = await client.alerting.policies.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* alert_type: 'universal_ssl_event_type',
* enabled: true,
* mechanisms: {},
* name: 'SSL Notification Event Policy',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/alerting/v3/policies`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Update a Notification policy.
*
* @example
* ```ts
* const policy = await client.alerting.policies.update(
* '0da2b59ef118439d8097bdfb215203c9',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
update(policyID, params, options) {
const { account_id, ...body } = params;
return this._client.put(path `/accounts/${account_id}/alerting/v3/policies/${policyID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Get a list of all Notification policies.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const policy of client.alerting.policies.list({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* })) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id } = params;
return this._client.getAPIList(path `/accounts/${account_id}/alerting/v3/policies`, (SinglePage), options);
}
/**
* Delete a Notification policy.
*
* @example
* ```ts
* const policy = await client.alerting.policies.delete(
* '0da2b59ef118439d8097bdfb215203c9',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(policyID, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/alerting/v3/policies/${policyID}`, options);
}
/**
* Get details for a single policy.
*
* @example
* ```ts
* const policy = await client.alerting.policies.get(
* '0da2b59ef118439d8097bdfb215203c9',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(policyID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/alerting/v3/policies/${policyID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BasePolicies._key = Object.freeze([
'alerting',
'policies',
]);
return BasePolicies;
})();
export class Policies extends BasePolicies {
}
//# sourceMappingURL=policies.mjs.map