UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

197 lines • 8.05 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { SinglePage, V4PagePaginationArray, } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseDomains = /* @__PURE__ */ (() => { class BaseDomains extends APIResource { /** * Protects a new email domain by adding it to Email Security. Accepts a flat * configuration object covering all delivery modes. Returns the newly created * domain configuration. * * @example * ```ts * const domain = * await client.emailSecurity.settings.domains.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * allowed_delivery_modes: ['DIRECT'], * domain: 'domain', * drop_dispositions: ['MALICIOUS'], * ip_restrictions: ['192.0.2.0/24', '2001:db8::/32'], * regions: ['GLOBAL'], * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/email-security/settings/domains`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Replaces all mutable fields of a protected email domain in a single atomic * operation. Unlike PATCH, all non-computed fields are required. * * @example * ```ts * const domain = * await client.emailSecurity.settings.domains.update( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * allowed_delivery_modes: ['DIRECT'], * drop_dispositions: ['MALICIOUS'], * ip_restrictions: ['192.0.2.0/24', '2001:db8::/32'], * regions: ['GLOBAL'], * }, * ); * ``` */ update(domainID, params, options) { const { account_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/email-security/settings/domains/${domainID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Returns a paginated list of email domains protected by Email Security. Includes * domain configuration, delivery modes, and authorization status. Supports * filtering by delivery mode and integration ID. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const domainListResponse of client.emailSecurity.settings.domains.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/email-security/settings/domains`, (V4PagePaginationArray), { query, ...options }); } /** * Removes email security protection from a domain. After deletion, emails for this * domain will no longer be processed by Email Security. This action cannot be * undone. * * @example * ```ts * const domain = * await client.emailSecurity.settings.domains.delete( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(domainID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/email-security/settings/domains/${domainID}`, options)._thenUnwrap((obj) => obj.result); } /** * Executes multiple domain operations 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.domains.batch({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * deletes: [ * { id: 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415' }, * ], * patches: [ * { id: 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415' }, * ], * posts: [ * { * allowed_delivery_modes: ['DIRECT'], * domain: 'domain', * drop_dispositions: ['MALICIOUS'], * ip_restrictions: ['192.0.2.0/24', '2001:db8::/32'], * regions: ['GLOBAL'], * }, * ], * puts: [ * { * id: 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * allowed_delivery_modes: ['DIRECT'], * drop_dispositions: ['MALICIOUS'], * ip_restrictions: ['192.0.2.0/24', '2001:db8::/32'], * regions: ['GLOBAL'], * }, * ], * }); * ``` */ batch(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/email-security/settings/domains/batch`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Removes protection from multiple email domains. Deprecated; use the batch * endpoint instead. * * @deprecated This endpoint is deprecated. Use POST /accounts/{account_id}/email-security/settings/domains/batch instead. */ bulkDelete(params, options) { const { account_id } = params; return this._client.getAPIList(path `/accounts/${account_id}/email-security/settings/domains`, (SinglePage), { method: 'delete', ...options }); } /** * Updates configuration for a protected email domain. Only provided fields will be * modified. Changes affect delivery mode, security settings, and regional * processing. * * @example * ```ts * const response = * await client.emailSecurity.settings.domains.edit( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit(domainID, params, options) { const { account_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/email-security/settings/domains/${domainID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Retrieves detailed information for a specific protected email domain including * its delivery configuration, SPF/DMARC status, and authorization state. * * @example * ```ts * const domain = * await client.emailSecurity.settings.domains.get( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(domainID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/email-security/settings/domains/${domainID}`, options)._thenUnwrap((obj) => obj.result); } } BaseDomains._key = Object.freeze([ 'emailSecurity', 'settings', 'domains', ]); return BaseDomains; })(); export class Domains extends BaseDomains { } //# sourceMappingURL=domains.mjs.map