oncall-engine/engine/apps/public_api/serializers/escalation_chains.py
Ildar Iskhakov 498e7ed5f3
Allow editing assigned team via public api (#1619)
# What this PR does

For example, changing the integration's team
```
curl "localhost:8080/api/v1/integrations/CLYV3QBVHDV3T/" \
  --request PUT \
  --header "Authorization: meow" \
  --header "Content-Type: application/json" --data '{"team_id": "TWP6JJJN6LYZX"}'
```

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-04-05 06:39:30 +00:00

20 lines
688 B
Python

from rest_framework import serializers
from apps.alerts.models import EscalationChain
from common.api_helpers.custom_fields import TeamPrimaryKeyRelatedField
from common.api_helpers.utils import CurrentOrganizationDefault
class EscalationChainSerializer(serializers.ModelSerializer):
id = serializers.ReadOnlyField(source="public_primary_key")
organization = serializers.HiddenField(default=CurrentOrganizationDefault())
team_id = TeamPrimaryKeyRelatedField(required=False, allow_null=True, source="team")
class Meta:
model = EscalationChain
fields = (
"id",
"name",
"organization",
"team_id",
)