UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

561 lines • 16.7 kB
import { APIResource } from "../../../core/resource.mjs"; import { APIPromise } from "../../../core/api-promise.mjs"; import { PagePromise, V4PagePaginationArray, type V4PagePaginationArrayParams } from "../../../core/pagination.mjs"; import { RequestOptions } from "../../../internal/request-options.mjs"; export declare class BaseContentPolicies extends APIResource { static readonly _key: readonly ['emailSecurity', 'settings', 'contentPolicies']; /** * 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: ContentPolicyCreateParams, options?: RequestOptions): APIPromise<ContentPolicyCreateResponse>; /** * 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: ContentPolicyListParams, options?: RequestOptions): PagePromise<ContentPolicyListResponsesV4PagePaginationArray, ContentPolicyListResponse>; /** * 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: string, params: ContentPolicyDeleteParams, options?: RequestOptions): APIPromise<ContentPolicyDeleteResponse>; /** * 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: ContentPolicyBatchParams, options?: RequestOptions): APIPromise<ContentPolicyBatchResponse>; /** * 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: string, params: ContentPolicyEditParams, options?: RequestOptions): APIPromise<ContentPolicyEditResponse>; /** * 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: string, params: ContentPolicyGetParams, options?: RequestOptions): APIPromise<ContentPolicyGetResponse>; } export declare class ContentPolicies extends BaseContentPolicies { } export type ContentPolicyListResponsesV4PagePaginationArray = V4PagePaginationArray<ContentPolicyListResponse>; /** * A content policy pattern that matches against the subject or body of an email. */ export interface ContentPolicyCreateResponse { /** * Content policy identifier. */ id?: string; created_at?: string; /** * Whether the policy is active. */ enabled?: boolean; modified_at?: string; /** * Human-readable name of the policy. */ name?: string; /** * Optional note describing the purpose of the policy. */ notes?: string | null; /** * Regular expression the policy matches against. */ pattern?: string; /** * Parts of the email the pattern is matched against. */ targets?: Array<'SUBJECT' | 'BODY'>; } /** * A content policy pattern that matches against the subject or body of an email. */ export interface ContentPolicyListResponse { /** * Content policy identifier. */ id?: string; created_at?: string; /** * Whether the policy is active. */ enabled?: boolean; modified_at?: string; /** * Human-readable name of the policy. */ name?: string; /** * Optional note describing the purpose of the policy. */ notes?: string | null; /** * Regular expression the policy matches against. */ pattern?: string; /** * Parts of the email the pattern is matched against. */ targets?: Array<'SUBJECT' | 'BODY'>; } export interface ContentPolicyDeleteResponse { /** * Content policy identifier. */ id: string; } export interface ContentPolicyBatchResponse { deletes?: Array<ContentPolicyBatchResponse.Delete>; patches?: Array<ContentPolicyBatchResponse.Patch>; posts?: Array<ContentPolicyBatchResponse.Post>; puts?: Array<ContentPolicyBatchResponse.Put>; } export declare namespace ContentPolicyBatchResponse { interface Delete { /** * Content policy identifier. */ id: string; } /** * A content policy pattern that matches against the subject or body of an email. */ interface Patch { /** * Content policy identifier. */ id?: string; created_at?: string; /** * Whether the policy is active. */ enabled?: boolean; modified_at?: string; /** * Human-readable name of the policy. */ name?: string; /** * Optional note describing the purpose of the policy. */ notes?: string | null; /** * Regular expression the policy matches against. */ pattern?: string; /** * Parts of the email the pattern is matched against. */ targets?: Array<'SUBJECT' | 'BODY'>; } /** * A content policy pattern that matches against the subject or body of an email. */ interface Post { /** * Content policy identifier. */ id?: string; created_at?: string; /** * Whether the policy is active. */ enabled?: boolean; modified_at?: string; /** * Human-readable name of the policy. */ name?: string; /** * Optional note describing the purpose of the policy. */ notes?: string | null; /** * Regular expression the policy matches against. */ pattern?: string; /** * Parts of the email the pattern is matched against. */ targets?: Array<'SUBJECT' | 'BODY'>; } /** * A content policy pattern that matches against the subject or body of an email. */ interface Put { /** * Content policy identifier. */ id?: string; created_at?: string; /** * Whether the policy is active. */ enabled?: boolean; modified_at?: string; /** * Human-readable name of the policy. */ name?: string; /** * Optional note describing the purpose of the policy. */ notes?: string | null; /** * Regular expression the policy matches against. */ pattern?: string; /** * Parts of the email the pattern is matched against. */ targets?: Array<'SUBJECT' | 'BODY'>; } } /** * A content policy pattern that matches against the subject or body of an email. */ export interface ContentPolicyEditResponse { /** * Content policy identifier. */ id?: string; created_at?: string; /** * Whether the policy is active. */ enabled?: boolean; modified_at?: string; /** * Human-readable name of the policy. */ name?: string; /** * Optional note describing the purpose of the policy. */ notes?: string | null; /** * Regular expression the policy matches against. */ pattern?: string; /** * Parts of the email the pattern is matched against. */ targets?: Array<'SUBJECT' | 'BODY'>; } /** * A content policy pattern that matches against the subject or body of an email. */ export interface ContentPolicyGetResponse { /** * Content policy identifier. */ id?: string; created_at?: string; /** * Whether the policy is active. */ enabled?: boolean; modified_at?: string; /** * Human-readable name of the policy. */ name?: string; /** * Optional note describing the purpose of the policy. */ notes?: string | null; /** * Regular expression the policy matches against. */ pattern?: string; /** * Parts of the email the pattern is matched against. */ targets?: Array<'SUBJECT' | 'BODY'>; } export interface ContentPolicyCreateParams { /** * Path param: Account identifier tag. */ account_id: string; /** * Body param: Whether the policy is active. */ enabled: boolean; /** * Body param: Human-readable name of the policy. */ name: string; /** * Body param: Regular expression the policy matches against. */ pattern: string; /** * Body param: Parts of the email the pattern is matched against. */ targets: Array<'SUBJECT' | 'BODY'>; /** * Body param: Optional note describing the purpose of the policy. */ notes?: string | null; } export interface ContentPolicyListParams extends V4PagePaginationArrayParams { /** * Path param: Account identifier tag. */ account_id: string; /** * Query param: The sorting direction. */ direction?: 'asc' | 'desc'; /** * Query param: Filter by enabled status. */ enabled?: boolean; /** * Query param: Filter by exact policy name. */ name?: string; /** * Query param: Field to sort by. */ order?: 'name' | 'created_at'; /** * Query param: Search term for filtering records. Behavior may change. */ search?: string; } export interface ContentPolicyDeleteParams { /** * Account identifier tag. */ account_id: string; } export interface ContentPolicyBatchParams { /** * Path param: Account identifier tag. */ account_id: string; /** * Body param: IDs of the content policies to delete. */ deletes: Array<ContentPolicyBatchParams.Delete>; /** * Body param: Partial updates to apply — each entry carries the policy's ID and * only the fields to change. */ patches: Array<ContentPolicyBatchParams.Patch>; /** * Body param: Content policies to create. */ posts: Array<ContentPolicyBatchParams.Post>; /** * Body param: Full replacements to apply — each entry carries the policy's ID and * every field of its new value. */ puts: Array<ContentPolicyBatchParams.Put>; } export declare namespace ContentPolicyBatchParams { interface Delete { /** * Content policy identifier. */ id: string; } /** * A content policy pattern that matches against the subject or body of an email. */ interface Patch { /** * Whether the policy is active. */ enabled?: boolean; /** * Human-readable name of the policy. */ name?: string; /** * Optional note describing the purpose of the policy. */ notes?: string | null; /** * Regular expression the policy matches against. */ pattern?: string; /** * Parts of the email the pattern is matched against. */ targets?: Array<'SUBJECT' | 'BODY'>; } /** * Create a content policy. */ interface Post { /** * Whether the policy is active. */ enabled: boolean; /** * Human-readable name of the policy. */ name: string; /** * Regular expression the policy matches against. */ pattern: string; /** * Parts of the email the pattern is matched against. */ targets: Array<'SUBJECT' | 'BODY'>; /** * Optional note describing the purpose of the policy. */ notes?: string | null; } /** * A content policy pattern that matches against the subject or body of an email. */ interface Put { /** * Whether the policy is active. */ enabled: boolean; /** * Human-readable name of the policy. */ name: string; /** * Regular expression the policy matches against. */ pattern: string; /** * Parts of the email the pattern is matched against. */ targets: Array<'SUBJECT' | 'BODY'>; /** * Optional note describing the purpose of the policy. */ notes?: string | null; } } export interface ContentPolicyEditParams { /** * Path param: Account identifier tag. */ account_id: string; /** * Body param: Whether the policy is active. */ enabled?: boolean; /** * Body param: Human-readable name of the policy. */ name?: string; /** * Body param: Optional note describing the purpose of the policy. */ notes?: string | null; /** * Body param: Regular expression the policy matches against. */ pattern?: string; /** * Body param: Parts of the email the pattern is matched against. */ targets?: Array<'SUBJECT' | 'BODY'>; } export interface ContentPolicyGetParams { /** * Account identifier tag. */ account_id: string; } export declare namespace ContentPolicies { export { type ContentPolicyCreateResponse as ContentPolicyCreateResponse, type ContentPolicyListResponse as ContentPolicyListResponse, type ContentPolicyDeleteResponse as ContentPolicyDeleteResponse, type ContentPolicyBatchResponse as ContentPolicyBatchResponse, type ContentPolicyEditResponse as ContentPolicyEditResponse, type ContentPolicyGetResponse as ContentPolicyGetResponse, type ContentPolicyListResponsesV4PagePaginationArray as ContentPolicyListResponsesV4PagePaginationArray, type ContentPolicyCreateParams as ContentPolicyCreateParams, type ContentPolicyListParams as ContentPolicyListParams, type ContentPolicyDeleteParams as ContentPolicyDeleteParams, type ContentPolicyBatchParams as ContentPolicyBatchParams, type ContentPolicyEditParams as ContentPolicyEditParams, type ContentPolicyGetParams as ContentPolicyGetParams, }; } //# sourceMappingURL=content-policies.d.mts.map