cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v3.1.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/alerting/policies.ts

657lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import * as Core from 'cloudflare/core';
4import { APIResource } from 'cloudflare/resource';
5import * as PoliciesAPI from 'cloudflare/resources/alerting/policies';
6import { SinglePage } from 'cloudflare/pagination';
7
8export class Policies extends APIResource {
9 /**
10 * Creates a new Notification policy.
11 */
12 create(params: PolicyCreateParams, options?: Core.RequestOptions): Core.APIPromise<PolicyCreateResponse> {
13 const { account_id, ...body } = params;
14 return (
15 this._client.post(`/accounts/${account_id}/alerting/v3/policies`, {
16 body,
17 ...options,
18 }) as Core.APIPromise<{ result: PolicyCreateResponse }>
19 )._thenUnwrap((obj) => obj.result);
20 }
21
22 /**
23 * Update a Notification policy.
24 */
25 update(
26 policyId: string,
27 params: PolicyUpdateParams,
28 options?: Core.RequestOptions,
29 ): Core.APIPromise<PolicyUpdateResponse> {
30 const { account_id, ...body } = params;
31 return (
32 this._client.put(`/accounts/${account_id}/alerting/v3/policies/${policyId}`, {
33 body,
34 ...options,
35 }) as Core.APIPromise<{ result: PolicyUpdateResponse }>
36 )._thenUnwrap((obj) => obj.result);
37 }
38
39 /**
40 * Get a list of all Notification policies.
41 */
42 list(
43 params: PolicyListParams,
44 options?: Core.RequestOptions,
45 ): Core.PagePromise<PoliciesSinglePage, Policy> {
46 const { account_id } = params;
47 return this._client.getAPIList(
48 `/accounts/${account_id}/alerting/v3/policies`,
49 PoliciesSinglePage,
50 options,
51 );
52 }
53
54 /**
55 * Delete a Notification policy.
56 */
57 delete(
58 policyId: string,
59 params: PolicyDeleteParams,
60 options?: Core.RequestOptions,
61 ): Core.APIPromise<PolicyDeleteResponse | null> {
62 const { account_id } = params;
63 return (
64 this._client.delete(
65 `/accounts/${account_id}/alerting/v3/policies/${policyId}`,
66 options,
67 ) as Core.APIPromise<{ result: PolicyDeleteResponse | null }>
68 )._thenUnwrap((obj) => obj.result);
69 }
70
71 /**
72 * Get details for a single policy.
73 */
74 get(policyId: string, params: PolicyGetParams, options?: Core.RequestOptions): Core.APIPromise<Policy> {
75 const { account_id } = params;
76 return (
77 this._client.get(
78 `/accounts/${account_id}/alerting/v3/policies/${policyId}`,
79 options,
80 ) as Core.APIPromise<{ result: Policy }>
81 )._thenUnwrap((obj) => obj.result);
82 }
83}
84
85export class PoliciesSinglePage extends SinglePage<Policy> {}
86
87/**
88 * List of IDs that will be used when dispatching a notification. IDs for email
89 * type will be the email address.
90 */
91export type Mechanism = Record<string, Array<Mechanism.UnnamedSchemaWithMapParent1>>;
92
93export namespace Mechanism {
94 export interface UnnamedSchemaWithMapParent1 {
95 /**
96 * UUID
97 */
98 id?: string | string;
99 }
100}
101
102export interface Policy {
103 /**
104 * The unique identifier of a notification policy
105 */
106 id?: string;
107
108 /**
109 * Refers to which event will trigger a Notification dispatch. You can use the
110 * endpoint to get available alert types which then will give you a list of
111 * possible values.
112 */
113 alert_type?:
114 | 'access_custom_certificate_expiration_type'
115 | 'advanced_ddos_attack_l4_alert'
116 | 'advanced_ddos_attack_l7_alert'
117 | 'advanced_http_alert_error'
118 | 'bgp_hijack_notification'
119 | 'billing_usage_alert'
120 | 'block_notification_block_removed'
121 | 'block_notification_new_block'
122 | 'block_notification_review_rejected'
123 | 'brand_protection_alert'
124 | 'brand_protection_digest'
125 | 'clickhouse_alert_fw_anomaly'
126 | 'clickhouse_alert_fw_ent_anomaly'
127 | 'custom_ssl_certificate_event_type'
128 | 'dedicated_ssl_certificate_event_type'
129 | 'dos_attack_l4'
130 | 'dos_attack_l7'
131 | 'expiring_service_token_alert'
132 | 'failing_logpush_job_disabled_alert'
133 | 'fbm_auto_advertisement'
134 | 'fbm_dosd_attack'
135 | 'fbm_volumetric_attack'
136 | 'health_check_status_notification'
137 | 'hostname_aop_custom_certificate_expiration_type'
138 | 'http_alert_edge_error'
139 | 'http_alert_origin_error'
140 | 'incident_alert'
141 | 'load_balancing_health_alert'
142 | 'load_balancing_pool_enablement_alert'
143 | 'logo_match_alert'
144 | 'magic_tunnel_health_check_event'
145 | 'maintenance_event_notification'
146 | 'mtls_certificate_store_certificate_expiration_type'
147 | 'pages_event_alert'
148 | 'radar_notification'
149 | 'real_origin_monitoring'
150 | 'scriptmonitor_alert_new_code_change_detections'
151 | 'scriptmonitor_alert_new_hosts'
152 | 'scriptmonitor_alert_new_malicious_hosts'
153 | 'scriptmonitor_alert_new_malicious_scripts'
154 | 'scriptmonitor_alert_new_malicious_url'
155 | 'scriptmonitor_alert_new_max_length_resource_url'
156 | 'scriptmonitor_alert_new_resources'
157 | 'secondary_dns_all_primaries_failing'
158 | 'secondary_dns_primaries_failing'
159 | 'secondary_dns_zone_successfully_updated'
160 | 'secondary_dns_zone_validation_warning'
161 | 'sentinel_alert'
162 | 'stream_live_notifications'
163 | 'traffic_anomalies_alert'
164 | 'tunnel_health_event'
165 | 'tunnel_update_event'
166 | 'universal_ssl_event_type'
167 | 'web_analytics_metrics_update'
168 | 'zone_aop_custom_certificate_expiration_type';
169
170 created?: string;
171
172 /**
173 * Optional description for the Notification policy.
174 */
175 description?: string;
176
177 /**
178 * Whether or not the Notification policy is enabled.
179 */
180 enabled?: boolean;
181
182 /**
183 * Optional filters that allow you to be alerted only on a subset of events for
184 * that alert type based on some criteria. This is only available for select alert
185 * types. See alert type documentation for more details.
186 */
187 filters?: PolicyFilter;
188
189 /**
190 * List of IDs that will be used when dispatching a notification. IDs for email
191 * type will be the email address.
192 */
193 mechanisms?: Mechanism;
194
195 modified?: string;
196
197 /**
198 * Name of the policy.
199 */
200 name?: string;
201}
202
203/**
204 * Optional filters that allow you to be alerted only on a subset of events for
205 * that alert type based on some criteria. This is only available for select alert
206 * types. See alert type documentation for more details.
207 */
208export interface PolicyFilter {
209 /**
210 * Usage depends on specific alert type
211 */
212 actions?: Array<string>;
213
214 /**
215 * Used for configuring radar_notification
216 */
217 affected_asns?: Array<string>;
218
219 /**
220 * Used for configuring incident_alert. A list of identifiers for each component to
221 * monitor.
222 */
223 affected_components?: Array<string>;
224
225 /**
226 * Used for configuring radar_notification
227 */
228 affected_locations?: Array<string>;
229
230 /**
231 * Used for configuring maintenance_event_notification
232 */
233 airport_code?: Array<string>;
234
235 /**
236 * Usage depends on specific alert type
237 */
238 alert_trigger_preferences?: Array<string>;
239
240 /**
241 * Used for configuring magic_tunnel_health_check_event
242 */
243 alert_trigger_preferences_value?: Array<'99.0' | '98.0' | '97.0'>;
244
245 /**
246 * Used for configuring load_balancing_pool_enablement_alert
247 */
248 enabled?: Array<string>;
249
250 /**
251 * Used for configuring pages_event_alert
252 */
253 environment?: Array<string>;
254
255 /**
256 * Used for configuring pages_event_alert
257 */
258 event?: Array<string>;
259
260 /**
261 * Used for configuring load_balancing_health_alert
262 */
263 event_source?: Array<string>;
264
265 /**
266 * Usage depends on specific alert type
267 */
268 event_type?: Array<string>;
269
270 /**
271 * Usage depends on specific alert type
272 */
273 group_by?: Array<string>;
274
275 /**
276 * Used for configuring health_check_status_notification
277 */
278 health_check_id?: Array<string>;
279
280 /**
281 * Used for configuring incident_alert
282 */
283 incident_impact?: Array<
284 'INCIDENT_IMPACT_NONE' | 'INCIDENT_IMPACT_MINOR' | 'INCIDENT_IMPACT_MAJOR' | 'INCIDENT_IMPACT_CRITICAL'
285 >;
286
287 /**
288 * Used for configuring stream_live_notifications
289 */
290 input_id?: Array<string>;
291
292 /**
293 * Used for configuring billing_usage_alert
294 */
295 limit?: Array<string>;
296
297 /**
298 * Used for configuring logo_match_alert
299 */
300 logo_tag?: Array<string>;
301
302 /**
303 * Used for configuring advanced_ddos_attack_l4_alert
304 */
305 megabits_per_second?: Array<string>;
306
307 /**
308 * Used for configuring load_balancing_health_alert
309 */
310 new_health?: Array<string>;
311
312 /**
313 * Used for configuring tunnel_health_event
314 */
315 new_status?: Array<string>;
316
317 /**
318 * Used for configuring advanced_ddos_attack_l4_alert
319 */
320 packets_per_second?: Array<string>;
321
322 /**
323 * Usage depends on specific alert type
324 */
325 pool_id?: Array<string>;
326
327 /**
328 * Used for configuring billing_usage_alert
329 */
330 product?: Array<string>;
331
332 /**
333 * Used for configuring pages_event_alert
334 */
335 project_id?: Array<string>;
336
337 /**
338 * Used for configuring advanced_ddos_attack_l4_alert
339 */
340 protocol?: Array<string>;
341
342 /**
343 * Usage depends on specific alert type
344 */
345 query_tag?: Array<string>;
346
347 /**
348 * Used for configuring advanced_ddos_attack_l7_alert
349 */
350 requests_per_second?: Array<string>;
351
352 /**
353 * Usage depends on specific alert type
354 */
355 selectors?: Array<string>;
356
357 /**
358 * Used for configuring clickhouse_alert_fw_ent_anomaly
359 */
360 services?: Array<string>;
361
362 /**
363 * Usage depends on specific alert type
364 */
365 slo?: Array<string>;
366
367 /**
368 * Used for configuring health_check_status_notification
369 */
370 status?: Array<string>;
371
372 /**
373 * Used for configuring advanced_ddos_attack_l7_alert
374 */
375 target_hostname?: Array<string>;
376
377 /**
378 * Used for configuring advanced_ddos_attack_l4_alert
379 */
380 target_ip?: Array<string>;
381
382 /**
383 * Used for configuring advanced_ddos_attack_l7_alert
384 */
385 target_zone_name?: Array<string>;
386
387 /**
388 * Used for configuring traffic_anomalies_alert
389 */
390 traffic_exclusions?: Array<'security_events'>;
391
392 /**
393 * Used for configuring tunnel_health_event
394 */
395 tunnel_id?: Array<string>;
396
397 /**
398 * Used for configuring magic_tunnel_health_check_event
399 */
400 tunnel_name?: Array<string>;
401
402 /**
403 * Usage depends on specific alert type
404 */
405 where?: Array<string>;
406
407 /**
408 * Usage depends on specific alert type
409 */
410 zones?: Array<string>;
411}
412
413export interface PolicyCreateResponse {
414 /**
415 * UUID
416 */
417 id?: string;
418}
419
420export interface PolicyUpdateResponse {
421 /**
422 * UUID
423 */
424 id?: string;
425}
426
427export type PolicyDeleteResponse = unknown | Array<unknown> | string;
428
429export interface PolicyCreateParams {
430 /**
431 * Path param: The account id
432 */
433 account_id: string;
434
435 /**
436 * Body param: Refers to which event will trigger a Notification dispatch. You can
437 * use the endpoint to get available alert types which then will give you a list of
438 * possible values.
439 */
440 alert_type:
441 | 'access_custom_certificate_expiration_type'
442 | 'advanced_ddos_attack_l4_alert'
443 | 'advanced_ddos_attack_l7_alert'
444 | 'advanced_http_alert_error'
445 | 'bgp_hijack_notification'
446 | 'billing_usage_alert'
447 | 'block_notification_block_removed'
448 | 'block_notification_new_block'
449 | 'block_notification_review_rejected'
450 | 'brand_protection_alert'
451 | 'brand_protection_digest'
452 | 'clickhouse_alert_fw_anomaly'
453 | 'clickhouse_alert_fw_ent_anomaly'
454 | 'custom_ssl_certificate_event_type'
455 | 'dedicated_ssl_certificate_event_type'
456 | 'dos_attack_l4'
457 | 'dos_attack_l7'
458 | 'expiring_service_token_alert'
459 | 'failing_logpush_job_disabled_alert'
460 | 'fbm_auto_advertisement'
461 | 'fbm_dosd_attack'
462 | 'fbm_volumetric_attack'
463 | 'health_check_status_notification'
464 | 'hostname_aop_custom_certificate_expiration_type'
465 | 'http_alert_edge_error'
466 | 'http_alert_origin_error'
467 | 'incident_alert'
468 | 'load_balancing_health_alert'
469 | 'load_balancing_pool_enablement_alert'
470 | 'logo_match_alert'
471 | 'magic_tunnel_health_check_event'
472 | 'maintenance_event_notification'
473 | 'mtls_certificate_store_certificate_expiration_type'
474 | 'pages_event_alert'
475 | 'radar_notification'
476 | 'real_origin_monitoring'
477 | 'scriptmonitor_alert_new_code_change_detections'
478 | 'scriptmonitor_alert_new_hosts'
479 | 'scriptmonitor_alert_new_malicious_hosts'
480 | 'scriptmonitor_alert_new_malicious_scripts'
481 | 'scriptmonitor_alert_new_malicious_url'
482 | 'scriptmonitor_alert_new_max_length_resource_url'
483 | 'scriptmonitor_alert_new_resources'
484 | 'secondary_dns_all_primaries_failing'
485 | 'secondary_dns_primaries_failing'
486 | 'secondary_dns_zone_successfully_updated'
487 | 'secondary_dns_zone_validation_warning'
488 | 'sentinel_alert'
489 | 'stream_live_notifications'
490 | 'traffic_anomalies_alert'
491 | 'tunnel_health_event'
492 | 'tunnel_update_event'
493 | 'universal_ssl_event_type'
494 | 'web_analytics_metrics_update'
495 | 'zone_aop_custom_certificate_expiration_type';
496
497 /**
498 * Body param: Whether or not the Notification policy is enabled.
499 */
500 enabled: boolean;
501
502 /**
503 * Body param: List of IDs that will be used when dispatching a notification. IDs
504 * for email type will be the email address.
505 */
506 mechanisms: Mechanism;
507
508 /**
509 * Body param: Name of the policy.
510 */
511 name: string;
512
513 /**
514 * Body param: Optional description for the Notification policy.
515 */
516 description?: string;
517
518 /**
519 * Body param: Optional filters that allow you to be alerted only on a subset of
520 * events for that alert type based on some criteria. This is only available for
521 * select alert types. See alert type documentation for more details.
522 */
523 filters?: PolicyFilter;
524}
525
526export interface PolicyUpdateParams {
527 /**
528 * Path param: The account id
529 */
530 account_id: string;
531
532 /**
533 * Body param: Refers to which event will trigger a Notification dispatch. You can
534 * use the endpoint to get available alert types which then will give you a list of
535 * possible values.
536 */
537 alert_type?:
538 | 'access_custom_certificate_expiration_type'
539 | 'advanced_ddos_attack_l4_alert'
540 | 'advanced_ddos_attack_l7_alert'
541 | 'advanced_http_alert_error'
542 | 'bgp_hijack_notification'
543 | 'billing_usage_alert'
544 | 'block_notification_block_removed'
545 | 'block_notification_new_block'
546 | 'block_notification_review_rejected'
547 | 'brand_protection_alert'
548 | 'brand_protection_digest'
549 | 'clickhouse_alert_fw_anomaly'
550 | 'clickhouse_alert_fw_ent_anomaly'
551 | 'custom_ssl_certificate_event_type'
552 | 'dedicated_ssl_certificate_event_type'
553 | 'dos_attack_l4'
554 | 'dos_attack_l7'
555 | 'expiring_service_token_alert'
556 | 'failing_logpush_job_disabled_alert'
557 | 'fbm_auto_advertisement'
558 | 'fbm_dosd_attack'
559 | 'fbm_volumetric_attack'
560 | 'health_check_status_notification'
561 | 'hostname_aop_custom_certificate_expiration_type'
562 | 'http_alert_edge_error'
563 | 'http_alert_origin_error'
564 | 'incident_alert'
565 | 'load_balancing_health_alert'
566 | 'load_balancing_pool_enablement_alert'
567 | 'logo_match_alert'
568 | 'magic_tunnel_health_check_event'
569 | 'maintenance_event_notification'
570 | 'mtls_certificate_store_certificate_expiration_type'
571 | 'pages_event_alert'
572 | 'radar_notification'
573 | 'real_origin_monitoring'
574 | 'scriptmonitor_alert_new_code_change_detections'
575 | 'scriptmonitor_alert_new_hosts'
576 | 'scriptmonitor_alert_new_malicious_hosts'
577 | 'scriptmonitor_alert_new_malicious_scripts'
578 | 'scriptmonitor_alert_new_malicious_url'
579 | 'scriptmonitor_alert_new_max_length_resource_url'
580 | 'scriptmonitor_alert_new_resources'
581 | 'secondary_dns_all_primaries_failing'
582 | 'secondary_dns_primaries_failing'
583 | 'secondary_dns_zone_successfully_updated'
584 | 'secondary_dns_zone_validation_warning'
585 | 'sentinel_alert'
586 | 'stream_live_notifications'
587 | 'traffic_anomalies_alert'
588 | 'tunnel_health_event'
589 | 'tunnel_update_event'
590 | 'universal_ssl_event_type'
591 | 'web_analytics_metrics_update'
592 | 'zone_aop_custom_certificate_expiration_type';
593
594 /**
595 * Body param: Optional description for the Notification policy.
596 */
597 description?: string;
598
599 /**
600 * Body param: Whether or not the Notification policy is enabled.
601 */
602 enabled?: boolean;
603
604 /**
605 * Body param: Optional filters that allow you to be alerted only on a subset of
606 * events for that alert type based on some criteria. This is only available for
607 * select alert types. See alert type documentation for more details.
608 */
609 filters?: PolicyFilter;
610
611 /**
612 * Body param: List of IDs that will be used when dispatching a notification. IDs
613 * for email type will be the email address.
614 */
615 mechanisms?: Mechanism;
616
617 /**
618 * Body param: Name of the policy.
619 */
620 name?: string;
621}
622
623export interface PolicyListParams {
624 /**
625 * The account id
626 */
627 account_id: string;
628}
629
630export interface PolicyDeleteParams {
631 /**
632 * The account id
633 */
634 account_id: string;
635}
636
637export interface PolicyGetParams {
638 /**
639 * The account id
640 */
641 account_id: string;
642}
643
644export namespace Policies {
645 export import Mechanism = PoliciesAPI.Mechanism;
646 export import Policy = PoliciesAPI.Policy;
647 export import PolicyFilter = PoliciesAPI.PolicyFilter;
648 export import PolicyCreateResponse = PoliciesAPI.PolicyCreateResponse;
649 export import PolicyUpdateResponse = PoliciesAPI.PolicyUpdateResponse;
650 export import PolicyDeleteResponse = PoliciesAPI.PolicyDeleteResponse;
651 export import PoliciesSinglePage = PoliciesAPI.PoliciesSinglePage;
652 export import PolicyCreateParams = PoliciesAPI.PolicyCreateParams;
653 export import PolicyUpdateParams = PoliciesAPI.PolicyUpdateParams;
654 export import PolicyListParams = PoliciesAPI.PolicyListParams;
655 export import PolicyDeleteParams = PoliciesAPI.PolicyDeleteParams;
656 export import PolicyGetParams = PoliciesAPI.PolicyGetParams;
657}
658