cloudflare
Version:
The official TypeScript library for the Cloudflare API
159 lines • 6.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TrustedDomains = exports.BaseTrustedDomains = 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 BaseTrustedDomains = /* @__PURE__ */ (() => {
class BaseTrustedDomains extends resource_1.APIResource {
/**
* Creates a new trusted domain pattern. Use for partner domains or approved
* senders that should bypass recent domain registration and similarity checks.
* Configure whether it prevents recent domain or spoof dispositions.
*
* @example
* ```ts
* const trustedDomain =
* await client.emailSecurity.settings.trustedDomains.create(
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* is_recent: true,
* is_regex: false,
* is_similarity: false,
* pattern: 'example.com',
* },
* );
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/email-security/settings/trusted_domains`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns a paginated list of trusted domain patterns. Trusted domains prevent
* false positives for recently registered domains and lookalike domain detections.
* Patterns can use regular expressions for flexible matching.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const trustedDomainListResponse of client.emailSecurity.settings.trustedDomains.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/trusted_domains`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Removes a trusted domain pattern. After deletion, emails from this domain will
* be subject to normal recent domain and similarity checks.
*
* @example
* ```ts
* const trustedDomain =
* await client.emailSecurity.settings.trustedDomains.delete(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(trustedDomainID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/email-security/settings/trusted_domains/${trustedDomainID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Executes multiple trusted domain operations atomically: delete, partially
* update, replace, and create trusted domain 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.trustedDomains.batch({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* deletes: [
* { id: 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415' },
* ],
* patches: [{}],
* posts: [
* {
* is_recent: true,
* is_regex: false,
* is_similarity: false,
* pattern: 'example.com',
* },
* ],
* puts: [
* {
* is_recent: true,
* is_regex: false,
* is_similarity: false,
* pattern: 'example.com',
* },
* ],
* });
* ```
*/
batch(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/email-security/settings/trusted_domains/batch`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Updates an existing trusted domain pattern. Only provided fields will be
* modified. Changes take effect for new emails matching the pattern.
*
* @example
* ```ts
* const response =
* await client.emailSecurity.settings.trustedDomains.edit(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(trustedDomainID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/email-security/settings/trusted_domains/${trustedDomainID}`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Retrieves details for a specific trusted domain pattern including its pattern
* value, whether it uses regex matching, and which detection types it affects.
*
* @example
* ```ts
* const trustedDomain =
* await client.emailSecurity.settings.trustedDomains.get(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(trustedDomainID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/email-security/settings/trusted_domains/${trustedDomainID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseTrustedDomains._key = Object.freeze([
'emailSecurity',
'settings',
'trustedDomains',
]);
return BaseTrustedDomains;
})();
exports.BaseTrustedDomains = BaseTrustedDomains;
class TrustedDomains extends BaseTrustedDomains {
}
exports.TrustedDomains = TrustedDomains;
//# sourceMappingURL=trusted-domains.js.map