UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

149 lines • 5.74 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as ContentAPI from "./content.mjs"; import { BaseContent, Content } from "./content.mjs"; import * as VersionsAPI from "./versions.mjs"; import { BaseVersions, Versions, } from "./versions.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseTransformers = /* @__PURE__ */ (() => { class BaseTransformers extends APIResource { /** * 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, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/logpush/transformers`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * 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, params, options) { const { account_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/logpush/transformers/${transformerID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * 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, options) { const { account_id } = params; return this._client.getAPIList(path `/accounts/${account_id}/logpush/transformers`, (SinglePage), options); } /** * 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, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/logpush/transformers/${transformerID}`, options)._thenUnwrap((obj) => obj.result); } /** * Gets a single custom log transformer by ID. * * @example * ```ts * const transformer = await client.logpush.transformers.get( * 42, * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(transformerID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/logpush/transformers/${transformerID}`, options)._thenUnwrap((obj) => obj.result); } /** * 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, options) { const { account_id, ...body } = params; return this._client.getAPIList(path `/accounts/${account_id}/logpush/transformers/preview`, (SinglePage), { body, method: 'post', ...options }); } } BaseTransformers._key = Object.freeze([ 'logpush', 'transformers', ]); return BaseTransformers; })(); export var Transformers = /* @__PURE__ */ (() => { class Transformers extends BaseTransformers { constructor() { super(...arguments); this.content = new ContentAPI.Content(this._client); this.versions = new VersionsAPI.Versions(this._client); } } Transformers.Content = Content; Transformers.BaseContent = BaseContent; Transformers.Versions = Versions; Transformers.BaseVersions = BaseVersions; return Transformers; })(); //# sourceMappingURL=transformers.mjs.map