diff --git a/api.md b/api.md index 073c7cc7fb..a36faf5c79 100644 --- a/api.md +++ b/api.md @@ -2268,39 +2268,11 @@ Types: Types: -- AIRunResponse +- AIRunResponse Methods: -- client.workers.ai.run(modelName, { ...params }) -> AIRunResponse - -### Gateways - -Types: - -- GatewayCreateResponse -- GatewayUpdateResponse -- GatewayListResponse -- GatewayDeleteResponse -- GatewayGetResponse - -Methods: - -- client.workers.ai.gateways.create(accountTag, { ...params }) -> GatewayCreateResponse -- client.workers.ai.gateways.update(accountTag, id, { ...params }) -> GatewayUpdateResponse -- client.workers.ai.gateways.list(accountTag, { ...params }) -> GatewayListResponsesV4PagePaginationArray -- client.workers.ai.gateways.delete(accountTag, id) -> GatewayDeleteResponse -- client.workers.ai.gateways.get(accountTag, id) -> GatewayGetResponse - -#### Logs - -Types: - -- LogGetResponse - -Methods: - -- client.workers.ai.gateways.logs.get(accountTag, id, { ...params }) -> LogGetResponse +- client.workers.ai.run(modelName, { ...params }) -> AIRunResponse ## Scripts @@ -6451,3 +6423,31 @@ Methods: - client.eventNotifications.r2.configuration.queues.update(bucketName, queueId, { ...params }) -> QueueUpdateResponse - client.eventNotifications.r2.configuration.queues.delete(bucketName, queueId, { ...params }) -> QueueDeleteResponse + +# AIGateway + +Types: + +- AIGatewayCreateResponse +- AIGatewayUpdateResponse +- AIGatewayListResponse +- AIGatewayDeleteResponse +- AIGatewayGetResponse + +Methods: + +- client.aiGateway.create(accountTag, { ...params }) -> AIGatewayCreateResponse +- client.aiGateway.update(accountTag, id, { ...params }) -> AIGatewayUpdateResponse +- client.aiGateway.list(accountTag, { ...params }) -> AIGatewayListResponsesV4PagePaginationArray +- client.aiGateway.delete(accountTag, id) -> AIGatewayDeleteResponse +- client.aiGateway.get(accountTag, id) -> AIGatewayGetResponse + +## Logs + +Types: + +- LogGetResponse + +Methods: + +- client.aiGateway.logs.get(accountTag, id, { ...params }) -> LogGetResponse diff --git a/src/index.ts b/src/index.ts index 9af17bc07b..b5b07e3998 100644 --- a/src/index.ts +++ b/src/index.ts @@ -223,6 +223,7 @@ export class Cloudflare extends Core.APIClient { calls: API.Calls = new API.Calls(this); cloudforceOne: API.CloudforceOne = new API.CloudforceOne(this); eventNotifications: API.EventNotifications = new API.EventNotifications(this); + aiGateway: API.AIGateway = new API.AIGateway(this); protected override defaultQuery(): Core.DefaultQuery | undefined { return this._options.defaultQuery; @@ -551,6 +552,8 @@ export namespace Cloudflare { export import EventNotifications = API.EventNotifications; + export import AIGateway = API.AIGateway; + export import ASN = API.ASN; export import AuditLog = API.AuditLog; export import CloudflareTunnel = API.CloudflareTunnel; diff --git a/src/resources/workers/ai/gateways/gateways.ts b/src/resources/ai-gateway/ai-gateway.ts similarity index 64% rename from src/resources/workers/ai/gateways/gateways.ts rename to src/resources/ai-gateway/ai-gateway.ts index d6d42e4b91..424ed8b46d 100644 --- a/src/resources/workers/ai/gateways/gateways.ts +++ b/src/resources/ai-gateway/ai-gateway.ts @@ -3,11 +3,10 @@ import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; import { isRequestOptions } from 'cloudflare/core'; -import * as GatewaysAPI from 'cloudflare/resources/workers/ai/gateways/gateways'; -import * as LogsAPI from 'cloudflare/resources/workers/ai/gateways/logs'; +import * as LogsAPI from 'cloudflare/resources/ai-gateway/logs'; import { V4PagePaginationArray, type V4PagePaginationArrayParams } from 'cloudflare/pagination'; -export class Gateways extends APIResource { +export class AIGateway extends APIResource { logs: LogsAPI.Logs = new LogsAPI.Logs(this._client); /** @@ -15,14 +14,14 @@ export class Gateways extends APIResource { */ create( accountTag: string, - body: GatewayCreateParams, + body: AIGatewayCreateParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { return ( this._client.post(`/accounts/${accountTag}/ai-gateway/gateways`, { body, ...options, - }) as Core.APIPromise<{ result: GatewayCreateResponse }> + }) as Core.APIPromise<{ result: AIGatewayCreateResponse }> )._thenUnwrap((obj) => obj.result); } @@ -32,14 +31,14 @@ export class Gateways extends APIResource { update( accountTag: string, id: string, - body: GatewayUpdateParams, + body: AIGatewayUpdateParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { return ( this._client.put(`/accounts/${accountTag}/ai-gateway/gateways/${id}`, { body, ...options, - }) as Core.APIPromise<{ result: GatewayUpdateResponse }> + }) as Core.APIPromise<{ result: AIGatewayUpdateResponse }> )._thenUnwrap((obj) => obj.result); } @@ -48,24 +47,24 @@ export class Gateways extends APIResource { */ list( accountTag: string, - query?: GatewayListParams, + query?: AIGatewayListParams, options?: Core.RequestOptions, - ): Core.PagePromise; + ): Core.PagePromise; list( accountTag: string, options?: Core.RequestOptions, - ): Core.PagePromise; + ): Core.PagePromise; list( accountTag: string, - query: GatewayListParams | Core.RequestOptions = {}, + query: AIGatewayListParams | Core.RequestOptions = {}, options?: Core.RequestOptions, - ): Core.PagePromise { + ): Core.PagePromise { if (isRequestOptions(query)) { return this.list(accountTag, {}, query); } return this._client.getAPIList( `/accounts/${accountTag}/ai-gateway/gateways`, - GatewayListResponsesV4PagePaginationArray, + AIGatewayListResponsesV4PagePaginationArray, { query, ...options }, ); } @@ -77,10 +76,10 @@ export class Gateways extends APIResource { accountTag: string, id: string, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { return ( this._client.delete(`/accounts/${accountTag}/ai-gateway/gateways/${id}`, options) as Core.APIPromise<{ - result: GatewayDeleteResponse; + result: AIGatewayDeleteResponse; }> )._thenUnwrap((obj) => obj.result); } @@ -88,22 +87,22 @@ export class Gateways extends APIResource { /** * Fetch a Gateway */ - get(accountTag: string, id: string, options?: Core.RequestOptions): Core.APIPromise { + get(accountTag: string, id: string, options?: Core.RequestOptions): Core.APIPromise { return ( this._client.get(`/accounts/${accountTag}/ai-gateway/gateways/${id}`, options) as Core.APIPromise<{ - result: GatewayGetResponse; + result: AIGatewayGetResponse; }> )._thenUnwrap((obj) => obj.result); } } -export class GatewayListResponsesV4PagePaginationArray extends V4PagePaginationArray {} +export class AIGatewayListResponsesV4PagePaginationArray extends V4PagePaginationArray {} -export interface GatewayCreateResponse { - task: GatewayCreateResponse.Task; +export interface AIGatewayCreateResponse { + task: AIGatewayCreateResponse.Task; } -export namespace GatewayCreateResponse { +export namespace AIGatewayCreateResponse { export interface Task { id: string; @@ -129,7 +128,7 @@ export namespace GatewayCreateResponse { } } -export interface GatewayUpdateResponse { +export interface AIGatewayUpdateResponse { id: string; cache_invalidate_on_update: boolean; @@ -153,7 +152,7 @@ export interface GatewayUpdateResponse { rate_limiting_technique?: string; } -export interface GatewayListResponse { +export interface AIGatewayListResponse { id: string; cache_invalidate_on_update: boolean; @@ -177,7 +176,7 @@ export interface GatewayListResponse { rate_limiting_technique?: string; } -export interface GatewayDeleteResponse { +export interface AIGatewayDeleteResponse { id: string; cache_invalidate_on_update: boolean; @@ -201,7 +200,7 @@ export interface GatewayDeleteResponse { rate_limiting_technique?: string; } -export interface GatewayGetResponse { +export interface AIGatewayGetResponse { id: string; cache_invalidate_on_update: boolean; @@ -225,7 +224,7 @@ export interface GatewayGetResponse { rate_limiting_technique?: string; } -export interface GatewayCreateParams { +export interface AIGatewayCreateParams { cache_invalidate_on_update: boolean; cache_ttl: number; @@ -243,7 +242,7 @@ export interface GatewayCreateParams { rate_limiting_technique?: string; } -export interface GatewayUpdateParams { +export interface AIGatewayUpdateParams { cache_invalidate_on_update: boolean; cache_ttl: number; @@ -261,7 +260,7 @@ export interface GatewayUpdateParams { rate_limiting_technique?: string; } -export interface GatewayListParams extends V4PagePaginationArrayParams { +export interface AIGatewayListParams extends V4PagePaginationArrayParams { id?: string; /** @@ -270,16 +269,7 @@ export interface GatewayListParams extends V4PagePaginationArrayParams { order_by?: string; } -export namespace Gateways { - export import GatewayCreateResponse = GatewaysAPI.GatewayCreateResponse; - export import GatewayUpdateResponse = GatewaysAPI.GatewayUpdateResponse; - export import GatewayListResponse = GatewaysAPI.GatewayListResponse; - export import GatewayDeleteResponse = GatewaysAPI.GatewayDeleteResponse; - export import GatewayGetResponse = GatewaysAPI.GatewayGetResponse; - export import GatewayListResponsesV4PagePaginationArray = GatewaysAPI.GatewayListResponsesV4PagePaginationArray; - export import GatewayCreateParams = GatewaysAPI.GatewayCreateParams; - export import GatewayUpdateParams = GatewaysAPI.GatewayUpdateParams; - export import GatewayListParams = GatewaysAPI.GatewayListParams; +export namespace AIGateway { export import Logs = LogsAPI.Logs; export import LogGetResponse = LogsAPI.LogGetResponse; export import LogGetParams = LogsAPI.LogGetParams; diff --git a/src/resources/ai-gateway/index.ts b/src/resources/ai-gateway/index.ts new file mode 100644 index 0000000000..cd31312a69 --- /dev/null +++ b/src/resources/ai-gateway/index.ts @@ -0,0 +1,4 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { AIGateway } from './ai-gateway'; +export { LogGetResponse, LogGetParams, Logs } from './logs'; diff --git a/src/resources/workers/ai/gateways/logs.ts b/src/resources/ai-gateway/logs.ts similarity index 96% rename from src/resources/workers/ai/gateways/logs.ts rename to src/resources/ai-gateway/logs.ts index 1f643b0155..cd74ca689b 100644 --- a/src/resources/workers/ai/gateways/logs.ts +++ b/src/resources/ai-gateway/logs.ts @@ -3,7 +3,7 @@ import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; import { isRequestOptions } from 'cloudflare/core'; -import * as LogsAPI from 'cloudflare/resources/workers/ai/gateways/logs'; +import * as LogsAPI from 'cloudflare/resources/ai-gateway/logs'; export class Logs extends APIResource { /** diff --git a/src/resources/index.ts b/src/resources/index.ts index 240c76db4a..a901306862 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -2,6 +2,7 @@ export * from './shared'; export { ACM } from './acm/acm'; +export { AIGateway } from './ai-gateway/ai-gateway'; export { Accounts } from './accounts/accounts'; export { Addressing } from './addressing/addressing'; export { Alerting } from './alerting/alerting'; diff --git a/src/resources/workers/ai/ai.ts b/src/resources/workers/ai.ts similarity index 87% rename from src/resources/workers/ai/ai.ts rename to src/resources/workers/ai.ts index 54446f136b..94f2f53dc2 100644 --- a/src/resources/workers/ai/ai.ts +++ b/src/resources/workers/ai.ts @@ -2,13 +2,10 @@ import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; -import * as AIAPI from 'cloudflare/resources/workers/ai/ai'; -import * as GatewaysAPI from 'cloudflare/resources/workers/ai/gateways/gateways'; +import * as AIAPI from 'cloudflare/resources/workers/ai'; import { type Uploadable } from 'cloudflare/core'; export class AI extends APIResource { - gateways: GatewaysAPI.Gateways = new GatewaysAPI.Gateways(this._client); - /** * This endpoint provides users with the capability to run specific AI models * on-demand. @@ -382,14 +379,4 @@ export namespace AIRunParams { export namespace AI { export import AIRunResponse = AIAPI.AIRunResponse; export import AIRunParams = AIAPI.AIRunParams; - export import Gateways = GatewaysAPI.Gateways; - export import GatewayCreateResponse = GatewaysAPI.GatewayCreateResponse; - export import GatewayUpdateResponse = GatewaysAPI.GatewayUpdateResponse; - export import GatewayListResponse = GatewaysAPI.GatewayListResponse; - export import GatewayDeleteResponse = GatewaysAPI.GatewayDeleteResponse; - export import GatewayGetResponse = GatewaysAPI.GatewayGetResponse; - export import GatewayListResponsesV4PagePaginationArray = GatewaysAPI.GatewayListResponsesV4PagePaginationArray; - export import GatewayCreateParams = GatewaysAPI.GatewayCreateParams; - export import GatewayUpdateParams = GatewaysAPI.GatewayUpdateParams; - export import GatewayListParams = GatewaysAPI.GatewayListParams; } diff --git a/src/resources/workers/ai/gateways/index.ts b/src/resources/workers/ai/gateways/index.ts deleted file mode 100644 index a6817a4678..0000000000 --- a/src/resources/workers/ai/gateways/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -export { - GatewayCreateResponse, - GatewayUpdateResponse, - GatewayListResponse, - GatewayDeleteResponse, - GatewayGetResponse, - GatewayCreateParams, - GatewayUpdateParams, - GatewayListParams, - GatewayListResponsesV4PagePaginationArray, - Gateways, -} from './gateways'; -export { LogGetResponse, LogGetParams, Logs } from './logs'; diff --git a/src/resources/workers/ai/index.ts b/src/resources/workers/ai/index.ts deleted file mode 100644 index 6c6885d782..0000000000 --- a/src/resources/workers/ai/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -export { AIRunResponse, AIRunParams, AI } from './ai'; -export { - GatewayCreateResponse, - GatewayUpdateResponse, - GatewayListResponse, - GatewayDeleteResponse, - GatewayGetResponse, - GatewayCreateParams, - GatewayUpdateParams, - GatewayListParams, - GatewayListResponsesV4PagePaginationArray, - Gateways, -} from './gateways/index'; diff --git a/src/resources/workers/index.ts b/src/resources/workers/index.ts index 830d2e1fd4..25a42d1b9a 100644 --- a/src/resources/workers/index.ts +++ b/src/resources/workers/index.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { AIRunResponse, AIRunParams, AI } from './ai/index'; +export { AIRunResponse, AIRunParams, AI } from './ai'; export { AccountSettingUpdateResponse, AccountSettingGetResponse, diff --git a/src/resources/workers/workers.ts b/src/resources/workers/workers.ts index 3f3a690bd2..dc35ad7bf3 100644 --- a/src/resources/workers/workers.ts +++ b/src/resources/workers/workers.ts @@ -2,9 +2,9 @@ import { APIResource } from 'cloudflare/resource'; import * as AccountSettingsAPI from 'cloudflare/resources/workers/account-settings'; +import * as AIAPI from 'cloudflare/resources/workers/ai'; import * as DomainsAPI from 'cloudflare/resources/workers/domains'; import * as SubdomainsAPI from 'cloudflare/resources/workers/subdomains'; -import * as AIAPI from 'cloudflare/resources/workers/ai/ai'; import * as ScriptsAPI from 'cloudflare/resources/workers/scripts/scripts'; export class Workers extends APIResource { diff --git a/tests/api-resources/workers/ai/gateways/gateways.test.ts b/tests/api-resources/ai-gateway/ai-gateway.test.ts similarity index 84% rename from tests/api-resources/workers/ai/gateways/gateways.test.ts rename to tests/api-resources/ai-gateway/ai-gateway.test.ts index e9e8af4285..a01249ca8b 100644 --- a/tests/api-resources/workers/ai/gateways/gateways.test.ts +++ b/tests/api-resources/ai-gateway/ai-gateway.test.ts @@ -9,9 +9,9 @@ const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); -describe('resource gateways', () => { +describe('resource aiGateway', () => { test('create: only required params', async () => { - const responsePromise = cloudflare.workers.ai.gateways.create('0d37909e38d3e99c29fa2cd343ac421a', { + const responsePromise = cloudflare.aiGateway.create('0d37909e38d3e99c29fa2cd343ac421a', { cache_invalidate_on_update: true, cache_ttl: 0, collect_logs: true, @@ -28,7 +28,7 @@ describe('resource gateways', () => { }); test('create: required and optional params', async () => { - const response = await cloudflare.workers.ai.gateways.create('0d37909e38d3e99c29fa2cd343ac421a', { + const response = await cloudflare.aiGateway.create('0d37909e38d3e99c29fa2cd343ac421a', { cache_invalidate_on_update: true, cache_ttl: 0, collect_logs: true, @@ -41,7 +41,7 @@ describe('resource gateways', () => { }); test('update: only required params', async () => { - const responsePromise = cloudflare.workers.ai.gateways.update( + const responsePromise = cloudflare.aiGateway.update( '0d37909e38d3e99c29fa2cd343ac421a', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { cache_invalidate_on_update: true, cache_ttl: 0, collect_logs: true, name: 'string', slug: 'string' }, @@ -56,7 +56,7 @@ describe('resource gateways', () => { }); test('update: required and optional params', async () => { - const response = await cloudflare.workers.ai.gateways.update( + const response = await cloudflare.aiGateway.update( '0d37909e38d3e99c29fa2cd343ac421a', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { @@ -73,7 +73,7 @@ describe('resource gateways', () => { }); test('list', async () => { - const responsePromise = cloudflare.workers.ai.gateways.list('0d37909e38d3e99c29fa2cd343ac421a'); + const responsePromise = cloudflare.aiGateway.list('0d37909e38d3e99c29fa2cd343ac421a'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -86,16 +86,14 @@ describe('resource gateways', () => { test('list: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - cloudflare.workers.ai.gateways.list('0d37909e38d3e99c29fa2cd343ac421a', { - path: '/_stainless_unknown_path', - }), + cloudflare.aiGateway.list('0d37909e38d3e99c29fa2cd343ac421a', { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Cloudflare.NotFoundError); }); test('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - cloudflare.workers.ai.gateways.list( + cloudflare.aiGateway.list( '0d37909e38d3e99c29fa2cd343ac421a', { id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', order_by: 'string', page: 1, per_page: 5 }, { path: '/_stainless_unknown_path' }, @@ -104,7 +102,7 @@ describe('resource gateways', () => { }); test('delete', async () => { - const responsePromise = cloudflare.workers.ai.gateways.delete( + const responsePromise = cloudflare.aiGateway.delete( '0d37909e38d3e99c29fa2cd343ac421a', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', ); @@ -120,7 +118,7 @@ describe('resource gateways', () => { test('delete: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - cloudflare.workers.ai.gateways.delete( + cloudflare.aiGateway.delete( '0d37909e38d3e99c29fa2cd343ac421a', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }, @@ -129,7 +127,7 @@ describe('resource gateways', () => { }); test('get', async () => { - const responsePromise = cloudflare.workers.ai.gateways.get( + const responsePromise = cloudflare.aiGateway.get( '0d37909e38d3e99c29fa2cd343ac421a', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', ); @@ -145,11 +143,9 @@ describe('resource gateways', () => { test('get: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - cloudflare.workers.ai.gateways.get( - '0d37909e38d3e99c29fa2cd343ac421a', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { path: '/_stainless_unknown_path' }, - ), + cloudflare.aiGateway.get('0d37909e38d3e99c29fa2cd343ac421a', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + path: '/_stainless_unknown_path', + }), ).rejects.toThrow(Cloudflare.NotFoundError); }); }); diff --git a/tests/api-resources/workers/ai/gateways/logs.test.ts b/tests/api-resources/ai-gateway/logs.test.ts similarity index 92% rename from tests/api-resources/workers/ai/gateways/logs.test.ts rename to tests/api-resources/ai-gateway/logs.test.ts index a436ceca43..261bd3a678 100644 --- a/tests/api-resources/workers/ai/gateways/logs.test.ts +++ b/tests/api-resources/ai-gateway/logs.test.ts @@ -11,7 +11,7 @@ const cloudflare = new Cloudflare({ describe('resource logs', () => { test('get', async () => { - const responsePromise = cloudflare.workers.ai.gateways.logs.get( + const responsePromise = cloudflare.aiGateway.logs.get( '0d37909e38d3e99c29fa2cd343ac421a', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', ); @@ -27,7 +27,7 @@ describe('resource logs', () => { test('get: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - cloudflare.workers.ai.gateways.logs.get( + cloudflare.aiGateway.logs.get( '0d37909e38d3e99c29fa2cd343ac421a', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }, @@ -38,7 +38,7 @@ describe('resource logs', () => { test('get: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - cloudflare.workers.ai.gateways.logs.get( + cloudflare.aiGateway.logs.get( '0d37909e38d3e99c29fa2cd343ac421a', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { diff --git a/tests/api-resources/workers/ai/ai.test.ts b/tests/api-resources/workers/ai.test.ts similarity index 100% rename from tests/api-resources/workers/ai/ai.test.ts rename to tests/api-resources/workers/ai.test.ts