prometheus/web/api
Yijie Qin d2802c6fac
api: Add rule group pagination to list rules api (#14017)
* Add paginated feature to list rules api

Signed-off-by: Yijie Qin <qinyijie@amazon.com>

* Refactor to simplify code:

* Reduce number of variables
* Reduce type convesion

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Simplify paginated implementation

* Remove maxAlerts parameter.
* Reuse existing API responses by using omitempty in some fields

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Simplify pagination implementation

* Eliminate the need to sort the rule groups.

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Fix linting error

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Add more unit tests

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Update pagination parameters to be consistent with existing parameters

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Rename max_rule_groups to max_groups

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Refactor to simplify code

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Refactor to simplify the calculation of next token

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Handle corner case in pagination request

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Handle corner cases for pagination of list rules

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Update documentation for list rules parameters

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Refactor comments

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Simplify pagination implementation

* Eliminate need for extra structs to store pagination parameters

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Update docs/querying/api.md

Co-authored-by: Julius Volz <julius.volz@gmail.com>
Signed-off-by: Raphael Philipe Mendes da Silva <rapphil@gmail.com>

* Update web/api/v1/api.go

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Raphael Philipe Mendes da Silva <rapphil@gmail.com>

* Update comment describing the need for next token

Signed-off-by: Raphael Silva <rapphil@gmail.com>

---------

Signed-off-by: Yijie Qin <qinyijie@amazon.com>
Signed-off-by: Raphael Silva <rapphil@gmail.com>
Signed-off-by: Raphael Philipe Mendes da Silva <rapphil@gmail.com>
Co-authored-by: Raphael Silva <rapphil@gmail.com>
Co-authored-by: Julius Volz <julius.volz@gmail.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
2024-10-22 00:04:40 +01:00
..
v1 api: Add rule group pagination to list rules api (#14017) 2024-10-22 00:04:40 +01:00