Tony Mack | 7130ac3 | 2013-03-22 21:58:00 -0400 | [diff] [blame] | 1 | # Create your views here. |
| 2 | |
Tony Mack | b1a54fb | 2013-03-29 12:06:46 -0400 | [diff] [blame] | 3 | from plstackapi.core.models import Site |
Tony Mack | 7130ac3 | 2013-03-22 21:58:00 -0400 | [diff] [blame] | 4 | from serializers import * |
| 5 | from rest_framework import generics |
| 6 | from rest_framework.decorators import api_view |
| 7 | from rest_framework.response import Response |
| 8 | from rest_framework.reverse import reverse |
| 9 | from rest_framework import renderers |
| 10 | |
| 11 | @api_view(['GET']) |
| 12 | def 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 | |
| 20 | class SiteList(generics.ListCreateAPIView): |
| 21 | model=Site |
| 22 | serializer_class = SiteSerializer |
| 23 | |
| 24 | class SiteDetail(generics.RetrieveUpdateDestroyAPIView): |
| 25 | model = Site |
| 26 | serializer_class = SiteSerializer |
| 27 | |
| 28 | class SliceList(generics.ListCreateAPIView): |
| 29 | model=Slice |
| 30 | serializer_class = SliceSerializer |
| 31 | |
| 32 | class SliceDetail(generics.RetrieveUpdateDestroyAPIView): |
| 33 | model = Slice |
| 34 | serializer_class = SliceSerializer |
| 35 | |
| 36 | class NodeList(generics.ListCreateAPIView): |
| 37 | model=Node |
| 38 | serializer_class = NodeSerializer |
| 39 | |
| 40 | class NodeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 41 | model = Node |
| 42 | serializer_class = NodeSerializer |
| 43 | |
| 44 | class SliverList(generics.ListCreateAPIView): |
| 45 | model=Sliver |
| 46 | serializer_class = SliverSerializer |
| 47 | |
| 48 | class SliverDetail(generics.RetrieveUpdateDestroyAPIView): |
| 49 | model = Sliver |
| 50 | serializer_class = SliverSerializer |
| 51 | |
| 52 | class DeploymentNetworkList(generics.ListCreateAPIView): |
| 53 | model=DeploymentNetwork |
| 54 | serializer_class = DeploymentNetworkSerializer |
| 55 | |
| 56 | class DeploymentNetworkDetail(generics.RetrieveUpdateDestroyAPIView): |
| 57 | model = DeploymentNetwork |
| 58 | serializer_class = DeploymentNetworkSerializer |
| 59 | |
| 60 | class SiteDeploymentNetworkList(generics.ListCreateAPIView): |
| 61 | model=SiteDeploymentNetwork |
| 62 | serializer_class = SiteDeploymentNetworkSerializer |
| 63 | |
| 64 | class SiteDeploymentNetworkDetail(generics.RetrieveUpdateDestroyAPIView): |
| 65 | model = SiteDeploymentNetwork |
| 66 | serializer_class = DeploymentNetworkSerializer |