cloudflare
Version:
The official TypeScript library for the Cloudflare API
139 lines • 4.9 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import { SinglePage } from "../../../../core/pagination.mjs";
import { path } from "../../../../internal/utils/path.mjs";
export var BaseRules = /* @__PURE__ */ (() => {
class BaseRules extends 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(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(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(path `/accounts/${account_id}/dlp/email/rules`, (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(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(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(path `/accounts/${account_id}/dlp/email/rules/${ruleID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseRules._key = Object.freeze([
'zeroTrust',
'dlp',
'email',
'rules',
]);
return BaseRules;
})();
export class Rules extends BaseRules {
}
//# sourceMappingURL=rules.mjs.map