From 0d5e53bea39c6541a712ed93f249ee42e7f97098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= Date: Mon, 21 Apr 2025 18:21:09 +0900 Subject: [PATCH] Add query parameter to events endpoint to filter on result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even though the "data.result" query parameter can be added when calling the "/events" endpoint, add the "result" parameter for convenience. This will also shorten the entire query and hide some of the internal implementation details from the end-user, as in the future, the query parameters might be sanitised such that any unknown or unsupported values could be removed. Signed-off-by: Krzysztof WilczyƄski --- api/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/main.py b/api/main.py index 44436ecb..dd4e08b7 100644 --- a/api/main.py +++ b/api/main.py @@ -484,6 +484,7 @@ async def get_events(request: Request): - from: Start timestamp (unix epoch) to filter events - kind: Event kind to filter events - state: Event state to filter events + - result: Event result to filter events - recursive: Retrieve node together with event This API endpoint is under development and may change in future. """ @@ -493,6 +494,7 @@ async def get_events(request: Request): limit = query_params.pop('limit', None) kind = query_params.pop('kind', None) state = query_params.pop('state', None) + result = query_params.pop('result', None) from_ts = query_params.pop('from', None) if from_ts: if isinstance(from_ts, str): @@ -502,6 +504,8 @@ async def get_events(request: Request): query_params['data.kind'] = kind if state: query_params['data.state'] = state + if result: + query_params['data.result'] = result if limit: query_params['limit'] = int(limit) resp = await db.find_by_attributes_nonpaginated(EventHistory, query_params)