dr.botzo/dispatch/serializers.py

35 lines
954 B
Python
Raw Normal View History

"""Serializers for the dispatcher API objects."""
from rest_framework import serializers
from dispatch.models import Dispatcher, DispatcherAction
class DispatcherActionSerializer(serializers.ModelSerializer):
"""Serializer for the individual actions associated to a preconfigured dispatcher."""
class Meta:
"""Meta options."""
model = DispatcherAction
fields = ('id', 'dispatcher', 'action_type', 'destination')
class DispatcherSerializer(serializers.ModelSerializer):
"""Serializer for a dispatcher, a set of actions for a key."""
actions = DispatcherActionSerializer(many=True, read_only=True)
class Meta:
"""Meta options."""
model = Dispatcher
fields = ('id', 'key', 'actions')
class DispatchMessageSerializer(serializers.Serializer):
"""Serializer for dispatch messaging."""
message = serializers.CharField()
status = serializers.CharField(read_only=True)