Commit 58065194 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Adapt so clients can fetch rabbitmq parameters from us

parent 07637b37
......@@ -48,3 +48,9 @@ class DeploymentTaskSerializer(serializers.Serializer):
class SiteSerializer(serializers.Serializer):
tasks = DeploymentTaskSerializer(many=True)
class RabbitMQInstanceSerializer(serializers.ModelSerializer):
class Meta:
model = models.RabbitMQInstance
fields = ['vhost', 'exchange']
import logging
from rest_framework import generics, views
from rest_framework.authentication import TokenAuthentication, BasicAuthentication
from rest_framework.authentication import BasicAuthentication
from rest_framework.response import Response
from .serializers import SiteSerializer, ServiceSerializer
from .serializers import SiteSerializer, ServiceSerializer, RabbitMQInstanceSerializer
from ..models import RabbitMQInstance
LOGGER = logging.getLogger(__name__)
......@@ -21,13 +22,22 @@ class DeploymentsView(generics.RetrieveAPIView):
# the client has to fetch the configuration (like services etc.) here
class ConfigurationView(generics.ListAPIView):
class ConfigurationView(views.APIView):
authentication_classes = AUTHENTICATION_CLASSES
serializer_class = ServiceSerializer
def get_queryset(self):
site = self.request.user.site
return site.services.all()
def get(self, request):
response = {
'services': ServiceSerializer(
request.user.site.services.all(),
many=True,
).data,
'rabbitmq_config': RabbitMQInstanceSerializer(
RabbitMQInstance.load(),
).data,
}
LOGGER.debug('Config: %s', response)
return Response(response)
class AckView(views.APIView):
......
......@@ -65,6 +65,7 @@ class RabbitMQInstance(SingletonModel):
port = models.IntegerField(
default=15672,
)
# TODO obsolete
path = models.CharField(
max_length=150,
default='api',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment