cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v3.0.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 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 // skipped: tests are disabled for the time being
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 // skipped: tests are disabled for the time being
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 // skipped: tests are disabled for the time being
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 // skipped: tests are disabled for the time being
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 // skipped: tests are disabled for the time being
162 test.skip('list: only required params', async () => {
163 const responsePromise = cloudflare.alerting.policies.list({
164 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
165 });
166 const rawResponse = await responsePromise.asResponse();
167 expect(rawResponse).toBeInstanceOf(Response);
168 const response = await responsePromise;
169 expect(response).not.toBeInstanceOf(Response);
170 const dataAndResponse = await responsePromise.withResponse();
171 expect(dataAndResponse.data).toBe(response);
172 expect(dataAndResponse.response).toBe(rawResponse);
173 });
174
175 // skipped: tests are disabled for the time being
176 test.skip('list: required and optional params', async () => {
177 const response = await cloudflare.alerting.policies.list({
178 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
179 });
180 });
181
182 // skipped: tests are disabled for the time being
183 test.skip('delete: only required params', async () => {
184 const responsePromise = cloudflare.alerting.policies.delete('0da2b59e-f118-439d-8097-bdfb215203c9', {
185 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
186 });
187 const rawResponse = await responsePromise.asResponse();
188 expect(rawResponse).toBeInstanceOf(Response);
189 const response = await responsePromise;
190 expect(response).not.toBeInstanceOf(Response);
191 const dataAndResponse = await responsePromise.withResponse();
192 expect(dataAndResponse.data).toBe(response);
193 expect(dataAndResponse.response).toBe(rawResponse);
194 });
195
196 // skipped: tests are disabled for the time being
197 test.skip('delete: required and optional params', async () => {
198 const response = await cloudflare.alerting.policies.delete('0da2b59e-f118-439d-8097-bdfb215203c9', {
199 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
200 });
201 });
202
203 // skipped: tests are disabled for the time being
204 test.skip('get: only required params', async () => {
205 const responsePromise = cloudflare.alerting.policies.get('0da2b59e-f118-439d-8097-bdfb215203c9', {
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 // skipped: tests are disabled for the time being
218 test.skip('get: required and optional params', async () => {
219 const response = await cloudflare.alerting.policies.get('0da2b59e-f118-439d-8097-bdfb215203c9', {
220 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
221 });
222 });
223});
224