def update(self, request, remote_id, *args, **kwargs): self.get_object() serializer = self.serializer_class(data=request.data) if not serializer.is_valid(): return BadRequest(serializer.errors) serializer.save() return Response(serializer.data)
def create(self, request, org, instance, *args, **kwargs): request.data["instance"] = instance.id serializer = Serializers.logical_port(data=request.data) if not serializer.is_valid(): return BadRequest(serializer.errors) logical_port = serializer.save() logical_port.save() return Response(Serializers.logical_port(instance=logical_port).data)
def create(self, request, org, instance, *args, **kwargs): data = request.data data["instance"] = instance.id serializer = Serializers.device(data=data) if not serializer.is_valid(): return BadRequest(serializer.errors) device = serializer.save() device.save() return Response(Serializers.device(instance=device).data)
def create(self, request, org, instance, *args, **kwargs): models.LogicalPort.objects.get(instance=instance, id=request.data.get("logical_port")) serializer = Serializers.virtual_port(data=request.data) if not serializer.is_valid(): return BadRequest(serializer.errors) virtual_port = serializer.save() virtual_port.save() return Response(Serializers.virtual_port(instance=virtual_port).data)
def create(self, request, org, instance, *args, **kwargs): device = models.Device.objects.get(instance=instance, id=request.data.get("device")) serializer = Serializers.physical_port(data=request.data) if not serializer.is_valid(): return BadRequest(serializer.errors) physical_port = serializer.save() physical_port.save() return Response(Serializers.physical_port(instance=physical_port).data)
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 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 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 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 update(self, request, org, instance, virtual_port, *args, **kwargs): serializer = Serializers.virtual_port( virtual_port, data=request.data, ) if not serializer.is_valid(): return BadRequest(serializer.errors) virtual_port = serializer.save() virtual_port.save() return Response(Serializers.virtual_port(instance=virtual_port).data)
def _list(self, request, *args, **kwargs): qset = self.filter(self.get_queryset(), request) if not self.filtered and not self.allow_unfiltered: return BadRequest( _("Unfiltered listing not allowed for this endpoint")) qset, joins = self.join_relations(qset, request) serializer = self.serializer_class(qset, many=True, context={"joins": joins}) return Response(serializer.data)
def create(self, request, *args, **kwargs): try: instance = models.Organization.objects.get( remote_id=request.data["remote_id"]) except models.Organization.DoesNotExist: instance = None serializer = self.serializer_class(instance=instance, data=request.data) if not serializer.is_valid(): return BadRequest(serializer.errors) serializer.save() return Response(serializer.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 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)