2015-06-18 23:57:43 -05:00
|
|
|
"""Serializers for the dispatcher API objects."""
|
|
|
|
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
2015-06-19 11:29:00 -05:00
|
|
|
from dispatch.models import Dispatcher, DispatcherAction
|
2015-06-18 23:57:43 -05:00
|
|
|
|
|
|
|
|
2015-06-19 15:08:57 -05:00
|
|
|
class DispatcherActionSerializer(serializers.ModelSerializer):
|
2017-02-12 11:58:20 -06:00
|
|
|
"""Serializer for the individual actions associated to a preconfigured dispatcher."""
|
2015-06-18 23:57:43 -05:00
|
|
|
|
|
|
|
class Meta:
|
2017-02-12 11:58:20 -06:00
|
|
|
"""Meta options."""
|
|
|
|
|
2015-06-19 15:08:57 -05:00
|
|
|
model = DispatcherAction
|
2023-02-28 18:25:02 -06:00
|
|
|
fields = ('id', 'dispatcher', 'action_type', 'destination')
|
2015-06-19 11:29:00 -05:00
|
|
|
|
|
|
|
|
2015-06-19 15:08:57 -05:00
|
|
|
class DispatcherSerializer(serializers.ModelSerializer):
|
2017-02-12 11:58:20 -06:00
|
|
|
"""Serializer for a dispatcher, a set of actions for a key."""
|
2015-06-19 15:08:57 -05:00
|
|
|
|
|
|
|
actions = DispatcherActionSerializer(many=True, read_only=True)
|
2015-06-19 11:29:00 -05:00
|
|
|
|
|
|
|
class Meta:
|
2017-02-12 11:58:20 -06:00
|
|
|
"""Meta options."""
|
|
|
|
|
2015-06-19 15:08:57 -05:00
|
|
|
model = Dispatcher
|
|
|
|
fields = ('id', 'key', 'actions')
|
2015-06-18 23:57:43 -05:00
|
|
|
|
|
|
|
|
|
|
|
class DispatchMessageSerializer(serializers.Serializer):
|
2017-02-12 11:58:20 -06:00
|
|
|
"""Serializer for dispatch messaging."""
|
2015-06-18 23:57:43 -05:00
|
|
|
|
|
|
|
message = serializers.CharField()
|
2015-06-19 10:51:11 -05:00
|
|
|
status = serializers.CharField(read_only=True)
|