oncall-engine/engine/apps/api/serializers/alert_receive_channel_connection.py
Vadim Stepanov cf1fac8997
Backend support for "connected" integrations (#4030)
# What this PR does

Adds a Django model and internal API for connected integrations. Based
on https://github.com/grafana/oncall/pull/3983

## Which issue(s) this PR closes

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

## 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-07 17:47:33 +00:00

36 lines
1.5 KiB
Python

from rest_framework import serializers
from apps.alerts.models import AlertReceiveChannel, AlertReceiveChannelConnection
from apps.api.serializers.alert_receive_channel import FastAlertReceiveChannelSerializer
class AlertReceiveChannelSourceChannelSerializer(serializers.ModelSerializer):
alert_receive_channel = FastAlertReceiveChannelSerializer(source="source_alert_receive_channel", read_only=True)
backsync = serializers.BooleanField()
class Meta:
model = AlertReceiveChannelConnection
fields = ["alert_receive_channel", "backsync"]
class AlertReceiveChannelConnectedChannelSerializer(serializers.ModelSerializer):
alert_receive_channel = FastAlertReceiveChannelSerializer(source="connected_alert_receive_channel", read_only=True)
backsync = serializers.BooleanField()
class Meta:
model = AlertReceiveChannelConnection
fields = ["alert_receive_channel", "backsync"]
class AlertReceiveChannelConnectionSerializer(serializers.ModelSerializer):
source_alert_receive_channels = AlertReceiveChannelSourceChannelSerializer(read_only=True, many=True)
connected_alert_receive_channels = AlertReceiveChannelConnectedChannelSerializer(read_only=True, many=True)
class Meta:
model = AlertReceiveChannel
fields = ["source_alert_receive_channels", "connected_alert_receive_channels"]
class AlertReceiveChannelNewConnectionSerializer(serializers.Serializer):
id = serializers.CharField()
backsync = serializers.BooleanField()