UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

102 lines • 3.77 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseRules = /* @__PURE__ */ (() => { class BaseRules extends APIResource { /** * Creates a new rule in a Web Analytics ruleset. * * @example * ```ts * const rumRule = await client.rum.rules.create( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ create(rulesetID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/rum/v2/${rulesetID}/rule`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Updates a rule in a Web Analytics ruleset. * * @example * ```ts * const rumRule = await client.rum.rules.update( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * ruleset_id: 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * }, * ); * ``` */ update(ruleID, params, options) { const { account_id, ruleset_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/rum/v2/${ruleset_id}/rule/${ruleID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists all the rules in a Web Analytics ruleset. * * @example * ```ts * const rules = await client.rum.rules.list( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ list(rulesetID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/rum/v2/${rulesetID}/rules`, options)._thenUnwrap((obj) => obj.result); } /** * Deletes an existing rule from a Web Analytics ruleset. * * @example * ```ts * const rule = await client.rum.rules.delete( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * ruleset_id: 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * }, * ); * ``` */ delete(ruleID, params, options) { const { account_id, ruleset_id } = params; return this._client.delete(path `/accounts/${account_id}/rum/v2/${ruleset_id}/rule/${ruleID}`, options)._thenUnwrap((obj) => obj.result); } /** * Modifies one or more rules in a Web Analytics ruleset with a single request. * * @example * ```ts * const response = await client.rum.rules.bulkCreate( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ bulkCreate(rulesetID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/rum/v2/${rulesetID}/rules`, { body, ...options, })._thenUnwrap((obj) => obj.result); } } BaseRules._key = Object.freeze(['rum', 'rules']); return BaseRules; })(); export class Rules extends BaseRules { } //# sourceMappingURL=rules.mjs.map