cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.4.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api-resources/alerting/policies.test.ts

223lines · 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 policies', () => {
13 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
14 test.skip('create: only required params', async () => {
15 const responsePromise = client.alerting.policies.create({
16 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
17 alert_type: 'universal_ssl_event_type',
18 enabled: true,
19 mechanisms: {},
20 name: 'SSL Notification Event Policy',
21 });
22 const rawResponse = await responsePromise.asResponse();
23 expect(rawResponse).toBeInstanceOf(Response);
24 const response = await responsePromise;
25 expect(response).not.toBeInstanceOf(Response);
26 const dataAndResponse = await responsePromise.withResponse();
27 expect(dataAndResponse.data).toBe(response);
28 expect(dataAndResponse.response).toBe(rawResponse);
29 });
30
31 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
32 test.skip('create: required and optional params', async () => {
33 const response = await client.alerting.policies.create({
34 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
35 alert_type: 'universal_ssl_event_type',
36 enabled: true,
37 mechanisms: {
38 email: [{ id: 'id' }],
39 pagerduty: [{ id: 'f174e90afafe4643bbbc4a0ed4fc8415' }],
40 webhooks: [{ id: 'f174e90afafe4643bbbc4a0ed4fc8415' }],
41 },
42 name: 'SSL Notification Event Policy',
43 alert_interval: '30m',
44 description: 'Something describing the policy.',
45 filters: {
46 actions: ['string'],
47 affected_asns: ['string'],
48 affected_components: ['string'],
49 affected_locations: ['string'],
50 airport_code: ['string'],
51 alert_trigger_preferences: ['string'],
52 alert_trigger_preferences_value: ['string'],
53 enabled: ['string'],
54 environment: ['string'],
55 event: ['string'],
56 event_source: ['string'],
57 event_type: ['string'],
58 group_by: ['string'],
59 health_check_id: ['string'],
60 incident_impact: ['INCIDENT_IMPACT_NONE'],
61 input_id: ['string'],
62 insight_class: ['string'],
63 limit: ['string'],
64 logo_tag: ['string'],
65 megabits_per_second: ['string'],
66 new_health: ['string'],
67 new_status: ['string'],
68 packets_per_second: ['string'],
69 pool_id: ['string'],
70 pop_names: ['string'],
71 product: ['string'],
72 project_id: ['string'],
73 protocol: ['string'],
74 query_tag: ['string'],
75 requests_per_second: ['string'],
76 selectors: ['string'],
77 services: ['string'],
78 slo: ['99.9'],
79 status: ['string'],
80 target_hostname: ['string'],
81 target_ip: ['string'],
82 target_zone_name: ['string'],
83 traffic_exclusions: ['security_events'],
84 tunnel_id: ['string'],
85 tunnel_name: ['string'],
86 type: ['string'],
87 where: ['string'],
88 zones: ['string'],
89 },
90 });
91 });
92
93 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
94 test.skip('update: only required params', async () => {
95 const responsePromise = client.alerting.policies.update('0da2b59ef118439d8097bdfb215203c9', {
96 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
97 });
98 const rawResponse = await responsePromise.asResponse();
99 expect(rawResponse).toBeInstanceOf(Response);
100 const response = await responsePromise;
101 expect(response).not.toBeInstanceOf(Response);
102 const dataAndResponse = await responsePromise.withResponse();
103 expect(dataAndResponse.data).toBe(response);
104 expect(dataAndResponse.response).toBe(rawResponse);
105 });
106
107 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
108 test.skip('update: required and optional params', async () => {
109 const response = await client.alerting.policies.update('0da2b59ef118439d8097bdfb215203c9', {
110 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
111 alert_interval: '30m',
112 alert_type: 'universal_ssl_event_type',
113 description: 'Something describing the policy.',
114 enabled: true,
115 filters: {
116 actions: ['string'],
117 affected_asns: ['string'],
118 affected_components: ['string'],
119 affected_locations: ['string'],
120 airport_code: ['string'],
121 alert_trigger_preferences: ['string'],
122 alert_trigger_preferences_value: ['string'],
123 enabled: ['string'],
124 environment: ['string'],
125 event: ['string'],
126 event_source: ['string'],
127 event_type: ['string'],
128 group_by: ['string'],
129 health_check_id: ['string'],
130 incident_impact: ['INCIDENT_IMPACT_NONE'],
131 input_id: ['string'],
132 insight_class: ['string'],
133 limit: ['string'],
134 logo_tag: ['string'],
135 megabits_per_second: ['string'],
136 new_health: ['string'],
137 new_status: ['string'],
138 packets_per_second: ['string'],
139 pool_id: ['string'],
140 pop_names: ['string'],
141 product: ['string'],
142 project_id: ['string'],
143 protocol: ['string'],
144 query_tag: ['string'],
145 requests_per_second: ['string'],
146 selectors: ['string'],
147 services: ['string'],
148 slo: ['99.9'],
149 status: ['string'],
150 target_hostname: ['string'],
151 target_ip: ['string'],
152 target_zone_name: ['string'],
153 traffic_exclusions: ['security_events'],
154 tunnel_id: ['string'],
155 tunnel_name: ['string'],
156 type: ['string'],
157 where: ['string'],
158 zones: ['string'],
159 },
160 mechanisms: {
161 email: [{ id: 'id' }],
162 pagerduty: [{ id: 'f174e90afafe4643bbbc4a0ed4fc8415' }],
163 webhooks: [{ id: 'f174e90afafe4643bbbc4a0ed4fc8415' }],
164 },
165 name: 'SSL Notification Event Policy',
166 });
167 });
168
169 test('list: only required params', async () => {
170 const responsePromise = client.alerting.policies.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });
171 const rawResponse = await responsePromise.asResponse();
172 expect(rawResponse).toBeInstanceOf(Response);
173 const response = await responsePromise;
174 expect(response).not.toBeInstanceOf(Response);
175 const dataAndResponse = await responsePromise.withResponse();
176 expect(dataAndResponse.data).toBe(response);
177 expect(dataAndResponse.response).toBe(rawResponse);
178 });
179
180 test('list: required and optional params', async () => {
181 const response = await client.alerting.policies.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });
182 });
183
184 test('delete: only required params', async () => {
185 const responsePromise = client.alerting.policies.delete('0da2b59ef118439d8097bdfb215203c9', {
186 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
187 });
188 const rawResponse = await responsePromise.asResponse();
189 expect(rawResponse).toBeInstanceOf(Response);
190 const response = await responsePromise;
191 expect(response).not.toBeInstanceOf(Response);
192 const dataAndResponse = await responsePromise.withResponse();
193 expect(dataAndResponse.data).toBe(response);
194 expect(dataAndResponse.response).toBe(rawResponse);
195 });
196
197 test('delete: required and optional params', async () => {
198 const response = await client.alerting.policies.delete('0da2b59ef118439d8097bdfb215203c9', {
199 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
200 });
201 });
202
203 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
204 test.skip('get: only required params', async () => {
205 const responsePromise = client.alerting.policies.get('0da2b59ef118439d8097bdfb215203c9', {
206 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
207 });
208 const rawResponse = await responsePromise.asResponse();
209 expect(rawResponse).toBeInstanceOf(Response);
210 const response = await responsePromise;
211 expect(response).not.toBeInstanceOf(Response);
212 const dataAndResponse = await responsePromise.withResponse();
213 expect(dataAndResponse.data).toBe(response);
214 expect(dataAndResponse.response).toBe(rawResponse);
215 });
216
217 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
218 test.skip('get: required and optional params', async () => {
219 const response = await client.alerting.policies.get('0da2b59ef118439d8097bdfb215203c9', {
220 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
221 });
222 });
223});
224