UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

62 lines • 2.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Precursor = exports.BasePrecursor = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const path_1 = require("../../internal/utils/path.js"); var BasePrecursor = /* @__PURE__ */ (() => { class BasePrecursor extends resource_1.APIResource { /** * Updates the Precursor configuration for a zone. * * `default_mode` sets the zone-level enforcement mode. `enforcement_rules` is the * ordered list of rules that override enforcement for matching requests. * * This is a partial update: only the fields present in the request body are * changed. * * - Sending an empty array (`[]`) clears all enforcement rules. * - At least one of `default_mode` or `enforcement_rules` must be present; an * empty body (`{}`) is rejected with `400`. * - Rule `id` is read-only (assigned by Cloudflare) and ignored on input. * - Rule `mode` must be `min-friction` or `max-security` (`off` is not a valid * rule mode; use `default_mode` to disable enforcement). * - Rule `expression` is limited to 4000 characters. The limit applies to each * rule individually, not to the combined size of all rules. * * @example * ```ts * const precursorConfig = await client.precursor.update({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * default_mode: 'min-friction', * }); * ``` */ update(params, options) { const { zone_id, ...body } = params; return this._client.put((0, path_1.path) `/zones/${zone_id}/precursor`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Retrieve a zone's Precursor configuration: the zone-level `default_mode` and the * ordered list of `enforcement_rules`. * * @example * ```ts * const precursorConfig = await client.precursor.get({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ get(params, options) { const { zone_id } = params; return this._client.get((0, path_1.path) `/zones/${zone_id}/precursor`, options)._thenUnwrap((obj) => obj.result); } } BasePrecursor._key = Object.freeze(['precursor']); return BasePrecursor; })(); exports.BasePrecursor = BasePrecursor; class Precursor extends BasePrecursor { } exports.Precursor = Precursor; //# sourceMappingURL=precursor.js.map