feat(api-engine): add retrieve and destroy actions to NodeViewSet#777
Open
AHS0003 wants to merge 1 commit into
Open
feat(api-engine): add retrieve and destroy actions to NodeViewSet#777AHS0003 wants to merge 1 commit into
AHS0003 wants to merge 1 commit into
Conversation
Signed-off-by: AHS0003 <aminehs623@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds missing REST actions to the api-engine NodeViewSet so nodes can be fetched and deleted individually, while keeping access scoped to the authenticated user’s organization (consistent with existing list/create behavior).
Changes:
- Added
retrieve(GET /nodes/{id}) with org-scoped lookup and 404 handling. - Added
destroy(DELETE /nodes/{id}) with org-scoped lookup, deletion, and 404 handling. - Updated Swagger annotations for the new actions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
9
to
+12
| from api.common import ok | ||
| from api.common.response import make_response_serializer | ||
| from api.utils.common import with_common_response | ||
| from common.responses import err |
Comment on lines
+67
to
+70
| def retrieve(self, request, pk: Optional[str] = None): | ||
| try: | ||
| node = Node.objects.get(pk=pk, organization=request.user.organization) | ||
| except Node.DoesNotExist: |
| @swagger_auto_schema( | ||
| operation_summary="Retrieve a node by ID", | ||
| responses=with_common_response( | ||
| {status.HTTP_200_OK: make_response_serializer(NodeResponse)} |
Comment on lines
+86
to
+89
| def destroy(self, request, pk: Optional[str] = None): | ||
| try: | ||
| Node.objects.get(pk=pk, organization=request.user.organization).delete() | ||
| except Node.DoesNotExist: |
| @swagger_auto_schema( | ||
| operation_summary="Delete a node by ID", | ||
| responses=with_common_response( | ||
| {status.HTTP_204_NO_CONTENT: "No Content"} |
514b2a0 to
07bfbe0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
retrieve(GET /nodes/{id}) anddestroy(
DELETE /nodes/{id}) actions toNodeViewSetin the
api-engine.Previously, nodes could only be listed and created,
but not individually fetched or deleted.
Both new actions scope node access to the authenticated
user's organization, consistent with the existing
listaction andOrganizationViewSetbehavior.Changes
retrieve()action → returns200or404destroy()action → returns204or404err("Node not found")NodeResponseserializerTesting
python -m flake8 node/views.py→ no errorsManually tested:
200)204)404)404)No migrations, no new dependencies, no frontend changes.