dynamicweb/opennebula_api/views.py
Modulos cbc13de34f Access VirtualMachineTemplates via api!
Serialization of VirtualMachineTemplates now fully works
2017-05-11 04:05:58 +02:00

18 lines
761 B
Python

from rest_framework import generics
from .serializers import VirtualMachineTemplateSerializer
from .models import VirtualMachineTemplate, 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