From ec3340bb8933cb5478deb21045efc58053180f23 Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Thu, 19 Sep 2024 09:41:13 +0200 Subject: [PATCH] fix: allow id filters to be combined This can be useful if we want to do filtering directly when querying Infrahub. Signed-off-by: Fatih Acar --- infrahub_sdk/client.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/infrahub_sdk/client.py b/infrahub_sdk/client.py index 8833f04b..3422535c 100644 --- a/infrahub_sdk/client.py +++ b/infrahub_sdk/client.py @@ -347,14 +347,14 @@ async def get( filters[schema.default_filter] = id else: filters["ids"] = [id] - elif hfid: + if hfid: if isinstance(schema, NodeSchema) and schema.human_friendly_id: filters["hfid"] = hfid else: raise ValueError("Cannot filter by HFID if the node doesn't have an HFID defined") - elif kwargs: - filters = kwargs - else: + if kwargs: + filters.update(kwargs) + if len(filters) == 0: raise ValueError("At least one filter must be provided to get()") results = await self.filters( @@ -1355,14 +1355,14 @@ def get( filters[schema.default_filter] = id else: filters["ids"] = [id] - elif hfid: + if hfid: if isinstance(schema, NodeSchema) and schema.human_friendly_id: filters["hfid"] = hfid else: raise ValueError("Cannot filter by HFID if the node doesn't have an HFID defined") - elif kwargs: - filters = kwargs - else: + if kwargs: + filters.update(kwargs) + if len(filters) == 0: raise ValueError("At least one filter must be provided to get()") results = self.filters(