cloudflare
Version:
The official TypeScript library for the Cloudflare API
167 lines • 7.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AIGateway = exports.BaseAIGateway = 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 CustomProvidersAPI = tslib_1.__importStar(require("./custom-providers.js"));
const custom_providers_1 = require("./custom-providers.js");
const DatasetsAPI = tslib_1.__importStar(require("./datasets.js"));
const datasets_1 = require("./datasets.js");
const DynamicRoutingAPI = tslib_1.__importStar(require("./dynamic-routing.js"));
const dynamic_routing_1 = require("./dynamic-routing.js");
const EvaluationTypesAPI = tslib_1.__importStar(require("./evaluation-types.js"));
const evaluation_types_1 = require("./evaluation-types.js");
const EvaluationsAPI = tslib_1.__importStar(require("./evaluations.js"));
const evaluations_1 = require("./evaluations.js");
const LogsAPI = tslib_1.__importStar(require("./logs.js"));
const logs_1 = require("./logs.js");
const ProviderConfigsAPI = tslib_1.__importStar(require("./provider-configs.js"));
const provider_configs_1 = require("./provider-configs.js");
const URLsAPI = tslib_1.__importStar(require("./urls.js"));
const urls_1 = require("./urls.js");
const BillingAPI = tslib_1.__importStar(require("./billing/billing.js"));
const billing_1 = require("./billing/billing.js");
const pagination_1 = require("../../core/pagination.js");
const path_1 = require("../../internal/utils/path.js");
var BaseAIGateway = /* @__PURE__ */ (() => {
class BaseAIGateway extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/ai-gateway/gateways`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/ai-gateway/gateways/${id}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseAIGateway._key = Object.freeze(['aiGateway']);
return BaseAIGateway;
})();
exports.BaseAIGateway = BaseAIGateway;
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 = evaluation_types_1.EvaluationTypes;
AIGateway.BaseEvaluationTypes = evaluation_types_1.BaseEvaluationTypes;
AIGateway.CustomProviders = custom_providers_1.CustomProviders;
AIGateway.BaseCustomProviders = custom_providers_1.BaseCustomProviders;
AIGateway.Logs = logs_1.Logs;
AIGateway.BaseLogs = logs_1.BaseLogs;
AIGateway.Datasets = datasets_1.Datasets;
AIGateway.BaseDatasets = datasets_1.BaseDatasets;
AIGateway.Evaluations = evaluations_1.Evaluations;
AIGateway.BaseEvaluations = evaluations_1.BaseEvaluations;
AIGateway.DynamicRouting = dynamic_routing_1.DynamicRouting;
AIGateway.BaseDynamicRouting = dynamic_routing_1.BaseDynamicRouting;
AIGateway.ProviderConfigs = provider_configs_1.ProviderConfigs;
AIGateway.BaseProviderConfigs = provider_configs_1.BaseProviderConfigs;
AIGateway.URLs = urls_1.URLs;
AIGateway.BaseURLs = urls_1.BaseURLs;
AIGateway.Billing = billing_1.Billing;
AIGateway.BaseBilling = billing_1.BaseBilling;
return AIGateway;
})();
exports.AIGateway = AIGateway;
//# sourceMappingURL=ai-gateway.js.map