cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api-resources/ai-gateway/provider-configs.test.ts

64lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import Cloudflare from 'cloudflare';
4import { Response } from 'node-fetch';
5
6const client = 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
12describe('resource providerConfigs', () => {
13 test('create: only required params', async () => {
14 const responsePromise = client.aiGateway.providerConfigs.create('my-gateway', {
15 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
16 alias: 'alias',
17 default_config: true,
18 provider_slug: 'provider_slug',
19 secret: 'secret',
20 secret_id: 'secret_id',
21 });
22 const rawResponse = await responsePromise.asResponse();
23 expect(rawResponse).toBeInstanceOf(Response);
24 const response = await responsePromise;
25 expect(response).not.toBeInstanceOf(Response);
26 const dataAndResponse = await responsePromise.withResponse();
27 expect(dataAndResponse.data).toBe(response);
28 expect(dataAndResponse.response).toBe(rawResponse);
29 });
30
31 test('create: required and optional params', async () => {
32 const response = await client.aiGateway.providerConfigs.create('my-gateway', {
33 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
34 alias: 'alias',
35 default_config: true,
36 provider_slug: 'provider_slug',
37 secret: 'secret',
38 secret_id: 'secret_id',
39 rate_limit: 0,
40 rate_limit_period: 0,
41 });
42 });
43
44 test('list: only required params', async () => {
45 const responsePromise = client.aiGateway.providerConfigs.list('my-gateway', {
46 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
47 });
48 const rawResponse = await responsePromise.asResponse();
49 expect(rawResponse).toBeInstanceOf(Response);
50 const response = await responsePromise;
51 expect(response).not.toBeInstanceOf(Response);
52 const dataAndResponse = await responsePromise.withResponse();
53 expect(dataAndResponse.data).toBe(response);
54 expect(dataAndResponse.response).toBe(rawResponse);
55 });
56
57 test('list: required and optional params', async () => {
58 const response = await client.aiGateway.providerConfigs.list('my-gateway', {
59 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
60 page: 1,
61 per_page: 1,
62 });
63 });
64});
65