From dc8c2357f96ee7d2d1ce8e32e7fe3febc127106c Mon Sep 17 00:00:00 2001 From: Gerrod Ubben Date: Mon, 30 Aug 2021 16:16:26 -0400 Subject: [PATCH] Return 201 for RBAC content guard assign/remove endpoints fixes: #9314 --- CHANGES/9314.bugfix | 1 + pulpcore/app/viewsets/publication.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 CHANGES/9314.bugfix diff --git a/CHANGES/9314.bugfix b/CHANGES/9314.bugfix new file mode 100644 index 0000000000..c7cb847d40 --- /dev/null +++ b/CHANGES/9314.bugfix @@ -0,0 +1 @@ +``RBACContentGuard`` assign/remove permission endpoints now properly return 201 instead of 200 diff --git a/pulpcore/app/viewsets/publication.py b/pulpcore/app/viewsets/publication.py index c45a5c9343..37b526e957 100644 --- a/pulpcore/app/viewsets/publication.py +++ b/pulpcore/app/viewsets/publication.py @@ -200,7 +200,7 @@ class RBACContentGuardViewSet(ContentGuardViewSet): ], } - @extend_schema(summary="Add download permission", responses={200: RBACContentGuardSerializer}) + @extend_schema(summary="Add download permission", responses={201: RBACContentGuardSerializer}) @action(methods=["post"], detail=True, serializer_class=RBACContentGuardPermissionSerializer) def assign_permission(self, request, pk): """Give users and groups the `download` permission""" @@ -210,10 +210,10 @@ def assign_permission(self, request, pk): guard.add_can_download(users=names.data["usernames"], groups=names.data["groupnames"]) self.serializer_class = RBACContentGuardSerializer serializer = self.get_serializer(guard) - return Response(serializer.data) + return Response(serializer.data, status=201) @extend_schema( - summary="Remove download permission", responses={200: RBACContentGuardSerializer} + summary="Remove download permission", responses={201: RBACContentGuardSerializer} ) @action(methods=["post"], detail=True, serializer_class=RBACContentGuardPermissionSerializer) def remove_permission(self, request, pk): @@ -224,7 +224,7 @@ def remove_permission(self, request, pk): guard.remove_can_download(users=names.data["usernames"], groups=names.data["groupnames"]) self.serializer_class = RBACContentGuardSerializer serializer = self.get_serializer(guard) - return Response(serializer.data) + return Response(serializer.data, status=201) class DistributionFilter(BaseFilterSet):