1 | |
2 | |
3 | * Update alert rule |
4 | * Update an existing alert rule |
5 | */ |
6 | export async function main(auth: RT.Qovery, alertRuleId: string, body: AlertRuleEditRequest) { |
7 | const url = new URL(`https://api.qovery.com/api/alert-rules/${alertRuleId}`) |
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 | |
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 | |
32 | * Alert severity level: |
33 | * - WARNING: Non-critical issue requiring attention |
34 | * - CRITICAL: Critical issue requiring immediate action |
35 | */ |
36 | export type AlertSeverity = 'WARNING' | 'CRITICAL' |
37 |
|
38 | export interface AlertRuleEditRequest { |
39 | |
40 | * Name of the alert rule |
41 | */ |
42 | name: string |
43 | |
44 | * Description of what the alert monitors |
45 | */ |
46 | description: string |
47 | |
48 | * PromQL expression to evaluate |
49 | */ |
50 | promql_expr: string |
51 | |
52 | * Duration the condition must be true before firing (ISO-8601 duration format) |
53 | */ |
54 | for_duration: string |
55 | severity: AlertSeverity |
56 | |
57 | * Whether the alert rule is enabled |
58 | */ |
59 | enabled: boolean |
60 | |
61 | * List of alert receiver IDs to send notifications to |
62 | * |
63 | * @minItems 1 |
64 | */ |
65 | alert_receiver_ids: string[] |
66 | presentation: AlertPresentation |
67 | [k: string]: unknown |
68 | } |
69 | export interface AlertPresentation { |
70 | summary?: string |
71 | |
72 | * URL to runbook with remediation steps |
73 | */ |
74 | runbook_url?: string |
75 | [k: string]: unknown |
76 | } |
77 |
|