cloudflare
Version:
The official TypeScript library for the Cloudflare API
144 lines • 5.16 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 {
/**
* Creates a new DLP email scanning rule that defines what content patterns to
* detect in email messages and what actions to take.
*
* @example
* ```ts
* const rule = await client.zeroTrust.dlp.email.rules.create({
* account_id: 'account_id',
* action: { action: 'Block' },
* conditions: [
* {
* operator: 'InList',
* selector: 'Recipients',
* value: ['string'],
* },
* ],
* enabled: true,
* name: 'name',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/dlp/email/rules`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Updates a DLP email scanning rule.
*
* @example
* ```ts
* const rule = await client.zeroTrust.dlp.email.rules.update(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* {
* account_id: 'account_id',
* action: { action: 'Block' },
* conditions: [
* {
* operator: 'InList',
* selector: 'Recipients',
* value: ['string'],
* },
* ],
* enabled: true,
* name: 'name',
* },
* );
* ```
*/
update(ruleID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/dlp/email/rules/${ruleID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists all email scanner rules for an account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const ruleListResponse of client.zeroTrust.dlp.email.rules.list(
* { account_id: 'account_id' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/dlp/email/rules`, (pagination_1.SinglePage), options);
}
/**
* Removes a DLP email scanning rule. The rule will no longer be applied to email
* messages.
*
* @example
* ```ts
* const rule = await client.zeroTrust.dlp.email.rules.delete(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
delete(ruleID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/dlp/email/rules/${ruleID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Reorders DLP email scanning rules by updating their priority values. Higher
* priority rules are evaluated first.
*
* @example
* ```ts
* const response =
* await client.zeroTrust.dlp.email.rules.bulkEdit({
* account_id: 'account_id',
* new_priorities: { foo: 0 },
* });
* ```
*/
bulkEdit(params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/dlp/email/rules`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Gets detailed configuration for a specific DLP email scanning rule, including
* detection patterns and actions.
*
* @example
* ```ts
* const rule = await client.zeroTrust.dlp.email.rules.get(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
get(ruleID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/dlp/email/rules/${ruleID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseRules._key = Object.freeze([
'zeroTrust',
'dlp',
'email',
'rules',
]);
return BaseRules;
})();
exports.BaseRules = BaseRules;
class Rules extends BaseRules {
}
exports.Rules = Rules;
//# sourceMappingURL=rules.js.map