Exemplo 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)
Exemplo 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)
Exemplo n.º 3
0
    def put(self, request, pk, format=None):
        """update a subnet"""
        data = parse_request(request.DATA)
        if "auth" not in data:
            return Response(status=status.HTTP_400_BAD_REQUEST)
        elif "subnet" not in data:
            return Response(status=status.HTTP_400_BAD_REQUEST)

        subnet = update_subnet(pk, data["subnet"])
        serializer = SubnetSerializer(subnet)
        return Response(serializer.data)
Exemplo n.º 4
0
    def put(self, request, pk, format=None):
        """update a subnet"""
        data = parse_request(request.DATA)
        if 'auth' not in data:
            return Response(status=status.HTTP_400_BAD_REQUEST)
        elif 'subnet' not in data:
            return Response(status=status.HTTP_400_BAD_REQUEST)

        subnet = update_subnet(pk, data['subnet'])
        serializer = SubnetSerializer(subnet)
        return Response(serializer.data)
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
 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_subnet(data["auth"], {"id": pk})
     return Response(status=status.HTTP_204_NO_CONTENT)
Exemplo n.º 8
0
 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_subnet(data['auth'], {'id': pk})
     return Response(status=status.HTTP_204_NO_CONTENT)