cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/ai-gateway/logs.ts
107lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import * as Core from 'cloudflare/core'; |
| 4 | import { APIResource } from 'cloudflare/resource'; |
| 5 | import * as LogsAPI from 'cloudflare/resources/ai-gateway/logs'; |
| 6 | |
| 7 | export class Logs extends APIResource { |
| 8 | /** |
| 9 | * List Gateway Logs |
| 10 | */ |
| 11 | get(id: string, params: LogGetParams, options?: Core.RequestOptions): Core.APIPromise<LogGetResponse> { |
| 12 | const { account_id, ...query } = params; |
| 13 | return ( |
| 14 | this._client.get(`/accounts/${account_id}/ai-gateway/gateways/${id}/logs`, { |
| 15 | query, |
| 16 | ...options, |
| 17 | }) as Core.APIPromise<{ result: LogGetResponse }> |
| 18 | )._thenUnwrap((obj) => obj.result); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | export type LogGetResponse = Array<LogGetResponse.LogGetResponseItem>; |
| 23 | |
| 24 | export namespace LogGetResponse { |
| 25 | export interface LogGetResponseItem { |
| 26 | id: string; |
| 27 | |
| 28 | cached: boolean; |
| 29 | |
| 30 | created_at: string; |
| 31 | |
| 32 | duration: number; |
| 33 | |
| 34 | model: string; |
| 35 | |
| 36 | path: string; |
| 37 | |
| 38 | provider: string; |
| 39 | |
| 40 | request: string; |
| 41 | |
| 42 | response: string; |
| 43 | |
| 44 | success: boolean; |
| 45 | |
| 46 | tokens_in: number; |
| 47 | |
| 48 | tokens_out: number; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | export interface LogGetParams { |
| 53 | /** |
| 54 | * Path param: |
| 55 | */ |
| 56 | account_id: string; |
| 57 | |
| 58 | /** |
| 59 | * Query param: |
| 60 | */ |
| 61 | cached?: boolean; |
| 62 | |
| 63 | /** |
| 64 | * Query param: |
| 65 | */ |
| 66 | direction?: 'asc' | 'desc'; |
| 67 | |
| 68 | /** |
| 69 | * Query param: |
| 70 | */ |
| 71 | end_date?: string; |
| 72 | |
| 73 | /** |
| 74 | * Query param: |
| 75 | */ |
| 76 | order_by?: 'created_at' | 'provider'; |
| 77 | |
| 78 | /** |
| 79 | * Query param: |
| 80 | */ |
| 81 | page?: number; |
| 82 | |
| 83 | /** |
| 84 | * Query param: |
| 85 | */ |
| 86 | per_page?: number; |
| 87 | |
| 88 | /** |
| 89 | * Query param: |
| 90 | */ |
| 91 | search?: string; |
| 92 | |
| 93 | /** |
| 94 | * Query param: |
| 95 | */ |
| 96 | start_date?: string; |
| 97 | |
| 98 | /** |
| 99 | * Query param: |
| 100 | */ |
| 101 | success?: boolean; |
| 102 | } |
| 103 | |
| 104 | export namespace Logs { |
| 105 | export import LogGetResponse = LogsAPI.LogGetResponse; |
| 106 | export import LogGetParams = LogsAPI.LogGetParams; |
| 107 | } |
| 108 | |