cloudflare
Version:
The official TypeScript library for the Cloudflare API
115 lines • 4.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PageRules = exports.BasePageRules = 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 BasePageRules = /* @__PURE__ */ (() => {
class BasePageRules extends resource_1.APIResource {
/**
* Creates a new Page Rule.
*
* @example
* ```ts
* const pageRule = await client.pageRules.create({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* actions: [{ id: 'browser_check' }],
* targets: [{}],
* });
* ```
*/
create(params, options) {
const { zone_id, ...body } = params;
return this._client.post((0, path_1.path) `/zones/${zone_id}/pagerules`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Replaces the configuration of an existing Page Rule. The configuration of the
* updated Page Rule will exactly match the data passed in the API request.
*
* @example
* ```ts
* const pageRule = await client.pageRules.update(
* '023e105f4ecef8ad9ca31a8372d0c353',
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* actions: [{ id: 'browser_check' }],
* targets: [{}],
* },
* );
* ```
*/
update(pageruleID, params, options) {
const { zone_id, ...body } = params;
return this._client.put((0, path_1.path) `/zones/${zone_id}/pagerules/${pageruleID}`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Fetches Page Rules in a zone.
*
* @example
* ```ts
* const pageRules = await client.pageRules.list({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
list(params, options) {
const { zone_id, ...query } = params;
return this._client.get((0, path_1.path) `/zones/${zone_id}/pagerules`, { query, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Deletes an existing Page Rule.
*
* @example
* ```ts
* const pageRule = await client.pageRules.delete(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(pageruleID, params, options) {
const { zone_id } = params;
return this._client.delete((0, path_1.path) `/zones/${zone_id}/pagerules/${pageruleID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Updates one or more fields of an existing Page Rule.
*
* @example
* ```ts
* const pageRule = await client.pageRules.edit(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(pageruleID, params, options) {
const { zone_id, ...body } = params;
return this._client.patch((0, path_1.path) `/zones/${zone_id}/pagerules/${pageruleID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Fetches the details of a Page Rule.
*
* @example
* ```ts
* const pageRule = await client.pageRules.get(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(pageruleID, params, options) {
const { zone_id } = params;
return this._client.get((0, path_1.path) `/zones/${zone_id}/pagerules/${pageruleID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BasePageRules._key = Object.freeze(['pageRules']);
return BasePageRules;
})();
exports.BasePageRules = BasePageRules;
class PageRules extends BasePageRules {
}
exports.PageRules = PageRules;
//# sourceMappingURL=page-rules.js.map