cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v4.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

221lines · 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: 'test@example.com' }],
39 pagerduty: [{ id: 'e8133a15-00a4-4d69-aec1-32f70c51f6e5' }],
40 webhooks: [{ id: '14cc1190-5d2b-4b98-a696-c424cb2ad05f' }],
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 where: ['string'],
87 zones: ['string'],
88 },
89 });
90 });
91
92 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
93 test.skip('update: only required params', async () => {
94 const responsePromise = client.alerting.policies.update('0da2b59e-f118-439d-8097-bdfb215203c9', {
95 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
96 });
97 const rawResponse = await responsePromise.asResponse();
98 expect(rawResponse).toBeInstanceOf(Response);
99 const response = await responsePromise;
100 expect(response).not.toBeInstanceOf(Response);
101 const dataAndResponse = await responsePromise.withResponse();
102 expect(dataAndResponse.data).toBe(response);
103 expect(dataAndResponse.response).toBe(rawResponse);
104 });
105
106 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
107 test.skip('update: required and optional params', async () => {
108 const response = await client.alerting.policies.update('0da2b59e-f118-439d-8097-bdfb215203c9', {
109 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
110 alert_interval: '30m',
111 alert_type: 'universal_ssl_event_type',
112 description: 'Something describing the policy.',
113 enabled: true,
114 filters: {
115 actions: ['string'],
116 affected_asns: ['string'],
117 affected_components: ['string'],
118 affected_locations: ['string'],
119 airport_code: ['string'],
120 alert_trigger_preferences: ['string'],
121 alert_trigger_preferences_value: ['string'],
122 enabled: ['string'],
123 environment: ['string'],
124 event: ['string'],
125 event_source: ['string'],
126 event_type: ['string'],
127 group_by: ['string'],
128 health_check_id: ['string'],
129 incident_impact: ['INCIDENT_IMPACT_NONE'],
130 input_id: ['string'],
131 insight_class: ['string'],
132 limit: ['string'],
133 logo_tag: ['string'],
134 megabits_per_second: ['string'],
135 new_health: ['string'],
136 new_status: ['string'],
137 packets_per_second: ['string'],
138 pool_id: ['string'],
139 pop_names: ['string'],
140 product: ['string'],
141 project_id: ['string'],
142 protocol: ['string'],
143 query_tag: ['string'],
144 requests_per_second: ['string'],
145 selectors: ['string'],
146 services: ['string'],
147 slo: ['99.9'],
148 status: ['string'],
149 target_hostname: ['string'],
150 target_ip: ['string'],
151 target_zone_name: ['string'],
152 traffic_exclusions: ['security_events'],
153 tunnel_id: ['string'],
154 tunnel_name: ['string'],
155 where: ['string'],
156 zones: ['string'],
157 },
158 mechanisms: {
159 email: [{ id: 'test@example.com' }],
160 pagerduty: [{ id: 'e8133a15-00a4-4d69-aec1-32f70c51f6e5' }],
161 webhooks: [{ id: '14cc1190-5d2b-4b98-a696-c424cb2ad05f' }],
162 },
163 name: 'SSL Notification Event Policy',
164 });
165 });
166
167 test('list: only required params', async () => {
168 const responsePromise = client.alerting.policies.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });
169 const rawResponse = await responsePromise.asResponse();
170 expect(rawResponse).toBeInstanceOf(Response);
171 const response = await responsePromise;
172 expect(response).not.toBeInstanceOf(Response);
173 const dataAndResponse = await responsePromise.withResponse();
174 expect(dataAndResponse.data).toBe(response);
175 expect(dataAndResponse.response).toBe(rawResponse);
176 });
177
178 test('list: required and optional params', async () => {
179 const response = await client.alerting.policies.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });
180 });
181
182 test('delete: only required params', async () => {
183 const responsePromise = client.alerting.policies.delete('0da2b59e-f118-439d-8097-bdfb215203c9', {
184 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
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('delete: required and optional params', async () => {
196 const response = await client.alerting.policies.delete('0da2b59e-f118-439d-8097-bdfb215203c9', {
197 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
198 });
199 });
200
201 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
202 test.skip('get: only required params', async () => {
203 const responsePromise = client.alerting.policies.get('0da2b59e-f118-439d-8097-bdfb215203c9', {
204 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
205 });
206 const rawResponse = await responsePromise.asResponse();
207 expect(rawResponse).toBeInstanceOf(Response);
208 const response = await responsePromise;
209 expect(response).not.toBeInstanceOf(Response);
210 const dataAndResponse = await responsePromise.withResponse();
211 expect(dataAndResponse.data).toBe(response);
212 expect(dataAndResponse.response).toBe(rawResponse);
213 });
214
215 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
216 test.skip('get: required and optional params', async () => {
217 const response = await client.alerting.policies.get('0da2b59e-f118-439d-8097-bdfb215203c9', {
218 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
219 });
220 });
221});
222