UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

94 lines • 3.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Phases = exports.BasePhases = void 0; const tslib_1 = require("../../../internal/tslib.js"); // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../core/resource.js"); const VersionsAPI = tslib_1.__importStar(require("./versions.js")); const versions_1 = require("./versions.js"); const error_1 = require("../../../core/error.js"); const path_1 = require("../../../internal/utils/path.js"); var BasePhases = /* @__PURE__ */ (() => { class BasePhases extends resource_1.APIResource { /** * Updates an account or zone entry point ruleset, creating a new version. * * @example * ```ts * const phase = await client.rulesets.phases.update( * 'http_request_firewall_custom', * { account_id: 'account_id' }, * ); * ``` */ update(rulesetPhase, params, options) { const { account_id, zone_id, dry_run, ...body } = params; if (!account_id && !zone_id) { throw new error_1.CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new error_1.CloudflareError('You cannot provide both account_id and zone_id.'); } const { accountOrZone, accountOrZoneId } = account_id ? { accountOrZone: 'accounts', accountOrZoneId: account_id, } : { accountOrZone: 'zones', accountOrZoneId: zone_id, }; return this._client.put((0, path_1.path) `/${accountOrZone}/${accountOrZoneId}/rulesets/phases/${rulesetPhase}/entrypoint`, { query: { dry_run }, body, ...options })._thenUnwrap((obj) => obj.result); } /** * Fetches the latest version of the account or zone entry point ruleset for a * given phase. * * @example * ```ts * const phase = await client.rulesets.phases.get( * 'http_request_firewall_custom', * { account_id: 'account_id' }, * ); * ``` */ get(rulesetPhase, params = {}, options) { const { account_id, zone_id } = params ?? {}; if (!account_id && !zone_id) { throw new error_1.CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new error_1.CloudflareError('You cannot provide both account_id and zone_id.'); } const { accountOrZone, accountOrZoneId } = account_id ? { accountOrZone: 'accounts', accountOrZoneId: account_id, } : { accountOrZone: 'zones', accountOrZoneId: zone_id, }; return this._client.get((0, path_1.path) `/${accountOrZone}/${accountOrZoneId}/rulesets/phases/${rulesetPhase}/entrypoint`, options)._thenUnwrap((obj) => obj.result); } } BasePhases._key = Object.freeze([ 'rulesets', 'phases', ]); return BasePhases; })(); exports.BasePhases = BasePhases; var Phases = /* @__PURE__ */ (() => { class Phases extends BasePhases { constructor() { super(...arguments); this.versions = new VersionsAPI.Versions(this._client); } } Phases.Versions = versions_1.Versions; Phases.BaseVersions = versions_1.BaseVersions; return Phases; })(); exports.Phases = Phases; //# sourceMappingURL=phases.js.map