cloudflare
Version:
The official TypeScript library for the Cloudflare API
94 lines • 3.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomProviders = exports.BaseCustomProviders = 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 BaseCustomProviders = /* @__PURE__ */ (() => {
class BaseCustomProviders extends resource_1.APIResource {
/**
* Creates an account-level custom provider that forwards AI Gateway requests to
* the HTTPS base URL you supply. Requests reference the provider as
* `custom-{slug}`, so the slug must be unique within the account.
*
* @example
* ```ts
* const customProvider =
* await client.aiGateway.customProviders.create({
* account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
* base_url: 'https://example.com',
* name: 'name',
* slug: 'slug',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/ai-gateway/custom-providers`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists the custom providers configured for the account, ordered by position and
* then name.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const customProviderListResponse of client.aiGateway.customProviders.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/custom-providers`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Deletes a custom provider and every pricing rule that belongs to it.
*
* @example
* ```ts
* const customProvider =
* await client.aiGateway.customProviders.delete(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' },
* );
* ```
*/
delete(id, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/ai-gateway/custom-providers/${id}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Retrieves a custom provider, including its slug, base URL, and custom headers.
*
* @example
* ```ts
* const customProvider =
* await client.aiGateway.customProviders.get(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' },
* );
* ```
*/
get(id, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/ai-gateway/custom-providers/${id}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseCustomProviders._key = Object.freeze([
'aiGateway',
'customProviders',
]);
return BaseCustomProviders;
})();
exports.BaseCustomProviders = BaseCustomProviders;
class CustomProviders extends BaseCustomProviders {
}
exports.CustomProviders = CustomProviders;
//# sourceMappingURL=custom-providers.js.map