Refactor to /opt/planetstack, final tweaks to make sure planetstack can run in non-openstack mode, adjustments to GUI for model focus changes
diff --git a/planetstack/core/views/slivers.py b/planetstack/core/views/slivers.py
new file mode 100644
index 0000000..3741cce
--- /dev/null
+++ b/planetstack/core/views/slivers.py
@@ -0,0 +1,66 @@
+from django.http import Http404
+from rest_framework.views import APIView
+from rest_framework.response import Response
+from rest_framework import status
+
+from core.api.slivers import add_sliver, delete_sliver, get_slivers, update_sliver
+from core.serializers import SliverSerializer
+from util.request import parse_request
+
+
+class SliverListCreate(APIView):
+ """
+ List all slivers or create a new sliver.
+ """
+
+ def post(self, request, format = None):
+ data = parse_request(request.DATA)
+ if 'auth' not in data:
+ return Response(status=status.HTTP_400_BAD_REQUEST)
+ elif 'sliver' in data:
+ sliver = add_sliver(data['auth'], data['sliver'])
+ serializer = SliverSerializer(sliver)
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
+ else:
+ slivers = get_slivers(data['auth'])
+ serializer = SliverSerializer(slivers, many=True)
+ return Response(serializer.data)
+
+
+class SliverRetrieveUpdateDestroy(APIView):
+ """
+ Retrieve, update or delete a sliver
+ """
+
+ def post(self, request, pk, format=None):
+ """Retrieve a sliver"""
+ data = parse_request(request.DATA)
+ if 'auth' not in data:
+ return Response(status=status.HTTP_400_BAD_REQUEST)
+ slivers = get_slivers(data['auth'], pk)
+ if not slivers:
+ return Response(status=status.HTTP_404_NOT_FOUND)
+ serializer = SliverSerializer(slivers[0])
+ return Response(serializer.data)
+
+ def put(self, request, pk, format=None):
+ """update a sliver"""
+ data = parse_request(request.DATA)
+ if 'auth' not in data:
+ return Response(status=status.HTTP_400_BAD_REQUEST)
+ elif 'sliver' not in data:
+ return Response(status=status.HTTP_400_BAD_REQUEST)
+
+ sliver = update_sliver(pk, data['sliver'])
+ serializer = SliverSerializer(sliver)
+ return Response(serializer.data)
+
+ def delete(self, request, pk, format=None):
+ data = parse_request(request.DATA)
+ if 'auth' not in data:
+ return Response(status=status.HTTP_400_BAD_REQUEST)
+ delete_sliver(data['auth'], pk)
+ return Response(status=status.HTTP_204_NO_CONTENT)
+
+
+