Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
feudal
feudalBackend
Commits
58065194
Commit
58065194
authored
Mar 16, 2018
by
Lukas Burgey
Browse files
Adapt so clients can fetch rabbitmq parameters from us
parent
07637b37
Changes
3
Hide whitespace changes
Inline
Side-by-side
django_backend/backend/clientapi/serializers.py
View file @
58065194
...
...
@@ -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'
]
django_backend/backend/clientapi/views.py
View file @
58065194
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
.
List
APIView
):
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
):
...
...
django_backend/backend/models.py
View file @
58065194
...
...
@@ -65,6 +65,7 @@ class RabbitMQInstance(SingletonModel):
port
=
models
.
IntegerField
(
default
=
15672
,
)
# TODO obsolete
path
=
models
.
CharField
(
max_length
=
150
,
default
=
'api'
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment