clients.py 1.38 KB
Newer Older
1
2
# we don't need to deserialize, so we do not implement the abstract methods
# pylint: disable=abstract-method
3

Lukas Burgey's avatar
Lukas Burgey committed
4
from django_mysql.models import JSONField
5
from rest_framework import serializers
Lukas Burgey's avatar
Lukas Burgey committed
6

7
from ... import models
8
from . import GroupSerializer
9
10


Lukas Burgey's avatar
Lukas Burgey committed
11
12
13
class ServiceSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.Service
Lukas Burgey's avatar
Lukas Burgey committed
14
15
16
        fields = [
            'name',
        ]
Lukas Burgey's avatar
Lukas Burgey committed
17
18


19
class UserSerializer(serializers.ModelSerializer):
Lukas Burgey's avatar
Lukas Burgey committed
20
    groups = GroupSerializer(many=True)
Lukas Burgey's avatar
Lukas Burgey committed
21
    userinfo = JSONField()
22
23

    class Meta:
Lukas Burgey's avatar
Lukas Burgey committed
24
        model = models.User
Lukas Burgey's avatar
Lukas Burgey committed
25
        fields = ['email', 'groups', 'userinfo']
26
27


28
class NewDeploymentSerializer(serializers.ModelSerializer):
29
    user = UserSerializer()
Lukas Burgey's avatar
Lukas Burgey committed
30
    service = ServiceSerializer()
31
    group = GroupSerializer()
32
33

    class Meta:
34
        model = models.NewDeployment
35
        fields = [
36
37
            'state_target',
            'id',
38
            'service',
39
40
            'group',
            'user',
41
        ]
42
43


44
class NewDeploymentsSerializer(serializers.Serializer):
45
    services = serializers.DictField(
46
        child=serializers.ListField(
47
            child=NewDeploymentSerializer()
48
49
        )
    )
50
51
52



53
54
#class SiteSerializer(serializers.Serializer):
#    state_items = NewDeploymentStateItemSerializer(many=True)
55
56
57
58


class RabbitMQInstanceSerializer(serializers.ModelSerializer):
    class Meta:
Lukas Burgey's avatar
Lukas Burgey committed
59
        model = models.RabbitMQInstance
Lukas Burgey's avatar
Lukas Burgey committed
60
        fields = ['vhost']