cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
update-example-structure

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/resources/ai-gateway/ai-gateway.ts

324lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { APIResource } from '../../resource';
4import * as Core from '../../core';
5import * as LogsAPI from './logs';
6import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination';
7
8export class AIGateway extends APIResource {
9 logs: LogsAPI.Logs = new LogsAPI.Logs(this._client);
10
11 /**
12 * Create a new Gateway
13 */
14 create(
15 params: AIGatewayCreateParams,
16 options?: Core.RequestOptions,
17 ): Core.APIPromise<AIGatewayCreateResponse> {
18 const { account_id, ...body } = params;
19 return (
20 this._client.post(`/accounts/${account_id}/ai-gateway/gateways`, {
21 body,
22 ...options,
23 }) as Core.APIPromise<{ result: AIGatewayCreateResponse }>
24 )._thenUnwrap((obj) => obj.result);
25 }
26
27 /**
28 * Update a Gateway
29 */
30 update(
31 id: string,
32 params: AIGatewayUpdateParams,
33 options?: Core.RequestOptions,
34 ): Core.APIPromise<AIGatewayUpdateResponse> {
35 const { account_id, ...body } = params;
36 return (
37 this._client.put(`/accounts/${account_id}/ai-gateway/gateways/${id}`, {
38 body,
39 ...options,
40 }) as Core.APIPromise<{ result: AIGatewayUpdateResponse }>
41 )._thenUnwrap((obj) => obj.result);
42 }
43
44 /**
45 * List Gateways
46 */
47 list(
48 params: AIGatewayListParams,
49 options?: Core.RequestOptions,
50 ): Core.PagePromise<AIGatewayListResponsesV4PagePaginationArray, AIGatewayListResponse> {
51 const { account_id, ...query } = params;
52 return this._client.getAPIList(
53 `/accounts/${account_id}/ai-gateway/gateways`,
54 AIGatewayListResponsesV4PagePaginationArray,
55 { query, ...options },
56 );
57 }
58
59 /**
60 * Delete a Gateway
61 */
62 delete(
63 id: string,
64 params: AIGatewayDeleteParams,
65 options?: Core.RequestOptions,
66 ): Core.APIPromise<AIGatewayDeleteResponse> {
67 const { account_id } = params;
68 return (
69 this._client.delete(`/accounts/${account_id}/ai-gateway/gateways/${id}`, options) as Core.APIPromise<{
70 result: AIGatewayDeleteResponse;
71 }>
72 )._thenUnwrap((obj) => obj.result);
73 }
74
75 /**
76 * Fetch a Gateway
77 */
78 get(
79 id: string,
80 params: AIGatewayGetParams,
81 options?: Core.RequestOptions,
82 ): Core.APIPromise<AIGatewayGetResponse> {
83 const { account_id } = params;
84 return (
85 this._client.get(`/accounts/${account_id}/ai-gateway/gateways/${id}`, options) as Core.APIPromise<{
86 result: AIGatewayGetResponse;
87 }>
88 )._thenUnwrap((obj) => obj.result);
89 }
90}
91
92export class AIGatewayListResponsesV4PagePaginationArray extends V4PagePaginationArray<AIGatewayListResponse> {}
93
94export interface AIGatewayCreateResponse {
95 task: AIGatewayCreateResponse.Task;
96}
97
98export namespace AIGatewayCreateResponse {
99 export interface Task {
100 /**
101 * gateway id
102 */
103 id: string;
104
105 cache_invalidate_on_update: boolean;
106
107 cache_ttl: number | null;
108
109 collect_logs: boolean;
110
111 created_at: string;
112
113 modified_at: string;
114
115 rate_limiting_interval: number | null;
116
117 rate_limiting_limit: number | null;
118
119 rate_limiting_technique: 'fixed' | 'sliding';
120 }
121}
122
123export interface AIGatewayUpdateResponse {
124 /**
125 * gateway id
126 */
127 id: string;
128
129 cache_invalidate_on_update: boolean;
130
131 cache_ttl: number | null;
132
133 collect_logs: boolean;
134
135 created_at: string;
136
137 modified_at: string;
138
139 rate_limiting_interval: number | null;
140
141 rate_limiting_limit: number | null;
142
143 rate_limiting_technique: 'fixed' | 'sliding';
144}
145
146export interface AIGatewayListResponse {
147 /**
148 * gateway id
149 */
150 id: string;
151
152 cache_invalidate_on_update: boolean;
153
154 cache_ttl: number | null;
155
156 collect_logs: boolean;
157
158 created_at: string;
159
160 modified_at: string;
161
162 rate_limiting_interval: number | null;
163
164 rate_limiting_limit: number | null;
165
166 rate_limiting_technique: 'fixed' | 'sliding';
167}
168
169export interface AIGatewayDeleteResponse {
170 /**
171 * gateway id
172 */
173 id: string;
174
175 cache_invalidate_on_update: boolean;
176
177 cache_ttl: number | null;
178
179 collect_logs: boolean;
180
181 created_at: string;
182
183 modified_at: string;
184
185 rate_limiting_interval: number | null;
186
187 rate_limiting_limit: number | null;
188
189 rate_limiting_technique: 'fixed' | 'sliding';
190}
191
192export interface AIGatewayGetResponse {
193 /**
194 * gateway id
195 */
196 id: string;
197
198 cache_invalidate_on_update: boolean;
199
200 cache_ttl: number | null;
201
202 collect_logs: boolean;
203
204 created_at: string;
205
206 modified_at: string;
207
208 rate_limiting_interval: number | null;
209
210 rate_limiting_limit: number | null;
211
212 rate_limiting_technique: 'fixed' | 'sliding';
213}
214
215export interface AIGatewayCreateParams {
216 /**
217 * Path param:
218 */
219 account_id: string;
220
221 /**
222 * Body param: gateway id
223 */
224 id: string;
225
226 /**
227 * Body param:
228 */
229 cache_invalidate_on_update: boolean;
230
231 /**
232 * Body param:
233 */
234 cache_ttl: number | null;
235
236 /**
237 * Body param:
238 */
239 collect_logs: boolean;
240
241 /**
242 * Body param:
243 */
244 rate_limiting_interval: number | null;
245
246 /**
247 * Body param:
248 */
249 rate_limiting_limit: number | null;
250
251 /**
252 * Body param:
253 */
254 rate_limiting_technique: 'fixed' | 'sliding';
255}
256
257export interface AIGatewayUpdateParams {
258 /**
259 * Path param:
260 */
261 account_id: string;
262
263 /**
264 * Body param:
265 */
266 cache_invalidate_on_update: boolean;
267
268 /**
269 * Body param:
270 */
271 cache_ttl: number | null;
272
273 /**
274 * Body param:
275 */
276 collect_logs: boolean;
277
278 /**
279 * Body param:
280 */
281 rate_limiting_interval: number | null;
282
283 /**
284 * Body param:
285 */
286 rate_limiting_limit: number | null;
287
288 /**
289 * Body param:
290 */
291 rate_limiting_technique: 'fixed' | 'sliding';
292}
293
294export interface AIGatewayListParams extends V4PagePaginationArrayParams {
295 /**
296 * Path param:
297 */
298 account_id: string;
299
300 /**
301 * Query param: gateway id
302 */
303 id?: string;
304
305 /**
306 * Query param: Order By Column Name
307 */
308 order_by?: string;
309}
310
311export interface AIGatewayDeleteParams {
312 account_id: string;
313}
314
315export interface AIGatewayGetParams {
316 account_id: string;
317}
318
319export namespace AIGateway {
320 export import Logs = LogsAPI.Logs;
321 export import LogListResponse = LogsAPI.LogListResponse;
322 export import LogListResponsesV4PagePaginationArray = LogsAPI.LogListResponsesV4PagePaginationArray;
323 export import LogListParams = LogsAPI.LogListParams;
324}