-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
106 changed files
with
1,637 additions
and
1,458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
engine/apps/api/serializers/alert_group_escalation_snapshot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from rest_framework import serializers | ||
|
||
from apps.api.serializers.custom_button import CustomButtonFastSerializer | ||
from apps.api.serializers.escalation_policy import EscalationPolicySerializer | ||
from apps.api.serializers.schedule_base import ScheduleFastSerializer | ||
from apps.api.serializers.user import FastUserSerializer | ||
from apps.api.serializers.user_group import UserGroupSerializer | ||
from apps.api.serializers.webhook import WebhookFastSerializer | ||
|
||
|
||
class EscalationPolicySnapshotAPISerializer(EscalationPolicySerializer): | ||
"""Serializes AlertGroup escalation policies snapshots for API endpoint""" | ||
|
||
notify_to_users_queue = FastUserSerializer(many=True, read_only=True) | ||
notify_schedule = ScheduleFastSerializer(read_only=True) | ||
notify_to_group = UserGroupSerializer(read_only=True) | ||
custom_button_trigger = CustomButtonFastSerializer(read_only=True) | ||
custom_webhook = WebhookFastSerializer(read_only=True) | ||
|
||
class Meta(EscalationPolicySerializer.Meta): | ||
fields = [ | ||
"step", | ||
"wait_delay", | ||
"notify_to_users_queue", | ||
"from_time", | ||
"to_time", | ||
"num_alerts_in_window", | ||
"num_minutes_in_window", | ||
"slack_integration_required", | ||
"custom_button_trigger", | ||
"custom_webhook", | ||
"notify_schedule", | ||
"notify_to_group", | ||
"important", | ||
] | ||
read_only_fields = fields | ||
|
||
|
||
class AlertGroupEscalationSnapshotAPISerializer(serializers.Serializer): | ||
"""Serializes AlertGroup escalation snapshot for API endpoint""" | ||
|
||
escalation_chain = serializers.SerializerMethodField() | ||
channel_filter = serializers.SerializerMethodField() | ||
escalation_policies = EscalationPolicySnapshotAPISerializer( | ||
source="escalation_policies_snapshots", many=True, read_only=True | ||
) | ||
|
||
class Meta: | ||
fields = ["escalation_chain", "channel_filter", "escalation_policies"] | ||
|
||
def get_escalation_chain(self, obj): | ||
return {"name": obj.escalation_chain_snapshot.name} | ||
|
||
def get_channel_filter(self, obj): | ||
return {"name": obj.channel_filter_snapshot.str_for_clients} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.