2020-09-02 22:04:12 +00:00
|
|
|
"""Outpost API Views"""
|
|
|
|
from rest_framework.serializers import JSONField, ModelSerializer
|
|
|
|
from rest_framework.viewsets import ModelViewSet
|
|
|
|
|
2020-11-04 10:04:18 +00:00
|
|
|
from passbook.outposts.models import (
|
|
|
|
DockerServiceConnection,
|
|
|
|
KubernetesServiceConnection,
|
|
|
|
Outpost,
|
|
|
|
)
|
2020-09-02 22:04:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OutpostSerializer(ModelSerializer):
|
|
|
|
"""Outpost Serializer"""
|
|
|
|
|
|
|
|
_config = JSONField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = Outpost
|
2020-11-04 09:41:18 +00:00
|
|
|
fields = ["pk", "name", "providers", "service_connection", "_config"]
|
2020-09-02 22:04:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OutpostViewSet(ModelViewSet):
|
|
|
|
"""Outpost Viewset"""
|
|
|
|
|
|
|
|
queryset = Outpost.objects.all()
|
|
|
|
serializer_class = OutpostSerializer
|
2020-11-04 10:04:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DockerServiceConnectionSerializer(ModelSerializer):
|
|
|
|
"""DockerServiceConnection Serializer"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = DockerServiceConnection
|
|
|
|
fields = ["pk", "name", "local", "url", "tls"]
|
|
|
|
|
|
|
|
|
|
|
|
class DockerServiceConnectionViewSet(ModelViewSet):
|
|
|
|
"""DockerServiceConnection Viewset"""
|
|
|
|
|
|
|
|
queryset = DockerServiceConnection.objects.all()
|
|
|
|
serializer_class = DockerServiceConnectionSerializer
|
|
|
|
|
|
|
|
|
|
|
|
class KubernetesServiceConnectionSerializer(ModelSerializer):
|
|
|
|
"""KubernetesServiceConnection Serializer"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = KubernetesServiceConnection
|
2020-11-04 12:01:38 +00:00
|
|
|
fields = ["pk", "name", "local", "kubeconfig"]
|
2020-11-04 10:04:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
class KubernetesServiceConnectionViewSet(ModelViewSet):
|
|
|
|
"""KubernetesServiceConnection Viewset"""
|
|
|
|
|
|
|
|
queryset = KubernetesServiceConnection.objects.all()
|
|
|
|
serializer_class = KubernetesServiceConnectionSerializer
|