cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/ai-gateway/datasets.ts
464lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { APIResource } from '../../resource'; |
| 4 | import * as Core from '../../core'; |
| 5 | import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination'; |
| 6 | |
| 7 | export class Datasets extends APIResource { |
| 8 | /** |
| 9 | * Create a new Dataset |
| 10 | */ |
| 11 | create( |
| 12 | gatewayId: string, |
| 13 | params: DatasetCreateParams, |
| 14 | options?: Core.RequestOptions, |
| 15 | ): Core.APIPromise<DatasetCreateResponse> { |
| 16 | const { account_id, ...body } = params; |
| 17 | return ( |
| 18 | this._client.post(`/accounts/${account_id}/ai-gateway/gateways/${gatewayId}/datasets`, { |
| 19 | body, |
| 20 | ...options, |
| 21 | }) as Core.APIPromise<{ result: DatasetCreateResponse }> |
| 22 | )._thenUnwrap((obj) => obj.result); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Update a Dataset |
| 27 | */ |
| 28 | update( |
| 29 | gatewayId: string, |
| 30 | id: string, |
| 31 | params: DatasetUpdateParams, |
| 32 | options?: Core.RequestOptions, |
| 33 | ): Core.APIPromise<DatasetUpdateResponse> { |
| 34 | const { account_id, ...body } = params; |
| 35 | return ( |
| 36 | this._client.put(`/accounts/${account_id}/ai-gateway/gateways/${gatewayId}/datasets/${id}`, { |
| 37 | body, |
| 38 | ...options, |
| 39 | }) as Core.APIPromise<{ result: DatasetUpdateResponse }> |
| 40 | )._thenUnwrap((obj) => obj.result); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * List Datasets |
| 45 | */ |
| 46 | list( |
| 47 | gatewayId: string, |
| 48 | params: DatasetListParams, |
| 49 | options?: Core.RequestOptions, |
| 50 | ): Core.PagePromise<DatasetListResponsesV4PagePaginationArray, DatasetListResponse> { |
| 51 | const { account_id, ...query } = params; |
| 52 | return this._client.getAPIList( |
| 53 | `/accounts/${account_id}/ai-gateway/gateways/${gatewayId}/datasets`, |
| 54 | DatasetListResponsesV4PagePaginationArray, |
| 55 | { query, ...options }, |
| 56 | ); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Delete a Dataset |
| 61 | */ |
| 62 | delete( |
| 63 | gatewayId: string, |
| 64 | id: string, |
| 65 | params: DatasetDeleteParams, |
| 66 | options?: Core.RequestOptions, |
| 67 | ): Core.APIPromise<DatasetDeleteResponse> { |
| 68 | const { account_id } = params; |
| 69 | return ( |
| 70 | this._client.delete( |
| 71 | `/accounts/${account_id}/ai-gateway/gateways/${gatewayId}/datasets/${id}`, |
| 72 | options, |
| 73 | ) as Core.APIPromise<{ result: DatasetDeleteResponse }> |
| 74 | )._thenUnwrap((obj) => obj.result); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Fetch a Dataset |
| 79 | */ |
| 80 | get( |
| 81 | gatewayId: string, |
| 82 | id: string, |
| 83 | params: DatasetGetParams, |
| 84 | options?: Core.RequestOptions, |
| 85 | ): Core.APIPromise<DatasetGetResponse> { |
| 86 | const { account_id } = params; |
| 87 | return ( |
| 88 | this._client.get( |
| 89 | `/accounts/${account_id}/ai-gateway/gateways/${gatewayId}/datasets/${id}`, |
| 90 | options, |
| 91 | ) as Core.APIPromise<{ result: DatasetGetResponse }> |
| 92 | )._thenUnwrap((obj) => obj.result); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | export class DatasetListResponsesV4PagePaginationArray extends V4PagePaginationArray<DatasetListResponse> {} |
| 97 | |
| 98 | export interface DatasetCreateResponse { |
| 99 | id: string; |
| 100 | |
| 101 | account_id: string; |
| 102 | |
| 103 | account_tag: string; |
| 104 | |
| 105 | created_at: string; |
| 106 | |
| 107 | enable: boolean; |
| 108 | |
| 109 | filters: Array<DatasetCreateResponse.Filter>; |
| 110 | |
| 111 | /** |
| 112 | * gateway id |
| 113 | */ |
| 114 | gateway_id: string; |
| 115 | |
| 116 | modified_at: string; |
| 117 | |
| 118 | name: string; |
| 119 | } |
| 120 | |
| 121 | export namespace DatasetCreateResponse { |
| 122 | export interface Filter { |
| 123 | key: |
| 124 | | 'created_at' |
| 125 | | 'request_content_type' |
| 126 | | 'response_content_type' |
| 127 | | 'success' |
| 128 | | 'cached' |
| 129 | | 'provider' |
| 130 | | 'model' |
| 131 | | 'cost' |
| 132 | | 'tokens' |
| 133 | | 'tokens_in' |
| 134 | | 'tokens_out' |
| 135 | | 'duration' |
| 136 | | 'feedback'; |
| 137 | |
| 138 | operator: 'eq' | 'contains' | 'lt' | 'gt'; |
| 139 | |
| 140 | value: Array<string | number | boolean>; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | export interface DatasetUpdateResponse { |
| 145 | id: string; |
| 146 | |
| 147 | account_id: string; |
| 148 | |
| 149 | account_tag: string; |
| 150 | |
| 151 | created_at: string; |
| 152 | |
| 153 | enable: boolean; |
| 154 | |
| 155 | filters: Array<DatasetUpdateResponse.Filter>; |
| 156 | |
| 157 | /** |
| 158 | * gateway id |
| 159 | */ |
| 160 | gateway_id: string; |
| 161 | |
| 162 | modified_at: string; |
| 163 | |
| 164 | name: string; |
| 165 | } |
| 166 | |
| 167 | export namespace DatasetUpdateResponse { |
| 168 | export interface Filter { |
| 169 | key: |
| 170 | | 'created_at' |
| 171 | | 'request_content_type' |
| 172 | | 'response_content_type' |
| 173 | | 'success' |
| 174 | | 'cached' |
| 175 | | 'provider' |
| 176 | | 'model' |
| 177 | | 'cost' |
| 178 | | 'tokens' |
| 179 | | 'tokens_in' |
| 180 | | 'tokens_out' |
| 181 | | 'duration' |
| 182 | | 'feedback'; |
| 183 | |
| 184 | operator: 'eq' | 'contains' | 'lt' | 'gt'; |
| 185 | |
| 186 | value: Array<string | number | boolean>; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | export interface DatasetListResponse { |
| 191 | id: string; |
| 192 | |
| 193 | account_id: string; |
| 194 | |
| 195 | account_tag: string; |
| 196 | |
| 197 | created_at: string; |
| 198 | |
| 199 | enable: boolean; |
| 200 | |
| 201 | filters: Array<DatasetListResponse.Filter>; |
| 202 | |
| 203 | /** |
| 204 | * gateway id |
| 205 | */ |
| 206 | gateway_id: string; |
| 207 | |
| 208 | modified_at: string; |
| 209 | |
| 210 | name: string; |
| 211 | } |
| 212 | |
| 213 | export namespace DatasetListResponse { |
| 214 | export interface Filter { |
| 215 | key: |
| 216 | | 'created_at' |
| 217 | | 'request_content_type' |
| 218 | | 'response_content_type' |
| 219 | | 'success' |
| 220 | | 'cached' |
| 221 | | 'provider' |
| 222 | | 'model' |
| 223 | | 'cost' |
| 224 | | 'tokens' |
| 225 | | 'tokens_in' |
| 226 | | 'tokens_out' |
| 227 | | 'duration' |
| 228 | | 'feedback'; |
| 229 | |
| 230 | operator: 'eq' | 'contains' | 'lt' | 'gt'; |
| 231 | |
| 232 | value: Array<string | number | boolean>; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | export interface DatasetDeleteResponse { |
| 237 | id: string; |
| 238 | |
| 239 | account_id: string; |
| 240 | |
| 241 | account_tag: string; |
| 242 | |
| 243 | created_at: string; |
| 244 | |
| 245 | enable: boolean; |
| 246 | |
| 247 | filters: Array<DatasetDeleteResponse.Filter>; |
| 248 | |
| 249 | /** |
| 250 | * gateway id |
| 251 | */ |
| 252 | gateway_id: string; |
| 253 | |
| 254 | modified_at: string; |
| 255 | |
| 256 | name: string; |
| 257 | } |
| 258 | |
| 259 | export namespace DatasetDeleteResponse { |
| 260 | export interface Filter { |
| 261 | key: |
| 262 | | 'created_at' |
| 263 | | 'request_content_type' |
| 264 | | 'response_content_type' |
| 265 | | 'success' |
| 266 | | 'cached' |
| 267 | | 'provider' |
| 268 | | 'model' |
| 269 | | 'cost' |
| 270 | | 'tokens' |
| 271 | | 'tokens_in' |
| 272 | | 'tokens_out' |
| 273 | | 'duration' |
| 274 | | 'feedback'; |
| 275 | |
| 276 | operator: 'eq' | 'contains' | 'lt' | 'gt'; |
| 277 | |
| 278 | value: Array<string | number | boolean>; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | export interface DatasetGetResponse { |
| 283 | id: string; |
| 284 | |
| 285 | account_id: string; |
| 286 | |
| 287 | account_tag: string; |
| 288 | |
| 289 | created_at: string; |
| 290 | |
| 291 | enable: boolean; |
| 292 | |
| 293 | filters: Array<DatasetGetResponse.Filter>; |
| 294 | |
| 295 | /** |
| 296 | * gateway id |
| 297 | */ |
| 298 | gateway_id: string; |
| 299 | |
| 300 | modified_at: string; |
| 301 | |
| 302 | name: string; |
| 303 | } |
| 304 | |
| 305 | export namespace DatasetGetResponse { |
| 306 | export interface Filter { |
| 307 | key: |
| 308 | | 'created_at' |
| 309 | | 'request_content_type' |
| 310 | | 'response_content_type' |
| 311 | | 'success' |
| 312 | | 'cached' |
| 313 | | 'provider' |
| 314 | | 'model' |
| 315 | | 'cost' |
| 316 | | 'tokens' |
| 317 | | 'tokens_in' |
| 318 | | 'tokens_out' |
| 319 | | 'duration' |
| 320 | | 'feedback'; |
| 321 | |
| 322 | operator: 'eq' | 'contains' | 'lt' | 'gt'; |
| 323 | |
| 324 | value: Array<string | number | boolean>; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | export interface DatasetCreateParams { |
| 329 | /** |
| 330 | * Path param: |
| 331 | */ |
| 332 | account_id: string; |
| 333 | |
| 334 | /** |
| 335 | * Body param: |
| 336 | */ |
| 337 | enable: boolean; |
| 338 | |
| 339 | /** |
| 340 | * Body param: |
| 341 | */ |
| 342 | filters: Array<DatasetCreateParams.Filter>; |
| 343 | |
| 344 | /** |
| 345 | * Body param: |
| 346 | */ |
| 347 | name: string; |
| 348 | } |
| 349 | |
| 350 | export namespace DatasetCreateParams { |
| 351 | export interface Filter { |
| 352 | key: |
| 353 | | 'created_at' |
| 354 | | 'request_content_type' |
| 355 | | 'response_content_type' |
| 356 | | 'success' |
| 357 | | 'cached' |
| 358 | | 'provider' |
| 359 | | 'model' |
| 360 | | 'cost' |
| 361 | | 'tokens' |
| 362 | | 'tokens_in' |
| 363 | | 'tokens_out' |
| 364 | | 'duration' |
| 365 | | 'feedback'; |
| 366 | |
| 367 | operator: 'eq' | 'contains' | 'lt' | 'gt'; |
| 368 | |
| 369 | value: Array<string | number | boolean>; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | export interface DatasetUpdateParams { |
| 374 | /** |
| 375 | * Path param: |
| 376 | */ |
| 377 | account_id: string; |
| 378 | |
| 379 | /** |
| 380 | * Body param: |
| 381 | */ |
| 382 | enable: boolean; |
| 383 | |
| 384 | /** |
| 385 | * Body param: |
| 386 | */ |
| 387 | filters: Array<DatasetUpdateParams.Filter>; |
| 388 | |
| 389 | /** |
| 390 | * Body param: |
| 391 | */ |
| 392 | name: string; |
| 393 | } |
| 394 | |
| 395 | export namespace DatasetUpdateParams { |
| 396 | export interface Filter { |
| 397 | key: |
| 398 | | 'created_at' |
| 399 | | 'request_content_type' |
| 400 | | 'response_content_type' |
| 401 | | 'success' |
| 402 | | 'cached' |
| 403 | | 'provider' |
| 404 | | 'model' |
| 405 | | 'cost' |
| 406 | | 'tokens' |
| 407 | | 'tokens_in' |
| 408 | | 'tokens_out' |
| 409 | | 'duration' |
| 410 | | 'feedback'; |
| 411 | |
| 412 | operator: 'eq' | 'contains' | 'lt' | 'gt'; |
| 413 | |
| 414 | value: Array<string | number | boolean>; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | export interface DatasetListParams extends V4PagePaginationArrayParams { |
| 419 | /** |
| 420 | * Path param: |
| 421 | */ |
| 422 | account_id: string; |
| 423 | |
| 424 | /** |
| 425 | * Query param: |
| 426 | */ |
| 427 | enable?: boolean; |
| 428 | |
| 429 | /** |
| 430 | * Query param: |
| 431 | */ |
| 432 | name?: string; |
| 433 | |
| 434 | /** |
| 435 | * Query param: Search by id, name, filters |
| 436 | */ |
| 437 | search?: string; |
| 438 | } |
| 439 | |
| 440 | export interface DatasetDeleteParams { |
| 441 | account_id: string; |
| 442 | } |
| 443 | |
| 444 | export interface DatasetGetParams { |
| 445 | account_id: string; |
| 446 | } |
| 447 | |
| 448 | Datasets.DatasetListResponsesV4PagePaginationArray = DatasetListResponsesV4PagePaginationArray; |
| 449 | |
| 450 | export declare namespace Datasets { |
| 451 | export { |
| 452 | type DatasetCreateResponse as DatasetCreateResponse, |
| 453 | type DatasetUpdateResponse as DatasetUpdateResponse, |
| 454 | type DatasetListResponse as DatasetListResponse, |
| 455 | type DatasetDeleteResponse as DatasetDeleteResponse, |
| 456 | type DatasetGetResponse as DatasetGetResponse, |
| 457 | DatasetListResponsesV4PagePaginationArray as DatasetListResponsesV4PagePaginationArray, |
| 458 | type DatasetCreateParams as DatasetCreateParams, |
| 459 | type DatasetUpdateParams as DatasetUpdateParams, |
| 460 | type DatasetListParams as DatasetListParams, |
| 461 | type DatasetDeleteParams as DatasetDeleteParams, |
| 462 | type DatasetGetParams as DatasetGetParams, |
| 463 | }; |
| 464 | } |
| 465 | |