cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/ai-gateway/dynamic-routing.test.ts
238lines · 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 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 | |
| 12 | describe('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 | page: 1, |
| 86 | per_page: 20, |
| 87 | }); |
| 88 | }); |
| 89 | |
| 90 | test('delete: only required params', async () => { |
| 91 | const responsePromise = client.aiGateway.dynamicRouting.delete('54442216', '54442216', { |
| 92 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 93 | }); |
| 94 | const rawResponse = await responsePromise.asResponse(); |
| 95 | expect(rawResponse).toBeInstanceOf(Response); |
| 96 | const response = await responsePromise; |
| 97 | expect(response).not.toBeInstanceOf(Response); |
| 98 | const dataAndResponse = await responsePromise.withResponse(); |
| 99 | expect(dataAndResponse.data).toBe(response); |
| 100 | expect(dataAndResponse.response).toBe(rawResponse); |
| 101 | }); |
| 102 | |
| 103 | test('delete: required and optional params', async () => { |
| 104 | const response = await client.aiGateway.dynamicRouting.delete('54442216', '54442216', { |
| 105 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 106 | }); |
| 107 | }); |
| 108 | |
| 109 | test('createDeployment: only required params', async () => { |
| 110 | const responsePromise = client.aiGateway.dynamicRouting.createDeployment('54442216', '54442216', { |
| 111 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 112 | version_id: '54442216', |
| 113 | }); |
| 114 | const rawResponse = await responsePromise.asResponse(); |
| 115 | expect(rawResponse).toBeInstanceOf(Response); |
| 116 | const response = await responsePromise; |
| 117 | expect(response).not.toBeInstanceOf(Response); |
| 118 | const dataAndResponse = await responsePromise.withResponse(); |
| 119 | expect(dataAndResponse.data).toBe(response); |
| 120 | expect(dataAndResponse.response).toBe(rawResponse); |
| 121 | }); |
| 122 | |
| 123 | test('createDeployment: required and optional params', async () => { |
| 124 | const response = await client.aiGateway.dynamicRouting.createDeployment('54442216', '54442216', { |
| 125 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 126 | version_id: '54442216', |
| 127 | }); |
| 128 | }); |
| 129 | |
| 130 | test('createVersion: only required params', async () => { |
| 131 | const responsePromise = client.aiGateway.dynamicRouting.createVersion('54442216', '54442216', { |
| 132 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 133 | elements: [ |
| 134 | { |
| 135 | id: 'id', |
| 136 | outputs: { next: { elementId: 'elementId' } }, |
| 137 | type: 'start', |
| 138 | }, |
| 139 | ], |
| 140 | }); |
| 141 | const rawResponse = await responsePromise.asResponse(); |
| 142 | expect(rawResponse).toBeInstanceOf(Response); |
| 143 | const response = await responsePromise; |
| 144 | expect(response).not.toBeInstanceOf(Response); |
| 145 | const dataAndResponse = await responsePromise.withResponse(); |
| 146 | expect(dataAndResponse.data).toBe(response); |
| 147 | expect(dataAndResponse.response).toBe(rawResponse); |
| 148 | }); |
| 149 | |
| 150 | test('createVersion: required and optional params', async () => { |
| 151 | const response = await client.aiGateway.dynamicRouting.createVersion('54442216', '54442216', { |
| 152 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 153 | elements: [ |
| 154 | { |
| 155 | id: 'id', |
| 156 | outputs: { next: { elementId: 'elementId' } }, |
| 157 | type: 'start', |
| 158 | }, |
| 159 | ], |
| 160 | }); |
| 161 | }); |
| 162 | |
| 163 | test('get: only required params', async () => { |
| 164 | const responsePromise = client.aiGateway.dynamicRouting.get('54442216', '54442216', { |
| 165 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 166 | }); |
| 167 | const rawResponse = await responsePromise.asResponse(); |
| 168 | expect(rawResponse).toBeInstanceOf(Response); |
| 169 | const response = await responsePromise; |
| 170 | expect(response).not.toBeInstanceOf(Response); |
| 171 | const dataAndResponse = await responsePromise.withResponse(); |
| 172 | expect(dataAndResponse.data).toBe(response); |
| 173 | expect(dataAndResponse.response).toBe(rawResponse); |
| 174 | }); |
| 175 | |
| 176 | test('get: required and optional params', async () => { |
| 177 | const response = await client.aiGateway.dynamicRouting.get('54442216', '54442216', { |
| 178 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 179 | }); |
| 180 | }); |
| 181 | |
| 182 | test('getVersion: only required params', async () => { |
| 183 | const responsePromise = client.aiGateway.dynamicRouting.getVersion('54442216', '54442216', '54442216', { |
| 184 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 185 | }); |
| 186 | const rawResponse = await responsePromise.asResponse(); |
| 187 | expect(rawResponse).toBeInstanceOf(Response); |
| 188 | const response = await responsePromise; |
| 189 | expect(response).not.toBeInstanceOf(Response); |
| 190 | const dataAndResponse = await responsePromise.withResponse(); |
| 191 | expect(dataAndResponse.data).toBe(response); |
| 192 | expect(dataAndResponse.response).toBe(rawResponse); |
| 193 | }); |
| 194 | |
| 195 | test('getVersion: required and optional params', async () => { |
| 196 | const response = await client.aiGateway.dynamicRouting.getVersion('54442216', '54442216', '54442216', { |
| 197 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 198 | }); |
| 199 | }); |
| 200 | |
| 201 | test('listDeployments: only required params', async () => { |
| 202 | const responsePromise = client.aiGateway.dynamicRouting.listDeployments('54442216', '54442216', { |
| 203 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 204 | }); |
| 205 | const rawResponse = await responsePromise.asResponse(); |
| 206 | expect(rawResponse).toBeInstanceOf(Response); |
| 207 | const response = await responsePromise; |
| 208 | expect(response).not.toBeInstanceOf(Response); |
| 209 | const dataAndResponse = await responsePromise.withResponse(); |
| 210 | expect(dataAndResponse.data).toBe(response); |
| 211 | expect(dataAndResponse.response).toBe(rawResponse); |
| 212 | }); |
| 213 | |
| 214 | test('listDeployments: required and optional params', async () => { |
| 215 | const response = await client.aiGateway.dynamicRouting.listDeployments('54442216', '54442216', { |
| 216 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 217 | }); |
| 218 | }); |
| 219 | |
| 220 | test('listVersions: only required params', async () => { |
| 221 | const responsePromise = client.aiGateway.dynamicRouting.listVersions('54442216', '54442216', { |
| 222 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 223 | }); |
| 224 | const rawResponse = await responsePromise.asResponse(); |
| 225 | expect(rawResponse).toBeInstanceOf(Response); |
| 226 | const response = await responsePromise; |
| 227 | expect(response).not.toBeInstanceOf(Response); |
| 228 | const dataAndResponse = await responsePromise.withResponse(); |
| 229 | expect(dataAndResponse.data).toBe(response); |
| 230 | expect(dataAndResponse.response).toBe(rawResponse); |
| 231 | }); |
| 232 | |
| 233 | test('listVersions: required and optional params', async () => { |
| 234 | const response = await client.aiGateway.dynamicRouting.listVersions('54442216', '54442216', { |
| 235 | account_id: '0d37909e38d3e99c29fa2cd343ac421a', |
| 236 | }); |
| 237 | }); |
| 238 | }); |
| 239 | |