From 2ece1a2ee8ee8c1313dcb150dc70b943c602b549 Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Wed, 20 Nov 2024 16:08:09 -0800 Subject: [PATCH] support the delegate filter for REST API The REST API does not add the delegate filter to the REST API query, which makes using -d give unexpected results: If you add -d then you will still obtain all patches, and then print them out sorted by delegate. Fix this by passing the delegate as a filter to the query command. I suspect this was not implemented before because the REST API may not actually allow partial names for the delegate. I believe this is still valuable to support even if it requires strict matching against the delegate names or IDs. If a match is desirable, this could be refactored to query the set of delegates from the API, find all the IDs which match, and then make multiple calls to _list for each matching delegate ID. I did not attempt to implement that. Signed-off-by: Jacob Keller --- pwclient/api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pwclient/api.py b/pwclient/api.py index 79a885d..15bceb8 100644 --- a/pwclient/api.py +++ b/pwclient/api.py @@ -747,6 +747,9 @@ def patch_list( if archived is not None: filters['archived'] = archived + if delegate is not None: + filters['delegate'] = delegate + patches = self._list('patches', params=filters) return [self._patch_to_dict(patch) for patch in patches]