oncall-engine/engine/apps/alerts/models/alert_receive_channel_connection.py
Vadim Stepanov 5074a16861
SNOW external ID (#4076)
# What this PR does

- Adds a new model `AlertGroupExternalID` to keep track of incident IDs
in external systems
- Adds calls to integration config specific functions on alert group
creation and webhook response

## Which issue(s) this PR closes

Related to https://github.com/grafana/oncall-private/issues/2541

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-03-20 10:54:27 +00:00

39 lines
1.5 KiB
Python

from django.db import models
class AlertReceiveChannelConnection(models.Model):
"""
This model represents a connection between two integrations (e.g. when an Alertmanager integration is connected to a
ServiceNow integration).
"""
source_alert_receive_channel = models.ForeignKey(
"AlertReceiveChannel", on_delete=models.CASCADE, related_name="connected_alert_receive_channels"
)
connected_alert_receive_channel = models.ForeignKey(
"AlertReceiveChannel", on_delete=models.CASCADE, related_name="source_alert_receive_channels"
)
backsync = models.BooleanField(default=False)
class Meta:
ordering = ["source_alert_receive_channel", "connected_alert_receive_channel"]
unique_together = ("source_alert_receive_channel", "connected_alert_receive_channel")
class AlertGroupExternalID(models.Model):
"""
This model represents an external ID for an alert group. This is used to keep track of the alert group in
the external system (e.g. ServiceNow).
"""
source_alert_receive_channel = models.ForeignKey(
"AlertReceiveChannel", on_delete=models.CASCADE, related_name="external_ids"
)
alert_group = models.ForeignKey("AlertGroup", on_delete=models.CASCADE, related_name="external_ids")
value = models.CharField(max_length=512)
class Meta:
unique_together = ("source_alert_receive_channel", "alert_group")
indexes = [
models.Index(fields=["value"]),
]