Skip to content

[Customer Entity] Add POST /service-requests/search endpoint - #903

Merged
Rashmika998 merged 7 commits into
wso2-open-operations:v2from
cloby99:task/entity-service
Jun 22, 2026
Merged

Rashmika998 merged 7 commits into
wso2-open-operations:v2from
cloby99:task/entity-service

Conversation

@cloby99

@cloby99 cloby99 commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

  • Added POST /service-requests/search endpoint (ServiceNow only) — proxies to SN POST /cases/search with caseTypes: ["service_request"] and returns a service-request-specific response shape including catalog, catalogItem, assignedTeam, workState, and conversation fields

Summary by CodeRabbit

  • New Features
    • Added service request search endpoint with filtering, sorting, and pagination capabilities
    • Supported filters include project/deployment IDs, state, date ranges, and creator information
    • Search results include enriched service request data with related entity references

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@cloby99, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 48 minutes and 51 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2c7db44e-c8e1-41f2-86d8-3d859cff8277

📥 Commits

Reviewing files that changed from the base of the PR and between 5b362fa and b493479.

📒 Files selected for processing (3)
  • entity-service/internal/domain/entity.go
  • entity-service/internal/handler/case_handler.go
  • entity-service/openapi.yaml
📝 Walkthrough

Walkthrough

Adds a POST /service-requests/search endpoint. New domain DTOs define the filter, request, view, and paginated response types. The CaseService interface gains a SearchServiceRequests method; the default implementation returns a ServiceUnavailableError, while the ServiceNow implementation validates inputs, calls Choreo's /cases/search filtered to service_request case type, and maps results to domain views.

Changes

Search Service Requests endpoint

Layer / File(s) Summary
Domain contracts: filters, view, and response DTOs
entity-service/internal/domain/entity.go
Adds SearchServiceRequestsFilters, SearchServiceRequestsRequest, ServiceRequestWorkStateRef, ServiceRequestView, and SearchServiceRequestsResponse as the public API contract types.
Service interface, default stub, and ServiceNow implementation
entity-service/internal/service/interfaces.go, entity-service/internal/service/case_service.go, entity-service/internal/service/sn_case_service.go
Extends CaseService with SearchServiceRequests; the default service returns ServiceUnavailableError; the SN service defines new JSON response structs (snServiceRequestsResponse, snServiceRequestCase, snServiceRequestWorkState) and implements the full method: pagination normalization, date-range validation, x-user-id-token extraction, Choreo API call, and result mapping.
HTTP handler and route registration
entity-service/internal/handler/case_handler.go, entity-service/internal/server/routes.go
Adds CaseHandler.SearchServiceRequests decoding the POST body, calling the service, and writing JSON; registers the route POST /service-requests/search in the mux.

Sequence Diagram

sequenceDiagram
  participant Client
  participant Router as routes.go
  participant Handler as CaseHandler.SearchServiceRequests
  participant snSvc as snCaseService.SearchServiceRequests
  participant Choreo as POST /cases/search

  Client->>Router: POST /service-requests/search
  Router->>Handler: dispatch
  Handler->>Handler: decode body into SearchServiceRequestsRequest
  Handler->>snSvc: SearchServiceRequests(ctx, req)
  snSvc->>snSvc: validate pagination, searchQuery, date ranges
  snSvc->>snSvc: extract x-user-id-token from ctx
  snSvc->>Choreo: POST /cases/search (caseTypes=["service_request"])
  Choreo-->>snSvc: snServiceRequestsResponse
  snSvc->>snSvc: map cases to []domain.ServiceRequestView
  snSvc-->>Handler: SearchServiceRequestsResponse
  Handler-->>Client: 200 application/json
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • Rashmika998

Poem

🐇 A new search hops into the code today,
Service requests can now be queried away!
The Choreo path is filtered and mapped with care,
SN only — or a ServiceUnavailable snare.
From domain to handler, the rabbit did trace,
Each layer in order, at a tidy pace! 🌸

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and lacks required template sections including Purpose, Goals, Approach, User stories, Release note, Documentation, Testing details, Security checks, and other critical information. Expand the description to follow the repository template: add Purpose with issue links, Goals, Approach details, User stories, Release note, Documentation links, Automation test coverage details, and Security verification checkboxes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding a POST endpoint for searching service requests, which is the core feature across all modified files.
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@entity-service/internal/domain/entity.go`:
- Line 637: The comment for SearchServiceRequestsRequest contains a typo in the
endpoint path. Update the comment from `POST /service-request/search` (singular)
to `POST /service-requests/search` (plural) to match the actual registered
route. Also locate and fix any matching handler comment that references this
endpoint with the same singular path typo to maintain consistency throughout the
codebase.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4c1fde57-aa64-4e34-8c1d-5f066f8f0e99

📥 Commits

Reviewing files that changed from the base of the PR and between 673d6e5 and 5b362fa.

📒 Files selected for processing (6)
  • entity-service/internal/domain/entity.go
  • entity-service/internal/handler/case_handler.go
  • entity-service/internal/server/routes.go
  • entity-service/internal/service/case_service.go
  • entity-service/internal/service/interfaces.go
  • entity-service/internal/service/sn_case_service.go

Comment thread entity-service/internal/domain/entity.go Outdated
@Rashmika998
Rashmika998 merged commit a5008c8 into wso2-open-operations:v2 Jun 22, 2026
1 check passed
Rashmika998 added a commit that referenced this pull request Jun 22, 2026
…case search filters

- Add POST /service-requests/search endpoint (entity-service PR #903)
- Extend CaseSearchFilters with date range (closed/created/updated),
  createdBy, and createdByMe fields (entity-service PR #902)
- Update OpenAPI spec with new path, schemas, and filter fields
- Extend entityCaseClient interface and update test mock

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

3 participants