cloudflare
Version:
The official TypeScript library for the Cloudflare API
102 lines • 3.69 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { V4PagePaginationArray } from "../../core/pagination.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseUARules = /* @__PURE__ */ (() => {
class BaseUARules extends APIResource {
/**
* Creates a new User Agent Blocking rule in a zone.
*
* @example
* ```ts
* const uaRule = await client.firewall.uaRules.create({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* configuration: {},
* mode: 'challenge',
* });
* ```
*/
create(params, options) {
const { zone_id, ...body } = params;
return this._client.post(path `/zones/${zone_id}/firewall/ua_rules`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Updates an existing User Agent Blocking rule.
*
* @example
* ```ts
* const uaRule = await client.firewall.uaRules.update(
* '372e67954025e0ba6aaa6d586b9e0b59',
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* configuration: {},
* mode: 'challenge',
* },
* );
* ```
*/
update(uaRuleID, params, options) {
const { zone_id, ...body } = params;
return this._client.put(path `/zones/${zone_id}/firewall/ua_rules/${uaRuleID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Fetches User Agent Blocking rules in a zone. You can filter the results using
* several optional parameters.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const uaRuleListResponse of client.firewall.uaRules.list(
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { zone_id, ...query } = params;
return this._client.getAPIList(path `/zones/${zone_id}/firewall/ua_rules`, (V4PagePaginationArray), { query, ...options });
}
/**
* Deletes an existing User Agent Blocking rule.
*
* @example
* ```ts
* const uaRule = await client.firewall.uaRules.delete(
* '372e67954025e0ba6aaa6d586b9e0b59',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(uaRuleID, params, options) {
const { zone_id } = params;
return this._client.delete(path `/zones/${zone_id}/firewall/ua_rules/${uaRuleID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Fetches the details of a User Agent Blocking rule.
*
* @example
* ```ts
* const uaRule = await client.firewall.uaRules.get(
* '372e67954025e0ba6aaa6d586b9e0b59',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(uaRuleID, params, options) {
const { zone_id } = params;
return this._client.get(path `/zones/${zone_id}/firewall/ua_rules/${uaRuleID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseUARules._key = Object.freeze([
'firewall',
'uaRules',
]);
return BaseUARules;
})();
export class UARules extends BaseUARules {
}
//# sourceMappingURL=ua-rules.mjs.map