oncall-engine/engine/apps/api/views
Joey Orlando 06933a696a
Support alert routing based on labels (#3778)
# What this PR does

This PR adds support for routing alerts based on labels.
https://www.loom.com/share/4401de6e3c4945d5b8961fe43ee373c9

Additionally:
- improve the typing around the `get_object` method that is inherited by
[`PublicPrimaryKeyMixin.get_object`](https://github.com/grafana/oncall/blob/dev/engine/common/api_helpers/mixins.py#L153)
in most of our models. `PublicPrimaryKeyMixin` is generic, so it can be
more strongly typed when it is being subclassed, which results in better
typing of the `get_object` method in child classes
- I decided to do this because I started looking into this task via the
[`AlertReceiveChannelView.send_demo_alert`
method/endpoint](https://github.com/grafana/oncall/blob/dev/engine/apps/api/views/alert_receive_channel.py#L242).
Within that method, `instance` is not typed because the inherited
`get_object` method is not typed.. I digress 😄
- improve typing around `Alert.create` and
`apps.integrations.tasks.create_alert` functions
- make `Alert.render_group_data` more DRY by extracting some logic out
into `Alert._apply_jinja_template_to_alert_payload_and_labels`
- deduplicate the logic of `value.strip().lower() in ["1", "true",
"ok"]` into a shared function,
`common.jinja_templater.apply_jinja_template.templated_value_is_truthy`

Closes https://github.com/grafana/oncall-private/issues/2490

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
- [x] Documentation added (or `pr:no public docs` PR label added if not
required) (will be done in #3762)
2024-01-30 13:07:19 -05:00
..
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
alert_group.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
alert_group_table_settings.py Alert group column/label selector (#3281) 2023-11-29 12:11:31 +00:00
alert_receive_channel.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
alert_receive_channel_template.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
alerts.py Add alert detail view (#385) 2022-08-19 14:03:07 +05:00
auth.py Enable flake8-bugbear, fix issues (#3454) 2023-11-29 15:04:48 +00:00
channel_filter.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
custom_button.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
escalation_chain.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
escalation_policy.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
features.py Improve OpenAPI schema coverage (#3629) 2024-01-12 15:11:22 +00:00
integration_heartbeat.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
labels.py Improve OpenAPI schema coverage (#3629) 2024-01-12 15:11:22 +00:00
live_setting.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
on_call_shifts.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
organization.py Handle None role when syncing users from Grafana (#3147) 2023-10-19 17:39:08 +00:00
paging.py Let mobile use paging endpoint (#3619) 2024-01-08 12:18:39 +00:00
preview_template_options.py Fix of templates api behaviour for public and private api (#1408) 2023-03-01 16:32:15 +08:00
public_api_tokens.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
resolution_note.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
route_regex_debugger.py remove references to AlertGroup.is_archived and AlertGroup.unarchived_objects (#2524) 2023-07-18 11:48:34 +00:00
schedule.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
shift_swap.py Notify user when their shift swap request is taken (#2992) 2023-09-07 14:59:54 +00:00
slack_channel.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
slack_team_settings.py Handle None role when syncing users from Grafana (#3147) 2023-10-19 17:39:08 +00:00
team.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
telegram_channels.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
user.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
user_group.py Handle None role when syncing users from Grafana (#3147) 2023-10-19 17:39:08 +00:00
user_notification_policy.py WIP: Direct paging improvements (#3064) 2023-09-28 03:57:49 +00:00
webhooks.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00