UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

161 lines • 6.83 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import * as CustomProvidersAPI from "./custom-providers.mjs"; import { BaseCustomProviders, CustomProviders, } from "./custom-providers.mjs"; import * as DatasetsAPI from "./datasets.mjs"; import { BaseDatasets, Datasets, } from "./datasets.mjs"; import * as DynamicRoutingAPI from "./dynamic-routing.mjs"; import { BaseDynamicRouting, DynamicRouting, } from "./dynamic-routing.mjs"; import * as EvaluationTypesAPI from "./evaluation-types.mjs"; import { BaseEvaluationTypes, EvaluationTypes, } from "./evaluation-types.mjs"; import * as EvaluationsAPI from "./evaluations.mjs"; import { BaseEvaluations, Evaluations, } from "./evaluations.mjs"; import * as LogsAPI from "./logs.mjs"; import { BaseLogs, Logs, } from "./logs.mjs"; import * as ProviderConfigsAPI from "./provider-configs.mjs"; import { BaseProviderConfigs, ProviderConfigs, } from "./provider-configs.mjs"; import * as URLsAPI from "./urls.mjs"; import { BaseURLs, URLs } from "./urls.mjs"; import * as BillingAPI from "./billing/billing.mjs"; import { BaseBilling, Billing, } from "./billing/billing.mjs"; import { V4PagePaginationArray } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseAIGateway = /* @__PURE__ */ (() => { class BaseAIGateway extends APIResource { /** * Creates an AI Gateway in the account with the specified caching, rate limiting, * logging, and authentication settings. The gateway ID appears in request URLs and * must be unique within the account. * * @example * ```ts * const aiGateway = await client.aiGateway.create({ * account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', * id: 'my-gateway', * cache_invalidate_on_update: true, * cache_ttl: 0, * collect_logs: true, * rate_limiting_interval: 0, * rate_limiting_limit: 0, * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/ai-gateway/gateways`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Updates the configuration of an AI Gateway, such as its caching, rate limiting, * logging, and authentication settings. * * @example * ```ts * const aiGateway = await client.aiGateway.update( * 'my-gateway', * { * account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', * cache_invalidate_on_update: true, * cache_ttl: 0, * collect_logs: true, * rate_limiting_interval: 0, * rate_limiting_limit: 0, * }, * ); * ``` */ update(id, params, options) { const { account_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/ai-gateway/gateways/${id}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists the AI Gateways in the account. Use `search` to filter by gateway ID. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const aiGatewayListResponse of client.aiGateway.list( * { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/ai-gateway/gateways`, (V4PagePaginationArray), { query, ...options }); } /** * Permanently deletes an AI Gateway, its configuration, and its stored logs. * * @example * ```ts * const aiGateway = await client.aiGateway.delete( * 'my-gateway', * { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' }, * ); * ``` */ delete(id, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/ai-gateway/gateways/${id}`, options)._thenUnwrap((obj) => obj.result); } /** * Retrieves the configuration of an AI Gateway. * * @example * ```ts * const aiGateway = await client.aiGateway.get('my-gateway', { * account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', * }); * ``` */ get(id, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/ai-gateway/gateways/${id}`, options)._thenUnwrap((obj) => obj.result); } } BaseAIGateway._key = Object.freeze(['aiGateway']); return BaseAIGateway; })(); export var AIGateway = /* @__PURE__ */ (() => { class AIGateway extends BaseAIGateway { constructor() { super(...arguments); this.evaluationTypes = new EvaluationTypesAPI.EvaluationTypes(this._client); this.customProviders = new CustomProvidersAPI.CustomProviders(this._client); this.logs = new LogsAPI.Logs(this._client); this.datasets = new DatasetsAPI.Datasets(this._client); this.evaluations = new EvaluationsAPI.Evaluations(this._client); this.dynamicRouting = new DynamicRoutingAPI.DynamicRouting(this._client); this.providerConfigs = new ProviderConfigsAPI.ProviderConfigs(this._client); this.urls = new URLsAPI.URLs(this._client); this.billing = new BillingAPI.Billing(this._client); } } AIGateway.EvaluationTypes = EvaluationTypes; AIGateway.BaseEvaluationTypes = BaseEvaluationTypes; AIGateway.CustomProviders = CustomProviders; AIGateway.BaseCustomProviders = BaseCustomProviders; AIGateway.Logs = Logs; AIGateway.BaseLogs = BaseLogs; AIGateway.Datasets = Datasets; AIGateway.BaseDatasets = BaseDatasets; AIGateway.Evaluations = Evaluations; AIGateway.BaseEvaluations = BaseEvaluations; AIGateway.DynamicRouting = DynamicRouting; AIGateway.BaseDynamicRouting = BaseDynamicRouting; AIGateway.ProviderConfigs = ProviderConfigs; AIGateway.BaseProviderConfigs = BaseProviderConfigs; AIGateway.URLs = URLs; AIGateway.BaseURLs = BaseURLs; AIGateway.Billing = Billing; AIGateway.BaseBilling = BaseBilling; return AIGateway; })(); //# sourceMappingURL=ai-gateway.mjs.map