Skip to content

[CSM Portal] Add deployments search; fix product versions route; remove unused endpoint - #752

Merged
v15a1 merged 3 commits into
wso2-open-operations:v2from
Rashmika998:task/csm-portal-deployments-search
May 28, 2026
Merged

v15a1 merged 3 commits into
wso2-open-operations:v2from
Rashmika998:task/csm-portal-deployments-search

Conversation

@Rashmika998

@Rashmika998 Rashmika998 commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds POST /deployments/search endpoint proxying to the entity service, with DeploymentHandler, entity client method, route registration, OpenAPI schema, and full test coverage
  • Renames /product/{id}/versions/search to /products/{id}/versions/search for consistency with other resource routes
  • Removes unused GET /updates/recommended-update-levels endpoint and all related types, mapper, client method, tests, and OpenAPI path

Test plan

  • go test ./... passes locally
  • Pre-push hook ran all backend tests — all green
  • Verify POST /deployments/search proxies to entity service and returns deployment list
  • Verify filtering by projectIds and deploymentTypeKeys works end-to-end
  • Verify POST /products/{id}/versions/search still resolves correctly with the renamed route
  • Verify unauthenticated requests return 401
  • Verify oversized / invalid JSON bodies return 413 / 400

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds a new POST /deployments/search endpoint to the CSM Portal backend. The change includes OpenAPI schemas defining request/response structures, an entity client method forwarding search payloads to a downstream service, an HTTP handler enforcing authentication and validation, comprehensive test coverage, and server wiring to register the route.

Changes

Deployment Search Endpoint

Layer / File(s) Summary
API Contract and Schemas
apps/csm-portal/backend/openapi.yaml
OpenAPI definitions for POST /deployments/search endpoint with DeploymentSearchPayload, DeploymentSearchResponse, and Deployment schemas supporting pagination, search queries, and optional filters.
Entity Client Search Method
apps/csm-portal/backend/internal/entity/entity.go
New SearchDeployments method on entity client that issues POST request to /deployments/search and returns raw JSON response bytes.
Handler Implementation and Tests
apps/csm-portal/backend/internal/handler/deployments.go, apps/csm-portal/backend/internal/handler/deployments_test.go, apps/csm-portal/backend/internal/handler/helpers_test.go
DeploymentHandler with SearchDeployments method enforces authentication via context, applies max request body size limit, validates JSON payload, forwards to entity client, maps upstream errors to HTTP responses, and returns 200 OK. Comprehensive tests cover unauthenticated access, oversized requests, invalid JSON, successful forwarding, and error mapping; mock test helper supports the test suite.
Server Wiring
apps/csm-portal/backend/cmd/server/main.go
Initializes DeploymentHandler with entity client and registers POST /deployments/search route on HTTP mux.

Sequence Diagram

sequenceDiagram
  participant Client
  participant SearchDeployments
  participant EntityClient
  Client->>SearchDeployments: POST /deployments/search
  SearchDeployments->>SearchDeployments: Extract user from context
  alt No authenticated user
    SearchDeployments-->>Client: 401 Unauthorized
  end
  SearchDeployments->>SearchDeployments: Read and validate body size
  alt Body too large
    SearchDeployments-->>Client: 413 Request Entity Too Large
  end
  SearchDeployments->>SearchDeployments: Validate JSON format
  alt Invalid JSON
    SearchDeployments-->>Client: 400 Bad Request
  end
  SearchDeployments->>EntityClient: SearchDeployments(body)
  EntityClient-->>SearchDeployments: Response bytes or error
  alt Upstream error
    SearchDeployments-->>Client: Mapped HTTP error status
  else Success
    SearchDeployments-->>Client: 200 OK with JSON response
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Type/Improvement, Area/Backend, App/CSM Portal

Suggested reviewers

  • cloby99
  • kasunsiyambalapitiya

Poem

🐰 A search endpoint hops to life,
Schemas dance, no deployment strife,
Auth guards the gate with careful cheer,
Validations test what we hold dear,
One POST to find them all so clear! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The title mentions 'Add deployments search' which aligns with the main change, but also references two other unrelated changes ('fix product versions route; remove unused endpoint'), making it overly broad and not focused on the primary objective. Revise the title to focus on the primary change: 'Add POST /deployments/search endpoint' or similar, and consider addressing the other changes in separate PRs for clarity.
Description check ⚠️ Warning The PR description is minimal and uses a non-standard format. It provides a summary of changes and test plan but lacks most required template sections including Purpose, Goals, Approach, User stories, Release notes, Documentation, Training, Certification, Marketing, Security checks, Samples, Related PRs, and Migrations. Use the provided description template to include all required sections: Purpose (with issue links), Goals, Approach, User stories, Release notes, Documentation impact assessment, Training links, Certification status, Marketing content, Automation test details, Security checks, Samples, Related PRs, and any applicable Migrations. At minimum, address Purpose, Goals, Release notes, Documentation, and Security checks.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Wires POST /deployments/search into the csm-portal backend, proxying to
the entity service endpoint added in wso2-open-operations#751.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Rashmika998
Rashmika998 force-pushed the task/csm-portal-deployments-search branch from 949bba5 to 678f234 Compare May 28, 2026 11:17
@Rashmika998 Rashmika998 self-assigned this May 28, 2026
@Rashmika998 Rashmika998 added Type/Improvement Marks enhancements or improvements to existing features Area/Backend App/CSM Portal labels May 28, 2026
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

Rashmika998 and others added 2 commits May 28, 2026 16:55
…ersions/search

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Rashmika998 Rashmika998 changed the title [CSM Portal] Add deployments search endpoint [CSM Portal] Add deployments search; fix product versions route; remove unused endpoint May 28, 2026
@Rashmika998
Rashmika998 requested a review from cloby99 May 28, 2026 11:32
@v15a1
v15a1 merged commit c956584 into wso2-open-operations:v2 May 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App/CSM Portal Area/Backend Type/Improvement Marks enhancements or improvements to existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants