cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.1.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api-resources/ai-gateway/dynamic-routing.test.ts

236lines · 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 dynamicRouting', () => {
13 test('create: only required params', async () => {
14 const responsePromise = client.aiGateway.dynamicRouting.create('54442216', {
15 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
16 elements: [
17 {
18 id: 'id',
19 outputs: { next: { elementId: 'elementId' } },
20 type: 'start',
21 },
22 ],
23 name: 'name',
24 });
25 const rawResponse = await responsePromise.asResponse();
26 expect(rawResponse).toBeInstanceOf(Response);
27 const response = await responsePromise;
28 expect(response).not.toBeInstanceOf(Response);
29 const dataAndResponse = await responsePromise.withResponse();
30 expect(dataAndResponse.data).toBe(response);
31 expect(dataAndResponse.response).toBe(rawResponse);
32 });
33
34 test('create: required and optional params', async () => {
35 const response = await client.aiGateway.dynamicRouting.create('54442216', {
36 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
37 elements: [
38 {
39 id: 'id',
40 outputs: { next: { elementId: 'elementId' } },
41 type: 'start',
42 },
43 ],
44 name: 'name',
45 });
46 });
47
48 test('update: only required params', async () => {
49 const responsePromise = client.aiGateway.dynamicRouting.update('54442216', '54442216', {
50 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
51 name: 'Route Name',
52 });
53 const rawResponse = await responsePromise.asResponse();
54 expect(rawResponse).toBeInstanceOf(Response);
55 const response = await responsePromise;
56 expect(response).not.toBeInstanceOf(Response);
57 const dataAndResponse = await responsePromise.withResponse();
58 expect(dataAndResponse.data).toBe(response);
59 expect(dataAndResponse.response).toBe(rawResponse);
60 });
61
62 test('update: required and optional params', async () => {
63 const response = await client.aiGateway.dynamicRouting.update('54442216', '54442216', {
64 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
65 name: 'Route Name',
66 });
67 });
68
69 test('list: only required params', async () => {
70 const responsePromise = client.aiGateway.dynamicRouting.list('54442216', {
71 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
72 });
73 const rawResponse = await responsePromise.asResponse();
74 expect(rawResponse).toBeInstanceOf(Response);
75 const response = await responsePromise;
76 expect(response).not.toBeInstanceOf(Response);
77 const dataAndResponse = await responsePromise.withResponse();
78 expect(dataAndResponse.data).toBe(response);
79 expect(dataAndResponse.response).toBe(rawResponse);
80 });
81
82 test('list: required and optional params', async () => {
83 const response = await client.aiGateway.dynamicRouting.list('54442216', {
84 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
85 });
86 });
87
88 test('delete: only required params', async () => {
89 const responsePromise = client.aiGateway.dynamicRouting.delete('54442216', '54442216', {
90 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
91 });
92 const rawResponse = await responsePromise.asResponse();
93 expect(rawResponse).toBeInstanceOf(Response);
94 const response = await responsePromise;
95 expect(response).not.toBeInstanceOf(Response);
96 const dataAndResponse = await responsePromise.withResponse();
97 expect(dataAndResponse.data).toBe(response);
98 expect(dataAndResponse.response).toBe(rawResponse);
99 });
100
101 test('delete: required and optional params', async () => {
102 const response = await client.aiGateway.dynamicRouting.delete('54442216', '54442216', {
103 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
104 });
105 });
106
107 test('createDeployment: only required params', async () => {
108 const responsePromise = client.aiGateway.dynamicRouting.createDeployment('54442216', '54442216', {
109 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
110 version_id: '54442216',
111 });
112 const rawResponse = await responsePromise.asResponse();
113 expect(rawResponse).toBeInstanceOf(Response);
114 const response = await responsePromise;
115 expect(response).not.toBeInstanceOf(Response);
116 const dataAndResponse = await responsePromise.withResponse();
117 expect(dataAndResponse.data).toBe(response);
118 expect(dataAndResponse.response).toBe(rawResponse);
119 });
120
121 test('createDeployment: required and optional params', async () => {
122 const response = await client.aiGateway.dynamicRouting.createDeployment('54442216', '54442216', {
123 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
124 version_id: '54442216',
125 });
126 });
127
128 test('createVersion: only required params', async () => {
129 const responsePromise = client.aiGateway.dynamicRouting.createVersion('54442216', '54442216', {
130 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
131 elements: [
132 {
133 id: 'id',
134 outputs: { next: { elementId: 'elementId' } },
135 type: 'start',
136 },
137 ],
138 });
139 const rawResponse = await responsePromise.asResponse();
140 expect(rawResponse).toBeInstanceOf(Response);
141 const response = await responsePromise;
142 expect(response).not.toBeInstanceOf(Response);
143 const dataAndResponse = await responsePromise.withResponse();
144 expect(dataAndResponse.data).toBe(response);
145 expect(dataAndResponse.response).toBe(rawResponse);
146 });
147
148 test('createVersion: required and optional params', async () => {
149 const response = await client.aiGateway.dynamicRouting.createVersion('54442216', '54442216', {
150 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
151 elements: [
152 {
153 id: 'id',
154 outputs: { next: { elementId: 'elementId' } },
155 type: 'start',
156 },
157 ],
158 });
159 });
160
161 test('get: only required params', async () => {
162 const responsePromise = client.aiGateway.dynamicRouting.get('54442216', '54442216', {
163 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
164 });
165 const rawResponse = await responsePromise.asResponse();
166 expect(rawResponse).toBeInstanceOf(Response);
167 const response = await responsePromise;
168 expect(response).not.toBeInstanceOf(Response);
169 const dataAndResponse = await responsePromise.withResponse();
170 expect(dataAndResponse.data).toBe(response);
171 expect(dataAndResponse.response).toBe(rawResponse);
172 });
173
174 test('get: required and optional params', async () => {
175 const response = await client.aiGateway.dynamicRouting.get('54442216', '54442216', {
176 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
177 });
178 });
179
180 test('getVersion: only required params', async () => {
181 const responsePromise = client.aiGateway.dynamicRouting.getVersion('54442216', '54442216', '54442216', {
182 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
183 });
184 const rawResponse = await responsePromise.asResponse();
185 expect(rawResponse).toBeInstanceOf(Response);
186 const response = await responsePromise;
187 expect(response).not.toBeInstanceOf(Response);
188 const dataAndResponse = await responsePromise.withResponse();
189 expect(dataAndResponse.data).toBe(response);
190 expect(dataAndResponse.response).toBe(rawResponse);
191 });
192
193 test('getVersion: required and optional params', async () => {
194 const response = await client.aiGateway.dynamicRouting.getVersion('54442216', '54442216', '54442216', {
195 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
196 });
197 });
198
199 test('listDeployments: only required params', async () => {
200 const responsePromise = client.aiGateway.dynamicRouting.listDeployments('54442216', '54442216', {
201 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
202 });
203 const rawResponse = await responsePromise.asResponse();
204 expect(rawResponse).toBeInstanceOf(Response);
205 const response = await responsePromise;
206 expect(response).not.toBeInstanceOf(Response);
207 const dataAndResponse = await responsePromise.withResponse();
208 expect(dataAndResponse.data).toBe(response);
209 expect(dataAndResponse.response).toBe(rawResponse);
210 });
211
212 test('listDeployments: required and optional params', async () => {
213 const response = await client.aiGateway.dynamicRouting.listDeployments('54442216', '54442216', {
214 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
215 });
216 });
217
218 test('listVersions: only required params', async () => {
219 const responsePromise = client.aiGateway.dynamicRouting.listVersions('54442216', '54442216', {
220 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
221 });
222 const rawResponse = await responsePromise.asResponse();
223 expect(rawResponse).toBeInstanceOf(Response);
224 const response = await responsePromise;
225 expect(response).not.toBeInstanceOf(Response);
226 const dataAndResponse = await responsePromise.withResponse();
227 expect(dataAndResponse.data).toBe(response);
228 expect(dataAndResponse.response).toBe(rawResponse);
229 });
230
231 test('listVersions: required and optional params', async () => {
232 const response = await client.aiGateway.dynamicRouting.listVersions('54442216', '54442216', {
233 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
234 });
235 });
236});
237