0

Update Alert

by
Published Oct 17, 2025

Update a specific preset alert.

Script mezmo Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Update Alert
4
 * Update a specific preset alert.
5
 */
6
export async function main(auth: RT.Mezmo, presetId: string, body: Body) {
7
	const url = new URL(`https://api.mezmo.com/v1/config/presetalert/${presetId}`)
8

9
	const response = await fetch(url, {
10
		method: 'PUT',
11
		headers: {
12
			'Content-Type': 'application/json',
13
			Authorization: 'Token ' + auth.apiKey
14
		},
15
		body: JSON.stringify(body)
16
	})
17
	if (!response.ok) {
18
		const text = await response.text()
19
		throw new Error(`${response.status} ${text}`)
20
	}
21
	return await response.json()
22
}
23

24
/* eslint-disable */
25
/**
26
 * This file was automatically generated by json-schema-to-typescript.
27
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
28
 * and run json-schema-to-typescript to regenerate this file.
29
 */
30

31
export interface Body {
32
	/**
33
	 * Name of a view.
34
	 */
35
	name?: string
36
	channels?: {
37
		/**
38
		 * Defines the type of notification channel. Valid values are: `email`, `webhook`, `slack`, and `pagerduty`
39
		 */
40
		integration?: string
41
		emails?: string[]
42
		/**
43
		 * Webhook URL.
44
		 */
45
		url?: string
46
		/**
47
		 * PagerDuty key.
48
		 */
49
		key?: string
50
		/**
51
		 * Specify the number of log lines that match the view's filtering and search criteria. When the number of log lines is reached, an alert is triggered.
52
		 */
53
		triggerlimit?: string
54
		/**
55
		 * Specify how often to trigger an alert. Valid values are: 30 seconds, 1 minute, 5 minutes, 15 minutes, 30 minutes, 1 hour, 6 hours, 12 hours, 24 hours
56
		 */
57
		triggerinterval?: string
58
		/**
59
		 * Set to true if you want the trigger condition to be evaluated as soon as the triggerlimit is reached.
60
		 */
61
		immediate?: boolean
62
		/**
63
		 * Set to true if you want the trigger condition to be evaluated after the time that you specify in the triggerinterval field is reached.
64
		 */
65
		terminal?: boolean
66
		/**
67
		 * Type of alert. Valid values are: `presence`and `absence`.
68
		 */
69
		operator?: string
70
		/**
71
		 * Timezone used to report timestamps. This can be any value defined in the tz database https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
72
		 */
73
		timezone?: string
74
		/**
75
		 * WebHook method such as POST.
76
		 */
77
		method?: 'POST' | 'PUT' | 'PATCH'
78
		headers?: {
79
			/**
80
			 * Header value
81
			 */
82
			timestamp?: string
83
			[k: string]: unknown
84
		}
85
		bodyTemplate?: {
86
			/**
87
			 * Define the webhook body.
88
			 */
89
			timestamp?: string
90
			[k: string]: unknown
91
		}
92
		/**
93
		 * Set to true if you want the set a condition to resolve the incident that was raised by this alert.  This property only applies to PagerDuty.
94
		 */
95
		autoresolve?: boolean
96
		/**
97
		 * Interval of time to aggregate and check # of matched lines against the auto resolve limit. Valid values are: 30 seconds, 1 minute, 5 minutes, 15 minutes, 30 minutes, 1 hour, 6 hours, 12 hours, 24 hours, 25 hours.
98
		 */
99
		autoresolveinterval?: string
100
		/**
101
		 * Specify the number of log lines that match the view's filtering and search criteria. When the number of log lines is reached, this incident will be set to resolved in PagerDuty.
102
		 */
103
		autoresolvelimit?: string
104
		[k: string]: unknown
105
	}[]
106
	[k: string]: unknown
107
}
108