UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

110 lines • 5.03 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 BaseImpersonationRegistry = /* @__PURE__ */ (() => { class BaseImpersonationRegistry extends APIResource { /** * Creates a new entry in the impersonation registry to protect against * impersonation. Emails attempting to impersonate this identity will be flagged. * Supports regex patterns for flexible email matching. * * @example * ```ts * const impersonationRegistry = * await client.emailSecurity.settings.impersonationRegistry.create( * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * email: 'john.doe@example.com', * is_email_regex: false, * name: 'John Doe', * }, * ); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/email-security/settings/impersonation_registry`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Returns a paginated list of protected identities in the impersonation registry. * These entries define identities and email addresses to protect from * impersonation attacks. Can be manually added or automatically synced from * directory integrations. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const impersonationRegistryListResponse of client.emailSecurity.settings.impersonationRegistry.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/email-security/settings/impersonation_registry`, (V4PagePaginationArray), { query, ...options }); } /** * Removes an entry from the impersonation registry. After deletion, this identity * will no longer be protected from impersonation. * * @example * ```ts * const impersonationRegistry = * await client.emailSecurity.settings.impersonationRegistry.delete( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(impersonationRegistryID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/email-security/settings/impersonation_registry/${impersonationRegistryID}`, options)._thenUnwrap((obj) => obj.result); } /** * Updates an existing impersonation registry entry. Only provided fields will be * modified. Directory-synced entries can't be updated. * * @example * ```ts * const response = * await client.emailSecurity.settings.impersonationRegistry.edit( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit(impersonationRegistryID, params, options) { const { account_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/email-security/settings/impersonation_registry/${impersonationRegistryID}`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Retrieves details for a specific impersonation registry entry including the * protected identity, email pattern, and synchronization source if * directory-synced. * * @example * ```ts * const impersonationRegistry = * await client.emailSecurity.settings.impersonationRegistry.get( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(impersonationRegistryID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/email-security/settings/impersonation_registry/${impersonationRegistryID}`, options)._thenUnwrap((obj) => obj.result); } } BaseImpersonationRegistry._key = Object.freeze(['emailSecurity', 'settings', 'impersonationRegistry']); return BaseImpersonationRegistry; })(); export class ImpersonationRegistry extends BaseImpersonationRegistry { } //# sourceMappingURL=impersonation-registry.mjs.map