Skip to content

Extend /incidents endpoint to handle POST requests as well#456

Merged
oxzi merged 1 commit into
mainfrom
extend-incidents-endpoint
Jul 10, 2026
Merged

Extend /incidents endpoint to handle POST requests as well#456
oxzi merged 1 commit into
mainfrom
extend-incidents-endpoint

Conversation

@yhabteab

@yhabteab yhabteab commented Jul 3, 2026

Copy link
Copy Markdown
Member

This PR extends the existing /incidents HTTP handler to allow POST requests as described in #452 as well. Also, both the GET and POST handler requires a filter parameter as described in the referenced issue. The changes to the endpoint are trivial but the PR is just that big simply because of the new documentation explaining the new behavior of both HTTP methods and also unit tests for the query string filter parsing and evaluating.

resolves #452

@cla-bot cla-bot Bot added the cla/signed CLA is signed by all contributors of a PR label Jul 3, 2026
@yhabteab yhabteab added this to the 1.0 milestone Jul 3, 2026
@yhabteab yhabteab requested a review from oxzi July 3, 2026 14:53
@yhabteab yhabteab force-pushed the extend-incidents-endpoint branch 3 times, most recently from 96b20d2 to 1d68d24 Compare July 6, 2026 07:17
@yhabteab

yhabteab commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Sorry, I've dropped two superfluous if statements.

Comment thread doc/20-HTTP-API.md
Comment thread doc/20-HTTP-API.md Outdated
Comment thread doc/20-HTTP-API.md Outdated
Comment thread doc/20-HTTP-API.md Outdated
Comment thread doc/20-HTTP-API.md Outdated
Comment thread doc/20-HTTP-API.md Outdated
Comment thread internal/listener/listener.go
Comment thread internal/listener/query_filter.go Outdated
Comment thread internal/listener/listener.go Outdated
Comment thread internal/listener/listener.go Outdated
@yhabteab yhabteab force-pushed the extend-incidents-endpoint branch from 1d68d24 to dfeea7b Compare July 6, 2026 13:42
@yhabteab yhabteab requested a review from oxzi July 6, 2026 13:46
@yhabteab yhabteab force-pushed the extend-incidents-endpoint branch 2 times, most recently from de39baa to 702cace Compare July 7, 2026 07:09
@yhabteab

yhabteab commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

I've changed the JSON decoder for the POST handler to reject unknown fields.

@yhabteab yhabteab force-pushed the extend-incidents-endpoint branch from 702cace to c860bd6 Compare July 8, 2026 06:41
@yhabteab

yhabteab commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

While testing Icinga/icingadb#1145, I noticed that using just the NOT EXISTS JSON filter syntax without any other postive matches caused to yield all incidents, which is completely wrong as that would defeat the whole the user must know what he's looking for argument from Johannes. So, the endpoint will now reject the request with 400 if the provided filter contains only negated conditions and documented it accordingly.

@yhabteab yhabteab force-pushed the extend-incidents-endpoint branch 2 times, most recently from 9fc1e06 to 820bc97 Compare July 8, 2026 08:08
@yhabteab

yhabteab commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Sorry, the latest two pushes weren't intentional! I accidentally pushed something here that's supposed to go to #460, so dropped the corresponding changes again.

@yhabteab yhabteab force-pushed the extend-incidents-endpoint branch from 820bc97 to 8e9b3ff Compare July 8, 2026 11:32
@yhabteab

yhabteab commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Reduced the PR by ~20 LOC by squashing the some test cases into a loop :).

@yhabteab yhabteab force-pushed the extend-incidents-endpoint branch from 8e9b3ff to 4ae97f7 Compare July 9, 2026 09:57
Comment thread internal/listener/listener.go
Comment thread internal/listener/query_filter.go
Comment thread internal/listener/listener.go
@yhabteab yhabteab force-pushed the extend-incidents-endpoint branch from 4ae97f7 to 7f15d05 Compare July 9, 2026 13:32
@yhabteab yhabteab requested a review from oxzi July 9, 2026 13:34

@oxzi oxzi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks. Only one small nitpicks where the docs diverge from the code. Please change it, and than it's good for me!

Comment thread doc/20-HTTP-API.md Outdated
@yhabteab yhabteab force-pushed the extend-incidents-endpoint branch from 7f15d05 to 17d20db Compare July 10, 2026 07:35
@yhabteab yhabteab requested a review from oxzi July 10, 2026 07:36
@oxzi oxzi merged commit 6f636c1 into main Jul 10, 2026
26 checks passed
@oxzi oxzi deleted the extend-incidents-endpoint branch July 10, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla/signed CLA is signed by all contributors of a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend API endpoint /incidents to allow filtering and modifications

2 participants