blob: a5efd367975d488d6b2ea829902cfe07554e4a56 [file] [log] [blame]
Tony Mack7130ac32013-03-22 21:58:00 -04001# Create your views here.
2
Tony Mackb1a54fb2013-03-29 12:06:46 -04003from plstackapi.core.models import Site
Tony Mack7130ac32013-03-22 21:58:00 -04004from serializers import *
5from rest_framework import generics
6from rest_framework.decorators import api_view
7from rest_framework.response import Response
8from rest_framework.reverse import reverse
9from rest_framework import renderers
10
11@api_view(['GET'])
12def api_root(request, format=None):
13 return Response({
14 'nodes': reverse('node-list', request=request, format=format),
15 'sites': reverse('site-list', request=request, format=format),
16 'deploymentNetworks': reverse('deploymentnetwork-list', request=request, format=format),
17 'slices': reverse('slice-list', request=request, format=format)
18 })
19
20class SiteList(generics.ListCreateAPIView):
21 model=Site
22 serializer_class = SiteSerializer
23
24class SiteDetail(generics.RetrieveUpdateDestroyAPIView):
25 model = Site
26 serializer_class = SiteSerializer
27
28class SliceList(generics.ListCreateAPIView):
29 model=Slice
30 serializer_class = SliceSerializer
31
32class SliceDetail(generics.RetrieveUpdateDestroyAPIView):
33 model = Slice
34 serializer_class = SliceSerializer
35
36class NodeList(generics.ListCreateAPIView):
37 model=Node
38 serializer_class = NodeSerializer
39
40class NodeDetail(generics.RetrieveUpdateDestroyAPIView):
41 model = Node
42 serializer_class = NodeSerializer
43
44class SliverList(generics.ListCreateAPIView):
45 model=Sliver
46 serializer_class = SliverSerializer
47
48class SliverDetail(generics.RetrieveUpdateDestroyAPIView):
49 model = Sliver
50 serializer_class = SliverSerializer
51
52class DeploymentNetworkList(generics.ListCreateAPIView):
53 model=DeploymentNetwork
54 serializer_class = DeploymentNetworkSerializer
55
56class DeploymentNetworkDetail(generics.RetrieveUpdateDestroyAPIView):
57 model = DeploymentNetwork
58 serializer_class = DeploymentNetworkSerializer
59
60class SiteDeploymentNetworkList(generics.ListCreateAPIView):
61 model=SiteDeploymentNetwork
62 serializer_class = SiteDeploymentNetworkSerializer
63
64class SiteDeploymentNetworkDetail(generics.RetrieveUpdateDestroyAPIView):
65 model = SiteDeploymentNetwork
66 serializer_class = DeploymentNetworkSerializer