cloudflare
Version:
The official TypeScript library for the Cloudflare API
159 lines • 6.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AllowPolicies = exports.BaseAllowPolicies = 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 BaseAllowPolicies = /* @__PURE__ */ (() => {
class BaseAllowPolicies extends resource_1.APIResource {
/**
* Creates a new allow policy that exempts matching emails from security
* detections. Use with caution as this bypasses email security scanning. Policies
* can match on sender patterns and apply to specific detections or all detections.
*
* @example
* ```ts
* const allowPolicy =
* await client.emailSecurity.settings.allowPolicies.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* is_acceptable_sender: false,
* is_exempt_recipient: false,
* is_regex: false,
* is_trusted_sender: true,
* pattern: 'test@example.com',
* pattern_type: 'EMAIL',
* verify_sender: true,
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/email-security/settings/allow_policies`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns a paginated list of email allow policies. These policies exempt matching
* emails from security detection, allowing them to bypass disposition actions.
* Supports filtering by pattern type and policy attributes.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const allowPolicyListResponse of client.emailSecurity.settings.allowPolicies.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/email-security/settings/allow_policies`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Removes an allow policy. After deletion, emails matching this pattern will be
* subject to normal security scanning and disposition actions.
*
* @example
* ```ts
* const allowPolicy =
* await client.emailSecurity.settings.allowPolicies.delete(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(policyID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/email-security/settings/allow_policies/${policyID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Executes multiple allow policy operations atomically: delete, partially update,
* replace, and create allow policies in a single request. All four operation
* arrays (deletes, patches, puts, posts) are required and executed in order. Send
* empty arrays for unused operations.
*
* @example
* ```ts
* const response =
* await client.emailSecurity.settings.allowPolicies.batch({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* deletes: [
* { id: 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415' },
* ],
* patches: [{}],
* posts: [
* {
* is_acceptable_sender: false,
* is_exempt_recipient: false,
* is_regex: false,
* is_trusted_sender: true,
* pattern: 'test@example.com',
* pattern_type: 'EMAIL',
* verify_sender: true,
* },
* ],
* puts: [{}],
* });
* ```
*/
batch(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/email-security/settings/allow_policies/batch`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Updates an existing allow policy. Only provided fields will be modified. Changes
* take effect for new emails matching the pattern.
*
* @example
* ```ts
* const response =
* await client.emailSecurity.settings.allowPolicies.edit(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(policyID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/email-security/settings/allow_policies/${policyID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Retrieves details for a specific allow policy including its pattern,
* dispositions that are exempted, and whether it applies to all detections.
*
* @example
* ```ts
* const allowPolicy =
* await client.emailSecurity.settings.allowPolicies.get(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(policyID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/email-security/settings/allow_policies/${policyID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseAllowPolicies._key = Object.freeze([
'emailSecurity',
'settings',
'allowPolicies',
]);
return BaseAllowPolicies;
})();
exports.BaseAllowPolicies = BaseAllowPolicies;
class AllowPolicies extends BaseAllowPolicies {
}
exports.AllowPolicies = AllowPolicies;
//# sourceMappingURL=allow-policies.js.map