Example #1
0
    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.member(data=data,
                                        context={"instance": instance})
        if not serializer.is_valid():
            return BadRequest(serializer.errors)

        member = serializer.save()

        return Response(Serializers.member(instance=member).data)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
 def destroy(self, request, org, instance, ix, member, *args, **kwargs):
     r = Response(Serializers.member(instance=member).data)
     member.delete()
     return r