//native
/**
* Update an issue alert rule
* Updates an issue alert rule.
*/
export async function main(
auth: RT.Sentry,
project_id_or_slug: string,
rule_id: string,
body: Body
) {
const url = new URL(
`https://${auth.region}.sentry.io/api/0/projects/${auth.organizationSlug}/${project_id_or_slug}/rules/${rule_id}/`
)
const response = await fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
export interface Body {
/**
* The name for the rule.
*/
name: string
/**
* A string determining which of the conditions need to be true before any filters are evaluated.
*
* * `all` - All conditions must evaluate to true.
* * `any` - At least one of the conditions must evaluate to true.
* * `none` - All conditions must evaluate to false.
*/
actionMatch: 'all' | 'any' | 'none'
/**
* 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.
*/
conditions: {
[k: string]: unknown
}[]
/**
* 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.
*/
actions: {
[k: string]: unknown
}[]
/**
* How often to perform the actions once for an issue, in minutes. The valid range is `5` to `43200`.
*/
frequency: number
/**
* The name of the environment to filter by.
*/
environment?: string
/**
* A string determining which filters need to be true before any actions take place.
*
* * `all` - All filters must evaluate to true.
* * `any` - At least one of the filters must evaluate to true.
* * `none` - All filters must evaluate to false.
*/
filterMatch?: 'all' | 'any' | 'none'
/**
* 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.
*/
filters?: {
[k: string]: unknown
}[]
/**
* The ID of the team or user that owns the rule.
*/
owner?: string
[k: string]: unknown
}
Submitted by hugo697 235 days ago