cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v3.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

219lines · 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 cloudflare = 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 = cloudflare.alerting.policies.create({
16 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
17 alert_type: 'universal_ssl_event_type',
18 enabled: true,
19 mechanisms: { email: [{}], pagerduty: [{}], webhooks: [{}] },
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 cloudflare.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 description: 'Something describing the policy.',
44 filters: {
45 actions: ['string', 'string', 'string'],
46 affected_asns: ['string', 'string', 'string'],
47 affected_components: ['string', 'string', 'string'],
48 affected_locations: ['string', 'string', 'string'],
49 airport_code: ['string', 'string', 'string'],
50 alert_trigger_preferences: ['string', 'string', 'string'],
51 alert_trigger_preferences_value: ['99.0', '98.0', '97.0'],
52 enabled: ['string', 'string', 'string'],
53 environment: ['string', 'string', 'string'],
54 event: ['string', 'string', 'string'],
55 event_source: ['string', 'string', 'string'],
56 event_type: ['string', 'string', 'string'],
57 group_by: ['string', 'string', 'string'],
58 health_check_id: ['string', 'string', 'string'],
59 incident_impact: ['INCIDENT_IMPACT_NONE', 'INCIDENT_IMPACT_MINOR', 'INCIDENT_IMPACT_MAJOR'],
60 input_id: ['string', 'string', 'string'],
61 limit: ['string', 'string', 'string'],
62 logo_tag: ['string', 'string', 'string'],
63 megabits_per_second: ['string', 'string', 'string'],
64 new_health: ['string', 'string', 'string'],
65 new_status: ['string', 'string', 'string'],
66 packets_per_second: ['string', 'string', 'string'],
67 pool_id: ['string', 'string', 'string'],
68 product: ['string', 'string', 'string'],
69 project_id: ['string', 'string', 'string'],
70 protocol: ['string', 'string', 'string'],
71 query_tag: ['string', 'string', 'string'],
72 requests_per_second: ['string', 'string', 'string'],
73 selectors: ['string', 'string', 'string'],
74 services: ['string', 'string', 'string'],
75 slo: ['99.9'],
76 status: ['string', 'string', 'string'],
77 target_hostname: ['string', 'string', 'string'],
78 target_ip: ['string', 'string', 'string'],
79 target_zone_name: ['string', 'string', 'string'],
80 traffic_exclusions: ['security_events'],
81 tunnel_id: ['string', 'string', 'string'],
82 tunnel_name: ['string', 'string', 'string'],
83 where: ['string', 'string', 'string'],
84 zones: ['string', 'string', 'string'],
85 },
86 });
87 });
88
89 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
90 test.skip('update: only required params', async () => {
91 const responsePromise = cloudflare.alerting.policies.update('0da2b59e-f118-439d-8097-bdfb215203c9', {
92 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
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 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
104 test.skip('update: required and optional params', async () => {
105 const response = await cloudflare.alerting.policies.update('0da2b59e-f118-439d-8097-bdfb215203c9', {
106 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
107 alert_type: 'universal_ssl_event_type',
108 description: 'Something describing the policy.',
109 enabled: true,
110 filters: {
111 actions: ['string', 'string', 'string'],
112 affected_asns: ['string', 'string', 'string'],
113 affected_components: ['string', 'string', 'string'],
114 affected_locations: ['string', 'string', 'string'],
115 airport_code: ['string', 'string', 'string'],
116 alert_trigger_preferences: ['string', 'string', 'string'],
117 alert_trigger_preferences_value: ['99.0', '98.0', '97.0'],
118 enabled: ['string', 'string', 'string'],
119 environment: ['string', 'string', 'string'],
120 event: ['string', 'string', 'string'],
121 event_source: ['string', 'string', 'string'],
122 event_type: ['string', 'string', 'string'],
123 group_by: ['string', 'string', 'string'],
124 health_check_id: ['string', 'string', 'string'],
125 incident_impact: ['INCIDENT_IMPACT_NONE', 'INCIDENT_IMPACT_MINOR', 'INCIDENT_IMPACT_MAJOR'],
126 input_id: ['string', 'string', 'string'],
127 limit: ['string', 'string', 'string'],
128 logo_tag: ['string', 'string', 'string'],
129 megabits_per_second: ['string', 'string', 'string'],
130 new_health: ['string', 'string', 'string'],
131 new_status: ['string', 'string', 'string'],
132 packets_per_second: ['string', 'string', 'string'],
133 pool_id: ['string', 'string', 'string'],
134 product: ['string', 'string', 'string'],
135 project_id: ['string', 'string', 'string'],
136 protocol: ['string', 'string', 'string'],
137 query_tag: ['string', 'string', 'string'],
138 requests_per_second: ['string', 'string', 'string'],
139 selectors: ['string', 'string', 'string'],
140 services: ['string', 'string', 'string'],
141 slo: ['99.9'],
142 status: ['string', 'string', 'string'],
143 target_hostname: ['string', 'string', 'string'],
144 target_ip: ['string', 'string', 'string'],
145 target_zone_name: ['string', 'string', 'string'],
146 traffic_exclusions: ['security_events'],
147 tunnel_id: ['string', 'string', 'string'],
148 tunnel_name: ['string', 'string', 'string'],
149 where: ['string', 'string', 'string'],
150 zones: ['string', 'string', 'string'],
151 },
152 mechanisms: {
153 email: [{ id: 'test@example.com' }],
154 pagerduty: [{ id: 'e8133a15-00a4-4d69-aec1-32f70c51f6e5' }],
155 webhooks: [{ id: '14cc1190-5d2b-4b98-a696-c424cb2ad05f' }],
156 },
157 name: 'SSL Notification Event Policy',
158 });
159 });
160
161 test('list: only required params', async () => {
162 const responsePromise = cloudflare.alerting.policies.list({
163 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
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('list: required and optional params', async () => {
175 const response = await cloudflare.alerting.policies.list({
176 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
177 });
178 });
179
180 test('delete: only required params', async () => {
181 const responsePromise = cloudflare.alerting.policies.delete('0da2b59e-f118-439d-8097-bdfb215203c9', {
182 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
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('delete: required and optional params', async () => {
194 const response = await cloudflare.alerting.policies.delete('0da2b59e-f118-439d-8097-bdfb215203c9', {
195 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
196 });
197 });
198
199 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
200 test.skip('get: only required params', async () => {
201 const responsePromise = cloudflare.alerting.policies.get('0da2b59e-f118-439d-8097-bdfb215203c9', {
202 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
203 });
204 const rawResponse = await responsePromise.asResponse();
205 expect(rawResponse).toBeInstanceOf(Response);
206 const response = await responsePromise;
207 expect(response).not.toBeInstanceOf(Response);
208 const dataAndResponse = await responsePromise.withResponse();
209 expect(dataAndResponse.data).toBe(response);
210 expect(dataAndResponse.response).toBe(rawResponse);
211 });
212
213 // prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274
214 test.skip('get: required and optional params', async () => {
215 const response = await cloudflare.alerting.policies.get('0da2b59e-f118-439d-8097-bdfb215203c9', {
216 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
217 });
218 });
219});
220