cloudflare
Version:
The official TypeScript library for the Cloudflare API
155 lines • 6.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Transformers = exports.BaseTransformers = void 0;
const tslib_1 = require("../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const ContentAPI = tslib_1.__importStar(require("./content.js"));
const content_1 = require("./content.js");
const VersionsAPI = tslib_1.__importStar(require("./versions.js"));
const versions_1 = require("./versions.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseTransformers = /* @__PURE__ */ (() => {
class BaseTransformers extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/logpush/transformers`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/logpush/transformers/preview`, (pagination_1.SinglePage), { body, method: 'post', ...options });
}
}
BaseTransformers._key = Object.freeze([
'logpush',
'transformers',
]);
return BaseTransformers;
})();
exports.BaseTransformers = BaseTransformers;
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_1.Content;
Transformers.BaseContent = content_1.BaseContent;
Transformers.Versions = versions_1.Versions;
Transformers.BaseVersions = versions_1.BaseVersions;
return Transformers;
})();
exports.Transformers = Transformers;
//# sourceMappingURL=transformers.js.map