UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

152 lines • 6.11 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 BaseBlockSenders = /* @__PURE__ */ (() => { class BaseBlockSenders extends APIResource { /** * Creates a new blocked sender pattern. Emails matching this pattern will be * blocked from delivery. Patterns can be email addresses, domains, or IP * addresses, and support regular expressions. * * @example * ```ts * const blockSender = * await client.emailSecurity.settings.blockSenders.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * is_regex: false, * pattern: 'test@example.com', * pattern_type: 'EMAIL', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/email-security/settings/block_senders`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Returns a paginated list of blocked email sender patterns. These patterns * prevent emails from matching senders from being delivered. Supports filtering by * pattern type and searching across patterns. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const blockSenderListResponse of client.emailSecurity.settings.blockSenders.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/email-security/settings/block_senders`, (V4PagePaginationArray), { query, ...options }); } /** * Removes a blocked sender pattern. After deletion, emails from this sender will * no longer be automatically blocked based on this rule. * * @example * ```ts * const blockSender = * await client.emailSecurity.settings.blockSenders.delete( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(patternID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/email-security/settings/block_senders/${patternID}`, options)._thenUnwrap((obj) => obj.result); } /** * Executes multiple blocked sender operations atomically: delete, partially * update, replace, and create blocked sender patterns 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.blockSenders.batch({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * deletes: [ * { id: 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415' }, * ], * patches: [{}], * posts: [ * { * is_regex: false, * pattern: 'test@example.com', * pattern_type: 'EMAIL', * }, * ], * puts: [ * { * is_regex: false, * pattern: 'test@example.com', * pattern_type: 'EMAIL', * }, * ], * }); * ``` */ batch(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/email-security/settings/block_senders/batch`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Updates an existing blocked sender pattern. Only provided fields will be * modified. The pattern will continue blocking emails until deleted. * * @example * ```ts * const response = * await client.emailSecurity.settings.blockSenders.edit( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit(patternID, params, options) { const { account_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/email-security/settings/block_senders/${patternID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Retrieves details for a specific blocked sender pattern including its pattern * type, value, and metadata. * * @example * ```ts * const blockSender = * await client.emailSecurity.settings.blockSenders.get( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(patternID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/email-security/settings/block_senders/${patternID}`, options)._thenUnwrap((obj) => obj.result); } } BaseBlockSenders._key = Object.freeze([ 'emailSecurity', 'settings', 'blockSenders', ]); return BaseBlockSenders; })(); export class BlockSenders extends BaseBlockSenders { } //# sourceMappingURL=block-senders.mjs.map