-
Notifications
You must be signed in to change notification settings - Fork 34
[CSM] feat: add time-cards search, patch change-request, and attachment endpoints #964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cloby99
merged 16 commits into
wso2-open-operations:v2
from
Rashmika998:feat/time-cards-and-patch-change-request
Jun 28, 2026
Merged
Changes from 6 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e776694
[CSM] feat: add POST /time-cards/search and PATCH /change-requests/{id}
Rashmika998 33ddad4
Add PatchChangeRequest to mockEntityChangeRequestClient in tests
Rashmika998 cfe3d67
Fix time cards parse error: drop id field from snTimeCardLabel
Rashmika998 eef3b7e
Add all time card states: pending, submitted, rejected, processed, re…
Rashmika998 87d7f9a
Merge upstream/v2 into feat/time-cards-and-patch-change-request: keep…
Rashmika998 83eee54
[CSM] feat: add DELETE /cases/{id}/attachments/{attachmentId} endpoint
Rashmika998 374ef92
fix: use camelCase {attachmentId} in entity service DELETE attachment…
Rashmika998 37ccf9a
fix: address CodeRabbit review on time-cards and change-request endpo…
Rashmika998 7ad5ca8
refactor: move attachment endpoints out of /cases/{id} path scope
Rashmika998 5c8cbcf
fix: update attachment handler tests for new path-param-free routes
Rashmika998 ebc2d08
refactor: use {id} path param for GET/DELETE attachment endpoints
Rashmika998 bd308db
fix: align attachment search payload with Ballerina service contract
Rashmika998 f15e05d
fix: align attachment create payload with Ballerina service contract
Rashmika998 cb90690
docs: fix attachment path params in README to use {id} instead of {at…
Rashmika998 3948577
Merge upstream/v2: add product vulnerabilities endpoints alongside ti…
Rashmika998 20b0964
fix: replace caseId with referenceId/referenceType in Attachment resp…
Rashmika998 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you under the Apache License, | ||
| // Version 2.0 (the "License"); you may not use this file except | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| package handler | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "errors" | ||
| "io" | ||
| "log/slog" | ||
| "net/http" | ||
|
|
||
| "github.com/wso2-open-operations/cs-tools/apps/csm-portal/backend/internal/middleware" | ||
| ) | ||
|
|
||
| // entityTimeCardClient abstracts the entity service time-card operations. | ||
| type entityTimeCardClient interface { | ||
| SearchTimeCards(ctx context.Context, body []byte) ([]byte, error) | ||
| } | ||
|
|
||
| // TimeCardHandler handles HTTP requests for time-card operations. | ||
| type TimeCardHandler struct { | ||
| entity entityTimeCardClient | ||
| } | ||
|
|
||
| // NewTimeCardHandler creates a TimeCardHandler backed by the given entity client. | ||
| func NewTimeCardHandler(entity entityTimeCardClient) *TimeCardHandler { | ||
| return &TimeCardHandler{entity: entity} | ||
| } | ||
|
|
||
| // SearchTimeCards handles POST /time-cards/search. | ||
| func (h *TimeCardHandler) SearchTimeCards(w http.ResponseWriter, r *http.Request) { | ||
| user := middleware.UserInfoFromContext(r.Context()) | ||
| if user == nil { | ||
| writeError(w, http.StatusUnauthorized, ErrMsgUnauthorized) | ||
| return | ||
| } | ||
|
|
||
| r.Body = http.MaxBytesReader(w, r.Body, maxRequestBodyBytes) | ||
| body, err := io.ReadAll(r.Body) | ||
| if err != nil { | ||
| var maxBytesErr *http.MaxBytesError | ||
| if errors.As(err, &maxBytesErr) { | ||
| writeError(w, http.StatusRequestEntityTooLarge, ErrMsgTooLarge) | ||
| return | ||
| } | ||
| writeError(w, http.StatusBadRequest, errMsgReadBody) | ||
| return | ||
| } | ||
|
|
||
| if len(body) > 0 && !json.Valid(body) { | ||
| writeError(w, http.StatusBadRequest, ErrMsgBadRequest) | ||
| return | ||
| } | ||
|
|
||
| result, err := h.entity.SearchTimeCards(r.Context(), body) | ||
| if err != nil { | ||
| slog.ErrorContext(r.Context(), "entity SearchTimeCards failed", "userID", user.UserID, "err", err) | ||
| mapUpstreamError(w, err, "Failed to search time cards.") | ||
| return | ||
| } | ||
|
|
||
| writeJSON(w, http.StatusOK, result) | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.