cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/ai-gateway/logs.test.ts
40lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import Cloudflare from 'cloudflare'; |
| 4 | import { Response } from 'node-fetch'; |
| 5 | |
| 6 | const cloudflare = new Cloudflare({ |
| 7 | apiKey: '144c9defac04969c7bfad8efaa8ea194', |
| 8 | apiEmail: 'user@example.com', |
| 9 | baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', |
| 10 | }); |
| 11 | |
| 12 | describe('resource logs', () => { |
| 13 | test('get: only required params', async () => { |
| 14 | const responsePromise = cloudflare.aiGateway.logs.get('my-gateway', { |
| 15 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 16 | }); |
| 17 | const rawResponse = await responsePromise.asResponse(); |
| 18 | expect(rawResponse).toBeInstanceOf(Response); |
| 19 | const response = await responsePromise; |
| 20 | expect(response).not.toBeInstanceOf(Response); |
| 21 | const dataAndResponse = await responsePromise.withResponse(); |
| 22 | expect(dataAndResponse.data).toBe(response); |
| 23 | expect(dataAndResponse.response).toBe(rawResponse); |
| 24 | }); |
| 25 | |
| 26 | test('get: required and optional params', async () => { |
| 27 | const response = await cloudflare.aiGateway.logs.get('my-gateway', { |
| 28 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 29 | cached: true, |
| 30 | direction: 'asc', |
| 31 | end_date: '2019-12-27T18:11:19.117Z', |
| 32 | order_by: 'created_at', |
| 33 | page: 1, |
| 34 | per_page: 5, |
| 35 | search: 'string', |
| 36 | start_date: '2019-12-27T18:11:19.117Z', |
| 37 | success: true, |
| 38 | }); |
| 39 | }); |
| 40 | }); |
| 41 | |