cloudflare
Version:
The official TypeScript library for the Cloudflare API
137 lines • 5.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Datasets = exports.BaseDatasets = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../core/resource.js");
const pagination_1 = require("../../core/pagination.js");
const path_1 = require("../../internal/utils/path.js");
var BaseDatasets = /* @__PURE__ */ (() => {
class BaseDatasets extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/ai-gateway/gateways/${gatewayID}/datasets`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/ai-gateway/gateways/${gateway_id}/datasets/${id}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseDatasets._key = Object.freeze([
'aiGateway',
'datasets',
]);
return BaseDatasets;
})();
exports.BaseDatasets = BaseDatasets;
class Datasets extends BaseDatasets {
}
exports.Datasets = Datasets;
//# sourceMappingURL=datasets.js.map