Skip to content

Commit

Permalink
Return 201 for RBAC content guard assign/remove endpoints
Browse files Browse the repository at this point in the history
fixes: #9314
  • Loading branch information
gerrod3 authored and bmbouter committed Aug 31, 2021
1 parent 225360c commit dc8c235
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/9314.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``RBACContentGuard`` assign/remove permission endpoints now properly return 201 instead of 200
8 changes: 4 additions & 4 deletions pulpcore/app/viewsets/publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit dc8c235

Please sign in to comment.