cloudflare
Version:
The official TypeScript library for the Cloudflare API
162 lines • 6.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContentPolicies = exports.BaseContentPolicies = 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 BaseContentPolicies = /* @__PURE__ */ (() => {
class BaseContentPolicies extends resource_1.APIResource {
/**
* Creates a new content policy. Emails whose subject or body matches the pattern
* will be subject to the configured action.
*
* @example
* ```ts
* const contentPolicy =
* await client.emailSecurity.settings.contentPolicies.create(
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* enabled: true,
* name: 'Block phishing keywords',
* pattern: 'urgent.*verify.*account',
* targets: ['SUBJECT'],
* },
* );
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/email-security/settings/content_policies`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns a paginated list of content policies. These policies match against the
* subject or body of emails using a pattern. Supports filtering by name or enabled
* status, and searching across name and pattern fields.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const contentPolicyListResponse of client.emailSecurity.settings.contentPolicies.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/content_policies`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Removes a content policy. After deletion, emails will no longer be evaluated
* against this pattern.
*
* @example
* ```ts
* const contentPolicy =
* await client.emailSecurity.settings.contentPolicies.delete(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(policyID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/email-security/settings/content_policies/${policyID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Executes multiple content policy operations atomically: delete, partially
* update, replace, and create content 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.contentPolicies.batch(
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* deletes: [
* { id: 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415' },
* ],
* patches: [{}],
* posts: [
* {
* enabled: true,
* name: 'Block phishing keywords',
* pattern: 'urgent.*verify.*account',
* targets: ['SUBJECT'],
* },
* ],
* puts: [
* {
* enabled: true,
* name: 'Block phishing keywords',
* pattern: 'urgent.*verify.*account',
* targets: ['SUBJECT'],
* },
* ],
* },
* );
* ```
*/
batch(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/email-security/settings/content_policies/batch`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Updates an existing content policy. Only provided fields will be modified.
*
* @example
* ```ts
* const response =
* await client.emailSecurity.settings.contentPolicies.edit(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(policyID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/email-security/settings/content_policies/${policyID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Retrieves details for a specific content policy including its pattern, targets,
* and metadata.
*
* @example
* ```ts
* const contentPolicy =
* await client.emailSecurity.settings.contentPolicies.get(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(policyID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/email-security/settings/content_policies/${policyID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseContentPolicies._key = Object.freeze([
'emailSecurity',
'settings',
'contentPolicies',
]);
return BaseContentPolicies;
})();
exports.BaseContentPolicies = BaseContentPolicies;
class ContentPolicies extends BaseContentPolicies {
}
exports.ContentPolicies = ContentPolicies;
//# sourceMappingURL=content-policies.js.map