cloudflare
Version:
The official TypeScript library for the Cloudflare API
135 lines • 5.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Rules = exports.BaseRules = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../core/resource.js");
const pagination_1 = require("../../core/pagination.js");
const path_1 = require("../../internal/utils/path.js");
var BaseRules = /* @__PURE__ */ (() => {
class BaseRules extends resource_1.APIResource {
/**
* Only available for the Waiting Room Advanced subscription. Creates a rule for a
* waiting room.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const waitingRoomRule of client.waitingRooms.rules.create(
* '699d98642c564d2e855e9661899b7252',
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* rules: {
* action: 'bypass_waiting_room',
* expression: 'ip.src in {10.20.30.40}',
* },
* },
* )) {
* // ...
* }
* ```
*/
create(waitingRoomID, params, options) {
const { zone_id, rules } = params;
return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/waiting_rooms/${waitingRoomID}/rules`, (pagination_1.SinglePage), { body: rules, method: 'post', ...options });
}
/**
* Only available for the Waiting Room Advanced subscription. Replaces all rules
* for a waiting room.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const waitingRoomRule of client.waitingRooms.rules.update(
* '699d98642c564d2e855e9661899b7252',
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* rules: [
* {
* action: 'bypass_waiting_room',
* expression: 'ip.src in {10.20.30.40}',
* },
* ],
* },
* )) {
* // ...
* }
* ```
*/
update(waitingRoomID, params, options) {
const { zone_id, rules } = params;
return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/waiting_rooms/${waitingRoomID}/rules`, (pagination_1.SinglePage), { body: rules, method: 'put', ...options });
}
/**
* Deletes a rule for a waiting room.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const waitingRoomRule of client.waitingRooms.rules.delete(
* '25756b2dfe6e378a06b033b670413757',
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* waiting_room_id: '699d98642c564d2e855e9661899b7252',
* },
* )) {
* // ...
* }
* ```
*/
delete(ruleID, params, options) {
const { zone_id, waiting_room_id } = params;
return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/waiting_rooms/${waiting_room_id}/rules/${ruleID}`, (pagination_1.SinglePage), { method: 'delete', ...options });
}
/**
* Patches a rule for a waiting room.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const waitingRoomRule of client.waitingRooms.rules.edit(
* '25756b2dfe6e378a06b033b670413757',
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* waiting_room_id: '699d98642c564d2e855e9661899b7252',
* action: 'bypass_waiting_room',
* expression: 'ip.src in {10.20.30.40}',
* },
* )) {
* // ...
* }
* ```
*/
edit(ruleID, params, options) {
const { zone_id, waiting_room_id, ...body } = params;
return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/waiting_rooms/${waiting_room_id}/rules/${ruleID}`, (pagination_1.SinglePage), { body, method: 'patch', ...options });
}
/**
* Lists rules for a waiting room.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const waitingRoomRule of client.waitingRooms.rules.get(
* '699d98642c564d2e855e9661899b7252',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
get(waitingRoomID, params, options) {
const { zone_id } = params;
return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/waiting_rooms/${waitingRoomID}/rules`, (pagination_1.SinglePage), options);
}
}
BaseRules._key = Object.freeze([
'waitingRooms',
'rules',
]);
return BaseRules;
})();
exports.BaseRules = BaseRules;
class Rules extends BaseRules {
}
exports.Rules = Rules;
//# sourceMappingURL=rules.js.map