UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

132 lines • 4.85 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { V4PagePaginationArray } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseDatasets = /* @__PURE__ */ (() => { class BaseDatasets extends APIResource { /** * Creates a dataset that selects gateway logs matching the specified filters for * use in evaluations. Evaluations and datasets are deprecated and unavailable to * new accounts. * * @example * ```ts * const dataset = await client.aiGateway.datasets.create( * 'my-gateway', * { * account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', * enable: true, * filters: [ * { * key: 'created_at', * operator: 'eq', * value: ['string'], * }, * ], * name: 'name', * }, * ); * ``` */ create(gatewayID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/ai-gateway/gateways/${gatewayID}/datasets`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Replaces the name, log filters, and enabled state of a dataset. Evaluations and * datasets are deprecated and unavailable to new accounts. * * @example * ```ts * const dataset = await client.aiGateway.datasets.update( * 'id', * { * account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', * gateway_id: 'my-gateway', * enable: true, * filters: [ * { * key: 'created_at', * operator: 'eq', * value: ['string'], * }, * ], * name: 'name', * }, * ); * ``` */ update(id, params, options) { const { account_id, gateway_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/datasets/${id}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists the datasets defined for an AI Gateway. Evaluations and datasets are * deprecated and unavailable to new accounts. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const datasetListResponse of client.aiGateway.datasets.list( * 'my-gateway', * { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' }, * )) { * // ... * } * ``` */ list(gatewayID, params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/ai-gateway/gateways/${gatewayID}/datasets`, (V4PagePaginationArray), { query, ...options }); } /** * Deletes a dataset. Evaluations and datasets are deprecated and unavailable to * new accounts. * * @example * ```ts * const dataset = await client.aiGateway.datasets.delete( * 'id', * { * account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', * gateway_id: 'my-gateway', * }, * ); * ``` */ delete(id, params, options) { const { account_id, gateway_id } = params; return this._client.delete(path `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/datasets/${id}`, options)._thenUnwrap((obj) => obj.result); } /** * Retrieves a dataset and its log filters. Evaluations and datasets are deprecated * and unavailable to new accounts. * * @example * ```ts * const dataset = await client.aiGateway.datasets.get('id', { * account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', * gateway_id: 'my-gateway', * }); * ``` */ get(id, params, options) { const { account_id, gateway_id } = params; return this._client.get(path `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/datasets/${id}`, options)._thenUnwrap((obj) => obj.result); } } BaseDatasets._key = Object.freeze([ 'aiGateway', 'datasets', ]); return BaseDatasets; })(); export class Datasets extends BaseDatasets { } //# sourceMappingURL=datasets.mjs.map