cloudflare
Version:
The official TypeScript library for the Cloudflare API
62 lines • 2.4 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from 'cloudflare/resource';
import { isRequestOptions } from 'cloudflare/core';
import * as RulesAPI from 'cloudflare/resources/firewall/rules';
import { V4PagePaginationArray } from 'cloudflare/pagination';
export class Rules extends APIResource {
/**
* Create one or more firewall rules.
*/
create(zoneIdentifier, body, options) {
return this._client.post(`/zones/${zoneIdentifier}/firewall/rules`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Updates an existing firewall rule.
*/
update(zoneIdentifier, id, body, options) {
return this._client.put(`/zones/${zoneIdentifier}/firewall/rules/${id}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
list(zoneIdentifier, query = {}, options) {
if (isRequestOptions(query)) {
return this.list(zoneIdentifier, {}, query);
}
return this._client.getAPIList(`/zones/${zoneIdentifier}/firewall/rules`, FirewallRulesV4PagePaginationArray, { query, ...options });
}
/**
* Deletes an existing firewall rule.
*/
delete(zoneIdentifier, id, body, options) {
return this._client.delete(`/zones/${zoneIdentifier}/firewall/rules/${id}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Updates the priority of an existing firewall rule.
*/
edit(zoneIdentifier, id, body, options) {
return this._client.patch(`/zones/${zoneIdentifier}/firewall/rules/${id}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Fetches the details of a firewall rule.
*/
get(zoneIdentifier, params, options) {
const { path_id, query_id, ...query } = params;
return this._client.get(`/zones/${zoneIdentifier}/firewall/rules/${path_id}`, {
query: { id: query_id, ...query },
...options,
})._thenUnwrap((obj) => obj.result);
}
}
export class FirewallRulesV4PagePaginationArray extends V4PagePaginationArray {
}
(function (Rules) {
Rules.FirewallRulesV4PagePaginationArray = RulesAPI.FirewallRulesV4PagePaginationArray;
})(Rules || (Rules = {}));
//# sourceMappingURL=rules.mjs.map