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/ai-gateway.test.ts

201lines · 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 aiGateway', () => {
13 test('create: only required params', async () => {
14 const responsePromise = client.aiGateway.create({
15 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
16 id: 'my-gateway',
17 cache_invalidate_on_update: true,
18 cache_ttl: 0,
19 collect_logs: true,
20 rate_limiting_interval: 0,
21 rate_limiting_limit: 0,
22 });
23 const rawResponse = await responsePromise.asResponse();
24 expect(rawResponse).toBeInstanceOf(Response);
25 const response = await responsePromise;
26 expect(response).not.toBeInstanceOf(Response);
27 const dataAndResponse = await responsePromise.withResponse();
28 expect(dataAndResponse.data).toBe(response);
29 expect(dataAndResponse.response).toBe(rawResponse);
30 });
31
32 test('create: required and optional params', async () => {
33 const response = await client.aiGateway.create({
34 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
35 id: 'my-gateway',
36 cache_invalidate_on_update: true,
37 cache_ttl: 0,
38 collect_logs: true,
39 rate_limiting_interval: 0,
40 rate_limiting_limit: 0,
41 authentication: true,
42 log_management: 10000,
43 log_management_strategy: 'STOP_INSERTING',
44 logpush: true,
45 logpush_public_key: 'xxxxxxxxxxxxxxxx',
46 rate_limiting_technique: 'fixed',
47 retry_backoff: 'constant',
48 retry_delay: 0,
49 retry_max_attempts: 1,
50 workers_ai_billing_mode: 'postpaid',
51 zdr: true,
52 });
53 });
54
55 test('update: only required params', async () => {
56 const responsePromise = client.aiGateway.update('my-gateway', {
57 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
58 cache_invalidate_on_update: true,
59 cache_ttl: 0,
60 collect_logs: true,
61 rate_limiting_interval: 0,
62 rate_limiting_limit: 0,
63 });
64 const rawResponse = await responsePromise.asResponse();
65 expect(rawResponse).toBeInstanceOf(Response);
66 const response = await responsePromise;
67 expect(response).not.toBeInstanceOf(Response);
68 const dataAndResponse = await responsePromise.withResponse();
69 expect(dataAndResponse.data).toBe(response);
70 expect(dataAndResponse.response).toBe(rawResponse);
71 });
72
73 test('update: required and optional params', async () => {
74 const response = await client.aiGateway.update('my-gateway', {
75 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
76 cache_invalidate_on_update: true,
77 cache_ttl: 0,
78 collect_logs: true,
79 rate_limiting_interval: 0,
80 rate_limiting_limit: 0,
81 authentication: true,
82 dlp: {
83 action: 'BLOCK',
84 enabled: true,
85 profiles: ['string'],
86 },
87 guardrails: {
88 prompt: {
89 P1: 'FLAG',
90 S1: 'FLAG',
91 S10: 'FLAG',
92 S11: 'FLAG',
93 S12: 'FLAG',
94 S13: 'FLAG',
95 S2: 'FLAG',
96 S3: 'FLAG',
97 S4: 'FLAG',
98 S5: 'FLAG',
99 S6: 'FLAG',
100 S7: 'FLAG',
101 S8: 'FLAG',
102 S9: 'FLAG',
103 },
104 response: {
105 P1: 'FLAG',
106 S1: 'FLAG',
107 S10: 'FLAG',
108 S11: 'FLAG',
109 S12: 'FLAG',
110 S13: 'FLAG',
111 S2: 'FLAG',
112 S3: 'FLAG',
113 S4: 'FLAG',
114 S5: 'FLAG',
115 S6: 'FLAG',
116 S7: 'FLAG',
117 S8: 'FLAG',
118 S9: 'FLAG',
119 },
120 },
121 log_management: 10000,
122 log_management_strategy: 'STOP_INSERTING',
123 logpush: true,
124 logpush_public_key: 'xxxxxxxxxxxxxxxx',
125 otel: [
126 {
127 authorization: 'authorization',
128 headers: { foo: 'string' },
129 url: 'https://example.com',
130 content_type: 'json',
131 },
132 ],
133 rate_limiting_technique: 'fixed',
134 retry_backoff: 'constant',
135 retry_delay: 0,
136 retry_max_attempts: 1,
137 store_id: 'store_id',
138 stripe: { authorization: 'authorization', usage_events: [{ payload: 'payload' }] },
139 workers_ai_billing_mode: 'postpaid',
140 zdr: true,
141 });
142 });
143
144 test('list: only required params', async () => {
145 const responsePromise = client.aiGateway.list({ account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' });
146 const rawResponse = await responsePromise.asResponse();
147 expect(rawResponse).toBeInstanceOf(Response);
148 const response = await responsePromise;
149 expect(response).not.toBeInstanceOf(Response);
150 const dataAndResponse = await responsePromise.withResponse();
151 expect(dataAndResponse.data).toBe(response);
152 expect(dataAndResponse.response).toBe(rawResponse);
153 });
154
155 test('list: required and optional params', async () => {
156 const response = await client.aiGateway.list({
157 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
158 page: 1,
159 per_page: 1,
160 search: 'search',
161 });
162 });
163
164 test('delete: only required params', async () => {
165 const responsePromise = client.aiGateway.delete('my-gateway', {
166 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
167 });
168 const rawResponse = await responsePromise.asResponse();
169 expect(rawResponse).toBeInstanceOf(Response);
170 const response = await responsePromise;
171 expect(response).not.toBeInstanceOf(Response);
172 const dataAndResponse = await responsePromise.withResponse();
173 expect(dataAndResponse.data).toBe(response);
174 expect(dataAndResponse.response).toBe(rawResponse);
175 });
176
177 test('delete: required and optional params', async () => {
178 const response = await client.aiGateway.delete('my-gateway', {
179 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
180 });
181 });
182
183 test('get: only required params', async () => {
184 const responsePromise = client.aiGateway.get('my-gateway', {
185 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
186 });
187 const rawResponse = await responsePromise.asResponse();
188 expect(rawResponse).toBeInstanceOf(Response);
189 const response = await responsePromise;
190 expect(response).not.toBeInstanceOf(Response);
191 const dataAndResponse = await responsePromise.withResponse();
192 expect(dataAndResponse.data).toBe(response);
193 expect(dataAndResponse.response).toBe(rawResponse);
194 });
195
196 test('get: required and optional params', async () => {
197 const response = await client.aiGateway.get('my-gateway', {
198 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
199 });
200 });
201});
202