add new /sizes endpoint

This commit is contained in:
Nico Schottelius 2020-12-20 21:45:47 +01:00
commit ece2bca831
6 changed files with 52 additions and 20 deletions

View file

@ -56,3 +56,13 @@ class WireGuardVPNCreateView(LoginRequiredMixin, SuccessMessageMixin, CreateView
def get_success_message(self, cleaned_data):
return self.success_message % dict(cleaned_data,
the_prefix = self.object.prefix)
class WireGuardVPNSizes(viewsets.ViewSet):
def list(self, request):
sizes = allowed_vpn_network_reservation_size()
print(sizes)
sizes = [ { 'size': size } for size in sizes ]
print(sizes)
return Response(WireGuardVPNSizesSerializer(sizes, many=True).data)