Esempio n. 1
0
    def create(self, request, org, instance, auditlog=None, *args, **kwargs):

        data = request.data
        data["pdb_id"] = None
        data["instance"] = instance.id
        serializer = Serializers.ix(data=data)
        if not serializer.is_valid():
            return BadRequest(serializer.errors)
        ix = serializer.save()

        return Response(Serializers.ix(instance=ix).data)
Esempio n. 2
0
 def destroy(self,
             request,
             org,
             ix,
             instance,
             auditlog=None,
             *args,
             **kwargs):
     ix.delete()
     ix.id = request.data.get("id")
     return Response(Serializers.ix(instance=ix).data)
Esempio n. 3
0
    def update(self,
               request,
               org,
               ix,
               instance,
               auditlog=None,
               *args,
               **kwargs):
        serializer = Serializers.ix(
            ix,
            data=request.data,
        )

        if not serializer.is_valid():
            return BadRequest(serializer.errors)
        ix = serializer.save()
        ix.instance = instance
        ix.save()

        return Response(Serializers.ix(instance=ix).data)
Esempio n. 4
0
    def import_peeringdb(self,
                         request,
                         org,
                         instance,
                         auditlog=None,
                         *args,
                         **kwargs):

        serializer = Serializers.impix(
            data=request.data,
            context={"instance": instance},
        )

        if not serializer.is_valid():
            return BadRequest(serializer.errors)

        ix = serializer.save()

        auditlog.log("ix:import", log_object=ix, **request.data)

        return Response(Serializers.ix(instance=ix).data)
Esempio n. 5
0
 def retrieve(self, request, org, ix, instance, *args, **kwargs):
     serializer = Serializers.ix(
         instance=ix,
         many=False,
     )
     return Response(serializer.data)
Esempio n. 6
0
 def list(self, request, org, instance, *args, **kwargs):
     serializer = Serializers.ix(
         instance=models.InternetExchange.objects.filter(instance=instance),
         many=True,
     )
     return Response(serializer.data)