UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

57 lines • 2.51 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 BasePrecursor = /* @__PURE__ */ (() => { class BasePrecursor extends 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(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(path `/zones/${zone_id}/precursor`, options)._thenUnwrap((obj) => obj.result); } } BasePrecursor._key = Object.freeze(['precursor']); return BasePrecursor; })(); export class Precursor extends BasePrecursor { } //# sourceMappingURL=precursor.mjs.map