Esempio n. 1
0
 def post(self, request, pk, format=None):
     """Retrieve a subnet"""
     data = parse_request(request.DATA)
     if "auth" not in data:
         return Response(status=status.HTTP_400_BAD_REQUEST)
     subnets = get_subnets(data["auth"], {"id": pk})
     if not subnets:
         return Response(status=status.HTTP_404_NOT_FOUND)
     serializer = SubnetSerializer(subnets[0])
     return Response(serializer.data)
Esempio n. 2
0
 def post(self, request, pk, format=None):
     """Retrieve a subnet"""
     data = parse_request(request.DATA)
     if 'auth' not in data:
         return Response(status=status.HTTP_400_BAD_REQUEST)
     subnets = get_subnets(data['auth'], {'id': pk})
     if not subnets:
         return Response(status=status.HTTP_404_NOT_FOUND)
     serializer = SubnetSerializer(subnets[0])
     return Response(serializer.data)
Esempio n. 3
0
 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 "subnet" in data:
         subnet = add_subnet(data["auth"], data["subnet"])
         serializer = SubnetSerializer(subnet)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         subnets = get_subnets(data["auth"])
         serializer = SubnetSerializer(subnets, many=True)
         return Response(serializer.data)
Esempio n. 4
0
 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 'subnet' in data:
         subnet = add_subnet(data['auth'], data['subnet'])
         serializer = SubnetSerializer(subnet)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         subnets = get_subnets(data['auth'])
         serializer = SubnetSerializer(subnets, many=True)
         return Response(serializer.data)