Skip to content

feat(api-engine): add retrieve and destroy actions to NodeViewSet#777

Open
AHS0003 wants to merge 1 commit into
hyperledger-cello:mainfrom
AHS0003:feature/node-retrieve-delete
Open

feat(api-engine): add retrieve and destroy actions to NodeViewSet#777
AHS0003 wants to merge 1 commit into
hyperledger-cello:mainfrom
AHS0003:feature/node-retrieve-delete

Conversation

@AHS0003
Copy link
Copy Markdown

@AHS0003 AHS0003 commented May 7, 2026

Adds retrieve (GET /nodes/{id}) and destroy
(DELETE /nodes/{id}) actions to NodeViewSet
in 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
list action and OrganizationViewSet behavior.

Changes

  • Added retrieve() action → returns 200 or 404
  • Added destroy() action → returns 204 or 404
  • Added organization-scoped lookup protection
  • Added 404 handling via err("Node not found")
  • Reused existing NodeResponse serializer

Testing

  • python -m flake8 node/views.py → no errors

  • Manually tested:

    • successful retrieve (200)
    • successful delete (204)
    • retrieve missing node (404)
    • delete missing node (404)

No migrations, no new dependencies, no frontend changes.

Copilot AI review requested due to automatic review settings May 7, 2026 13:39
Signed-off-by: AHS0003 <aminehs623@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"}
@AHS0003 AHS0003 force-pushed the feature/node-retrieve-delete branch from 514b2a0 to 07bfbe0 Compare May 7, 2026 13:46
@yeasy yeasy requested a review from dodo920306 May 8, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants