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

148lines · 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 datasets', () => {
13 test('create: only required params', async () => {
14 const responsePromise = client.aiGateway.datasets.create('my-gateway', {
15 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
16 enable: true,
17 filters: [
18 {
19 key: 'created_at',
20 operator: 'eq',
21 value: ['string'],
22 },
23 ],
24 name: 'name',
25 });
26 const rawResponse = await responsePromise.asResponse();
27 expect(rawResponse).toBeInstanceOf(Response);
28 const response = await responsePromise;
29 expect(response).not.toBeInstanceOf(Response);
30 const dataAndResponse = await responsePromise.withResponse();
31 expect(dataAndResponse.data).toBe(response);
32 expect(dataAndResponse.response).toBe(rawResponse);
33 });
34
35 test('create: required and optional params', async () => {
36 const response = await client.aiGateway.datasets.create('my-gateway', {
37 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
38 enable: true,
39 filters: [
40 {
41 key: 'created_at',
42 operator: 'eq',
43 value: ['string'],
44 },
45 ],
46 name: 'name',
47 });
48 });
49
50 test('update: only required params', async () => {
51 const responsePromise = client.aiGateway.datasets.update('my-gateway', 'id', {
52 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
53 enable: true,
54 filters: [
55 {
56 key: 'created_at',
57 operator: 'eq',
58 value: ['string'],
59 },
60 ],
61 name: 'name',
62 });
63 const rawResponse = await responsePromise.asResponse();
64 expect(rawResponse).toBeInstanceOf(Response);
65 const response = await responsePromise;
66 expect(response).not.toBeInstanceOf(Response);
67 const dataAndResponse = await responsePromise.withResponse();
68 expect(dataAndResponse.data).toBe(response);
69 expect(dataAndResponse.response).toBe(rawResponse);
70 });
71
72 test('update: required and optional params', async () => {
73 const response = await client.aiGateway.datasets.update('my-gateway', 'id', {
74 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
75 enable: true,
76 filters: [
77 {
78 key: 'created_at',
79 operator: 'eq',
80 value: ['string'],
81 },
82 ],
83 name: 'name',
84 });
85 });
86
87 test('list: only required params', async () => {
88 const responsePromise = client.aiGateway.datasets.list('my-gateway', {
89 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
90 });
91 const rawResponse = await responsePromise.asResponse();
92 expect(rawResponse).toBeInstanceOf(Response);
93 const response = await responsePromise;
94 expect(response).not.toBeInstanceOf(Response);
95 const dataAndResponse = await responsePromise.withResponse();
96 expect(dataAndResponse.data).toBe(response);
97 expect(dataAndResponse.response).toBe(rawResponse);
98 });
99
100 test('list: required and optional params', async () => {
101 const response = await client.aiGateway.datasets.list('my-gateway', {
102 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
103 enable: true,
104 name: 'name',
105 page: 1,
106 per_page: 1,
107 search: 'search',
108 });
109 });
110
111 test('delete: only required params', async () => {
112 const responsePromise = client.aiGateway.datasets.delete('my-gateway', 'id', {
113 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
114 });
115 const rawResponse = await responsePromise.asResponse();
116 expect(rawResponse).toBeInstanceOf(Response);
117 const response = await responsePromise;
118 expect(response).not.toBeInstanceOf(Response);
119 const dataAndResponse = await responsePromise.withResponse();
120 expect(dataAndResponse.data).toBe(response);
121 expect(dataAndResponse.response).toBe(rawResponse);
122 });
123
124 test('delete: required and optional params', async () => {
125 const response = await client.aiGateway.datasets.delete('my-gateway', 'id', {
126 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
127 });
128 });
129
130 test('get: only required params', async () => {
131 const responsePromise = client.aiGateway.datasets.get('my-gateway', 'id', {
132 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
133 });
134 const rawResponse = await responsePromise.asResponse();
135 expect(rawResponse).toBeInstanceOf(Response);
136 const response = await responsePromise;
137 expect(response).not.toBeInstanceOf(Response);
138 const dataAndResponse = await responsePromise.withResponse();
139 expect(dataAndResponse.data).toBe(response);
140 expect(dataAndResponse.response).toBe(rawResponse);
141 });
142
143 test('get: required and optional params', async () => {
144 const response = await client.aiGateway.datasets.get('my-gateway', 'id', {
145 account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
146 });
147 });
148});
149