cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.5.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api-resources/ai-gateway/custom-providers.test.ts

107lines · 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 customProviders', () => {
13 test('create: only required params', async () => {
14 const responsePromise = client.aiGateway.customProviders.create({
15 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
16 base_url: 'https://example.com',
17 name: 'name',
18 slug: 'slug',
19 });
20 const rawResponse = await responsePromise.asResponse();
21 expect(rawResponse).toBeInstanceOf(Response);
22 const response = await responsePromise;
23 expect(response).not.toBeInstanceOf(Response);
24 const dataAndResponse = await responsePromise.withResponse();
25 expect(dataAndResponse.data).toBe(response);
26 expect(dataAndResponse.response).toBe(rawResponse);
27 });
28
29 test('create: required and optional params', async () => {
30 const response = await client.aiGateway.customProviders.create({
31 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
32 base_url: 'https://example.com',
33 name: 'name',
34 slug: 'slug',
35 beta: true,
36 curl_example: 'curl_example',
37 description: 'description',
38 enable: true,
39 headers: 'headers',
40 js_example: 'js_example',
41 link: 'link',
42 position: 0,
43 });
44 });
45
46 test('list: only required params', async () => {
47 const responsePromise = client.aiGateway.customProviders.list({
48 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
49 });
50 const rawResponse = await responsePromise.asResponse();
51 expect(rawResponse).toBeInstanceOf(Response);
52 const response = await responsePromise;
53 expect(response).not.toBeInstanceOf(Response);
54 const dataAndResponse = await responsePromise.withResponse();
55 expect(dataAndResponse.data).toBe(response);
56 expect(dataAndResponse.response).toBe(rawResponse);
57 });
58
59 test('list: required and optional params', async () => {
60 const response = await client.aiGateway.customProviders.list({
61 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
62 beta: true,
63 enable: true,
64 page: 1,
65 per_page: 1,
66 search: 'search',
67 });
68 });
69
70 test('delete: only required params', async () => {
71 const responsePromise = client.aiGateway.customProviders.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
72 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
73 });
74 const rawResponse = await responsePromise.asResponse();
75 expect(rawResponse).toBeInstanceOf(Response);
76 const response = await responsePromise;
77 expect(response).not.toBeInstanceOf(Response);
78 const dataAndResponse = await responsePromise.withResponse();
79 expect(dataAndResponse.data).toBe(response);
80 expect(dataAndResponse.response).toBe(rawResponse);
81 });
82
83 test('delete: required and optional params', async () => {
84 const response = await client.aiGateway.customProviders.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
85 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
86 });
87 });
88
89 test('get: only required params', async () => {
90 const responsePromise = client.aiGateway.customProviders.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
91 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
92 });
93 const rawResponse = await responsePromise.asResponse();
94 expect(rawResponse).toBeInstanceOf(Response);
95 const response = await responsePromise;
96 expect(response).not.toBeInstanceOf(Response);
97 const dataAndResponse = await responsePromise.withResponse();
98 expect(dataAndResponse.data).toBe(response);
99 expect(dataAndResponse.response).toBe(rawResponse);
100 });
101
102 test('get: required and optional params', async () => {
103 const response = await client.aiGateway.customProviders.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
104 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
105 });
106 });
107});
108