Skip to content

Commit

Permalink
feat(api): support Page Rules
Browse files Browse the repository at this point in the history
Supports managing Page Rules resources.

Signed-off-by: Terin Stock <terinjokes@gmail.com>
  • Loading branch information
Perlover authored and terinjokes committed Aug 4, 2020
1 parent 5cf5f1c commit 9072fda
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const resources = {
enterpriseZoneWorkersKVNamespaces: require('./lib/resources/EnterpriseZoneWorkersKVNamespaces'),
enterpriseZoneWorkersKV: require('./lib/resources/EnterpriseZoneWorkersKV'),
ips: require('./lib/resources/IPs'),
pageRules: require('./lib/resources/PageRules'),
zones: require('./lib/resources/Zones'),
zoneSettings: require('./lib/resources/ZoneSettings'),
zoneCustomHostNames: require('./lib/resources/ZoneCustomHostNames'),
Expand Down Expand Up @@ -67,6 +68,7 @@ const withEnvProxy = function withEnvProxy(opts) {
*
* @property {DNSRecords} dnsRecords - DNS Records instance
* @property {IPs} ips - IPs instance
* @property {PageRules} pageRules - Page Rules instance
* @property {Zones} zones - Zones instance
* @property {ZoneSettings} zoneSettings - Zone Settings instance
* @property {ZoneCustomHostNames} zoneCustomHostNames - Zone Custom Host Names instance
Expand Down
80 changes: 80 additions & 0 deletions lib/resources/PageRules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (C) 2014-present Cloudflare, Inc.
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/

'use strict';

const prototypal = require('es-class');
const auto = require('autocreate');

const Resource = require('../Resource');

/**
* PageRules represents the /zones/:zoneID/pagerules API endpoint.
*
* @class PageRules
* @hideconstructor
* @extends Resource
*/
module.exports = auto(
prototypal({
extends: Resource,
path: 'zones/:zoneId/pagerules',

includeBasic: ['browse', 'read', 'edit', 'add', 'del'],

/**
* browse allows for listing all the page rules
*
* @function browse
* @memberof PageRules
* @instance
* @async
* @returns {Promise<Object>} The page rules browse response object.
*/
/**
* read allows for retrieving a specific page rule
*
* @function read
* @memberof PageRules
* @instance
* @async
* @param {string} id - The page rule ID
* @returns {Promise<Object>} The page rule response object.
*/
/**
* edit allows for modifying a specific zone
*
* @function edit
* @memberof PageRules
* @instance
* @async
* @param {string} id - The page rule ID
* @param {Object} page_rule - The modified page rule object
* @returns {Promise<Object>} The page rule response object.
*/
/**
* add allows for creating a new zone
*
* @function add
* @memberof PageRules
* @instance
* @async
* @param {Object} zone - The new page rule object
* @returns {Promise<Object>} The page rule response object.
*/
/**
* del allows for removing a new zone
*
* @function del
* @memberof PageRules
* @instance
* @async
* @param {string} id - The page rule ID to delete
* @returns {Promise<Object>} The page rule response object.
*/
})
);

0 comments on commit 9072fda

Please sign in to comment.