UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

406 lines • 12.9 kB
import { APIResource } from "../../../core/resource.js"; import * as ContentAPI from "./content.js"; import { BaseContent, Content, ContentGetParams, ContentGetResponse } from "./content.js"; import * as VersionsAPI from "./versions.js"; import { BaseVersions, VersionListParams, VersionListResponse, VersionListResponsesSinglePage, Versions } from "./versions.js"; import { APIPromise } from "../../../core/api-promise.js"; import { PagePromise, SinglePage } from "../../../core/pagination.js"; import { RequestOptions } from "../../../internal/request-options.js"; export declare class BaseTransformers extends APIResource { static readonly _key: readonly ['logpush', 'transformers']; /** * Creates a new custom log transformer for an account. * * @example * ```ts * const transformer = * await client.logpush.transformers.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * code: 'SELECT ClientIP, RayID FROM http_requests', * name: 'redact-pii', * }); * ``` */ create(params: TransformerCreateParams, options?: RequestOptions): APIPromise<TransformerCreateResponse>; /** * Updates an existing custom log transformer. When `code` is provided, the SQL * query is validated and a new version is created. When `code` is omitted, only * the name and description are updated. Omitting `description` clears the existing * description. * * @example * ```ts * const transformer = * await client.logpush.transformers.update(42, { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * name: 'redact-pii', * }); * ``` */ update(transformerID: number, params: TransformerUpdateParams, options?: RequestOptions): APIPromise<TransformerUpdateResponse>; /** * Lists all custom log transformers for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const transformerListResponse of client.logpush.transformers.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params: TransformerListParams, options?: RequestOptions): PagePromise<TransformerListResponsesSinglePage, TransformerListResponse>; /** * Deletes a custom log transformer. Returns 409 Conflict if any active logpush * jobs reference the transformer. * * @example * ```ts * const transformer = * await client.logpush.transformers.delete(42, { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ delete(transformerID: number, params: TransformerDeleteParams, options?: RequestOptions): APIPromise<TransformerDeleteResponse>; /** * Gets a single custom log transformer by ID. * * @example * ```ts * const transformer = await client.logpush.transformers.get( * 42, * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(transformerID: number, params: TransformerGetParams, options?: RequestOptions): APIPromise<TransformerGetResponse>; /** * Executes a SQL transformer against a single input record and returns the * transformed output. This is a stateless endpoint — nothing is persisted. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const transformerPreviewResponse of client.logpush.transformers.preview( * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * input: { * ClientIP: 'bar', * ClientRequestHost: 'bar', * EdgeStartTimestamp: 'bar', * RayID: 'bar', * }, * sql: 'SELECT ClientIP, RayID FROM http_requests', * }, * )) { * // ... * } * ``` */ preview(params: TransformerPreviewParams, options?: RequestOptions): PagePromise<TransformerPreviewResponsesSinglePage, TransformerPreviewResponse>; } export declare class Transformers extends BaseTransformers { content: ContentAPI.Content; versions: VersionsAPI.Versions; } export type TransformerListResponsesSinglePage = SinglePage<TransformerListResponse>; export type TransformerPreviewResponsesSinglePage = SinglePage<TransformerPreviewResponse>; export interface TransformerCreateResponse { /** * The transformer ID. */ id?: number; /** * Logpush jobs that reference this transformer. */ associated_jobs?: Array<TransformerCreateResponse.AssociatedJob>; /** * When the transformer was created (RFC 3339). */ created_at?: string; /** * The dataset this transformer operates on, derived from the SQL query's FROM * clause. Informational only. May be absent if the dataset cannot be determined * from the query. */ dataset?: string | null; /** * Optional customer-provided description. */ description?: string; /** * Customer-provided name for identification. */ name?: string; /** * When the transformer was last modified (RFC 3339). */ updated_at?: string; } export declare namespace TransformerCreateResponse { interface AssociatedJob { /** * The logpush job ID. */ id?: number; /** * The logpush job destination name. */ name?: string; /** * The zone or account tag. */ object_tag?: string; /** * Whether the job is zone-scoped or account-scoped. */ object_type?: 'zone' | 'account'; } } export interface TransformerUpdateResponse { /** * The transformer ID. */ id?: number; /** * Logpush jobs that reference this transformer. */ associated_jobs?: Array<TransformerUpdateResponse.AssociatedJob>; /** * When the transformer was created (RFC 3339). */ created_at?: string; /** * The dataset this transformer operates on, derived from the SQL query's FROM * clause. Informational only. May be absent if the dataset cannot be determined * from the query. */ dataset?: string | null; /** * Optional customer-provided description. */ description?: string; /** * Customer-provided name for identification. */ name?: string; /** * When the transformer was last modified (RFC 3339). */ updated_at?: string; } export declare namespace TransformerUpdateResponse { interface AssociatedJob { /** * The logpush job ID. */ id?: number; /** * The logpush job destination name. */ name?: string; /** * The zone or account tag. */ object_tag?: string; /** * Whether the job is zone-scoped or account-scoped. */ object_type?: 'zone' | 'account'; } } export interface TransformerListResponse { /** * The transformer ID. */ id?: number; /** * Logpush jobs that reference this transformer. */ associated_jobs?: Array<TransformerListResponse.AssociatedJob>; /** * When the transformer was created (RFC 3339). */ created_at?: string; /** * The dataset this transformer operates on, derived from the SQL query's FROM * clause. Informational only. May be absent if the dataset cannot be determined * from the query. */ dataset?: string | null; /** * Optional customer-provided description. */ description?: string; /** * Customer-provided name for identification. */ name?: string; /** * When the transformer was last modified (RFC 3339). */ updated_at?: string; } export declare namespace TransformerListResponse { interface AssociatedJob { /** * The logpush job ID. */ id?: number; /** * The logpush job destination name. */ name?: string; /** * The zone or account tag. */ object_tag?: string; /** * Whether the job is zone-scoped or account-scoped. */ object_type?: 'zone' | 'account'; } } export interface TransformerDeleteResponse { /** * The deleted transformer's ID. */ id?: number; } export interface TransformerGetResponse { /** * The transformer ID. */ id?: number; /** * Logpush jobs that reference this transformer. */ associated_jobs?: Array<TransformerGetResponse.AssociatedJob>; /** * When the transformer was created (RFC 3339). */ created_at?: string; /** * The dataset this transformer operates on, derived from the SQL query's FROM * clause. Informational only. May be absent if the dataset cannot be determined * from the query. */ dataset?: string | null; /** * Optional customer-provided description. */ description?: string; /** * Customer-provided name for identification. */ name?: string; /** * When the transformer was last modified (RFC 3339). */ updated_at?: string; } export declare namespace TransformerGetResponse { interface AssociatedJob { /** * The logpush job ID. */ id?: number; /** * The logpush job destination name. */ name?: string; /** * The zone or account tag. */ object_tag?: string; /** * Whether the job is zone-scoped or account-scoped. */ object_type?: 'zone' | 'account'; } } export type TransformerPreviewResponse = { [key: string]: unknown; }; export interface TransformerCreateParams { /** * Path param: Identifier. */ account_id: string; /** * Body param: The SQL transformer query. Maximum 32 KB. The query must contain a * FROM clause referencing a valid logpush dataset. */ code: string; /** * Body param: Customer-provided name for identification. */ name: string; /** * Body param: Optional customer-provided description. */ description?: string; } export interface TransformerUpdateParams { /** * Path param: Identifier. */ account_id: string; /** * Body param: Customer-provided name for identification. */ name: string; /** * Body param: The SQL transformer query. Maximum 32 KB. The query must contain a * FROM clause referencing a valid logpush dataset. */ code?: string; /** * Body param: Optional customer-provided description. */ description?: string; } export interface TransformerListParams { /** * Identifier. */ account_id: string; } export interface TransformerDeleteParams { /** * Identifier. */ account_id: string; } export interface TransformerGetParams { /** * Identifier. */ account_id: string; } export interface TransformerPreviewParams { /** * Path param: Identifier. */ account_id: string; /** * Body param: A single log record to transform (JSON object). */ input: { [key: string]: unknown; }; /** * Body param: The SQL transformer query. Maximum 32 KB. The query must contain a * FROM clause referencing a valid logpush dataset. */ sql: string; } export declare namespace Transformers { export { type TransformerCreateResponse as TransformerCreateResponse, type TransformerUpdateResponse as TransformerUpdateResponse, type TransformerListResponse as TransformerListResponse, type TransformerDeleteResponse as TransformerDeleteResponse, type TransformerGetResponse as TransformerGetResponse, type TransformerPreviewResponse as TransformerPreviewResponse, type TransformerListResponsesSinglePage as TransformerListResponsesSinglePage, type TransformerPreviewResponsesSinglePage as TransformerPreviewResponsesSinglePage, type TransformerCreateParams as TransformerCreateParams, type TransformerUpdateParams as TransformerUpdateParams, type TransformerListParams as TransformerListParams, type TransformerDeleteParams as TransformerDeleteParams, type TransformerGetParams as TransformerGetParams, type TransformerPreviewParams as TransformerPreviewParams, }; export { Content as Content, BaseContent as BaseContent, type ContentGetResponse as ContentGetResponse, type ContentGetParams as ContentGetParams, }; export { Versions as Versions, BaseVersions as BaseVersions, type VersionListResponse as VersionListResponse, type VersionListResponsesSinglePage as VersionListResponsesSinglePage, type VersionListParams as VersionListParams, }; } //# sourceMappingURL=transformers.d.ts.map