コード例 #1
0
 def put(self, request, pk, format=None):
     cluster = self.get_object(pk)
     serializer = ClusterSerializer(cluster,
                                    data=request.data,
                                    partial=True)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
コード例 #2
0
ファイル: views.py プロジェクト: csirving/nucleus-service
 def retrieve(self, request, cluster_name, format=None):
     """Obtain details about the named cluster."""
     clust = get_object_or_404(Cluster, name=cluster_name)
     if not clust.project in request.user.groups.all():
         raise PermissionDenied()
     serializer = ClusterSerializer(clust)
     return Response(serializer.data)
コード例 #3
0
 def post(self, request, format=None):
     serializer = ClusterSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
コード例 #4
0
 def get(self, request, pk, format=None):
     cluster = self.get_object(pk)
     serializer = ClusterSerializer(cluster)
     return Response(serializer.data)
コード例 #5
0
 def get(self, request, format=None):
     start = request.query_params.get('start', 0)
     num = request.query_params.get('num', 20)  # for pagination
     clusters = Cluster.objects.all()
     serializer = ClusterSerializer(clusters, many=True)
     return Response(serializer.data)