1 | |
2 | |
3 | * Update an issue alert rule |
4 | * Updates an issue alert rule. |
5 | */ |
6 | export async function main( |
7 | auth: RT.Sentry, |
8 | project_id_or_slug: string, |
9 | rule_id: string, |
10 | body: Body |
11 | ) { |
12 | const url = new URL( |
13 | `https://${auth.region}.sentry.io/api/0/projects/${auth.organizationSlug}/${project_id_or_slug}/rules/${rule_id}/` |
14 | ) |
15 |
|
16 | const response = await fetch(url, { |
17 | method: 'PUT', |
18 | headers: { |
19 | 'Content-Type': 'application/json', |
20 | Authorization: 'Bearer ' + auth.token |
21 | }, |
22 | body: JSON.stringify(body) |
23 | }) |
24 | if (!response.ok) { |
25 | const text = await response.text() |
26 | throw new Error(`${response.status} ${text}`) |
27 | } |
28 | return await response.json() |
29 | } |
30 |
|
31 | |
32 | |
33 | * This file was automatically generated by json-schema-to-typescript. |
34 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
35 | * and run json-schema-to-typescript to regenerate this file. |
36 | */ |
37 |
|
38 | export interface Body { |
39 | |
40 | * The name for the rule. |
41 | */ |
42 | name: string |
43 | |
44 | * A string determining which of the conditions need to be true before any filters are evaluated. |
45 | * |
46 | * * `all` - All conditions must evaluate to true. |
47 | * * `any` - At least one of the conditions must evaluate to true. |
48 | * * `none` - All conditions must evaluate to false. |
49 | */ |
50 | actionMatch: 'all' | 'any' | 'none' |
51 | |
52 | * A list of triggers that determine when the rule fires. See [Create an Issue Alert Rule](/api/alerts/create-an-issue-alert-rule-for-a-project) for valid conditions. |
53 | */ |
54 | conditions: { |
55 | [k: string]: unknown |
56 | }[] |
57 | |
58 | * A list of actions that take place when all required conditions and filters for the rule are met. See [Create an Issue Alert Rule](/api/alerts/create-an-issue-alert-rule-for-a-project) for valid actions. |
59 | */ |
60 | actions: { |
61 | [k: string]: unknown |
62 | }[] |
63 | |
64 | * How often to perform the actions once for an issue, in minutes. The valid range is `5` to `43200`. |
65 | */ |
66 | frequency: number |
67 | |
68 | * The name of the environment to filter by. |
69 | */ |
70 | environment?: string |
71 | |
72 | * A string determining which filters need to be true before any actions take place. |
73 | * |
74 | * * `all` - All filters must evaluate to true. |
75 | * * `any` - At least one of the filters must evaluate to true. |
76 | * * `none` - All filters must evaluate to false. |
77 | */ |
78 | filterMatch?: 'all' | 'any' | 'none' |
79 | |
80 | * A list of filters that determine if a rule fires after the necessary conditions have been met. See [Create an Issue Alert Rule](/api/alerts/create-an-issue-alert-rule-for-a-project) for valid filters. |
81 | */ |
82 | filters?: { |
83 | [k: string]: unknown |
84 | }[] |
85 | |
86 | * The ID of the team or user that owns the rule. |
87 | */ |
88 | owner?: string |
89 | [k: string]: unknown |
90 | } |
91 |
|