dynamicweb/opennebula_api/views.py
Modulos ef00d676f5 Access VirtualMachine via api!
Serialization of VirtualMachine objects now fully works
2017-05-11 05:51:30 +02:00

35 lines
1.4 KiB
Python

from rest_framework import generics
from .serializers import VirtualMachineTemplateSerializer, \
VirtualMachineSerializer
from .models import VirtualMachineTemplate, VirtualMachine, OpenNebulaManager
class TemplateCreateView(generics.ListCreateAPIView):
"""This class defines the create behavior of our rest api."""
queryset = VirtualMachineTemplate.objects.all()
serializer_class = VirtualMachineTemplateSerializer
def perform_create(self, serializer):
"""Save the post data when creating a new template."""
serializer.save()
class TemplateDetailsView(generics.RetrieveUpdateDestroyAPIView):
"""This class handles the http GET, PUT and DELETE requests."""
queryset = VirtualMachineTemplate.objects.all()
serializer_class = VirtualMachineTemplateSerializer
class VmCreateView(generics.ListCreateAPIView):
"""This class defines the create behavior of our rest api."""
queryset = VirtualMachine.objects.all()
serializer_class = VirtualMachineSerializer
def perform_create(self, serializer):
"""Save the post data when creating a new template."""
serializer.save()
class VmDetailsView(generics.RetrieveUpdateDestroyAPIView):
"""This class handles the http GET, PUT and DELETE requests."""
queryset = VirtualMachine.objects.all()
serializer_class = VirtualMachineSerializer