UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

154 lines • 6.37 kB
// 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 BaseAllowPolicies = /* @__PURE__ */ (() => { class BaseAllowPolicies extends 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(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(path `/accounts/${account_id}/email-security/settings/allow_policies`, (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(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(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(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(path `/accounts/${account_id}/email-security/settings/allow_policies/${policyID}`, options)._thenUnwrap((obj) => obj.result); } } BaseAllowPolicies._key = Object.freeze([ 'emailSecurity', 'settings', 'allowPolicies', ]); return BaseAllowPolicies; })(); export class AllowPolicies extends BaseAllowPolicies { } //# sourceMappingURL=allow-policies.mjs.map