//native
/**
* Update a spike protection notification action
* Updates a Spike Protection Notification Action.
Notification Actions notify a set of members when an action has been triggered through a notification service such as Slack or Sentry.
For example, organization owners and managers can receive an email when a spike occurs.
*/
export async function main(auth: RT.Sentry, action_id: string, body: Body) {
const url = new URL(
`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/notifications/actions/${action_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.
*/
/**
* Django Rest Framework serializer for incoming NotificationAction API payloads
*/
export interface Body {
/**
* Type of the trigger that causes the notification. The only supported trigger right now is: `spike-protection`.
*/
trigger_type: string
/**
* Service that is used for sending the notification.
* - `email`
* - `slack`
* - `sentry_notification`
* - `pagerduty`
* - `opsgenie`
*
*/
service_type: string
/**
* ID of the integration used as the notification service. See
* [List Integrations](https://docs.sentry.io/api/integrations/list-an-organizations-available-integrations/)
* to retrieve a full list of integrations.
*
* Required if **service_type** is `slack`, `pagerduty` or `opsgenie`.
*
*/
integration_id?: number
/**
* ID of the notification target, like a Slack channel ID.
*
* Required if **service_type** is `slack` or `opsgenie`.
*
*/
target_identifier?: string
/**
* Name of the notification target, like a Slack channel name.
*
* Required if **service_type** is `slack` or `opsgenie`.
*
*/
target_display?: string
/**
* List of projects slugs that the Notification Action is created for.
*/
projects?: string[]
[k: string]: unknown
}
Submitted by hugo697 235 days ago