def update(self, request, org, instance, ix, routeserver, *args, **kwargs): serializer = Serializers.rs(data=request.data, instance=routeserver, context={"instance": instance}) if not serializer.is_valid(): return BadRequest(serializer.errors) routeserver = serializer.save() return Response(Serializers.rs(instance=routeserver).data)
def create(self, request, org, instance, ix, *args, **kwargs): data = request.data data["ix"] = models.InternetExchange.objects.get(instance=instance, id=ix.pk).id serializer = Serializers.rs(data=data, context={"instance": instance}) if not serializer.is_valid(): return BadRequest(serializer.errors) routeserver = serializer.save() return Response(Serializers.rs(instance=routeserver).data)
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)
def retrieve(self, request, org, instance, ix, name, *args, **kwargs): rs_config = self.get_object() serializer = Serializers.rsconf( instance=rs_config, many=False, ) return Response(serializer.data)
def plain(self, request, org, instance, ix, name, *args, **kwargs): rs_config = self.get_object() serializer = Serializers.rsconf( instance=rs_config, many=False, ) # return Response(serializer.instance.body) return Response(serializer.instance.body)
def list(self, request, org, *args, **kwargs): serializer = Serializers.permreq( org.permreq_set.all(), many=True, context={ "user": request.user, "perms": request.perms, }, ) return Response(serializer.data)
def presence(self, request, org, instance, asn, net=None, *args, **kwargs): serializer = Serializers.presence( net.members, many=True, context={ "perms": request.perms, "user": request.user }, ) return Response(serializer.data)
def update(self, request, org, instance, ix, member, *args, **kwargs): serializer = request.grainy_update_serializer( Serializers.member, member, context={"instance": instance}) if not serializer.is_valid(): return BadRequest(serializer.errors) member = serializer.save() return Response(Serializers.member(instance=member).data)
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)
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)
def list(self, request, org, instance, ix, *args, **kwargs): queryset = self.get_queryset().order_by("name") ordering_filter = CaseInsensitiveOrderingFilter( ["name", "asn", "router_id"]) queryset = ordering_filter.filter_queryset(request, queryset, self) serializer = Serializers.rs( instance=queryset, many=True, ) return Response(serializer.data)
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)
def list(self, request, org, instance, ix, *args, **kwargs): ordering_filter = CaseInsensitiveOrderingFilter( ["name", "asn", "ipaddr4", "ipaddr6", "speed"]) queryset = self.get_queryset().select_related("ix", "ix__instance") queryset = ordering_filter.filter_queryset(request, queryset, self) members = models.InternetExchangeMember.preload_as_macro(queryset) serializer = Serializers.member( instance=members, many=True, ) return Response(serializer.data)
def list(self, request, org, instance, *args, **kwargs): serializer = Serializers.ix( instance=models.InternetExchange.objects.filter(instance=instance), many=True, ) return Response(serializer.data)
def list(self, request, org, instance, *args, **kwargs): serializer = Serializers.net( instance.net_set.all(), many=True, ) return Response(serializer.data)
def destroy(self, request, org, instance, ix, member, *args, **kwargs): r = Response(Serializers.member(instance=member).data) member.delete() return r
def retrieve(self, request, org, ix, instance, *args, **kwargs): serializer = Serializers.ix( instance=ix, many=False, ) return Response(serializer.data)
def destroy(self, request, org, instance, ix, routeserver, *args, **kwargs): r = Response(Serializers.rs(instance=routeserver).data) routeserver.delete() return r