From 87aaff50d3a3f2ddba128ecb7829df709c6210f7 Mon Sep 17 00:00:00 2001 From: Leonardo Schwarz Date: Mon, 5 Jan 2026 16:50:40 +0100 Subject: [PATCH] Alternative read --- bfabric/docs/changelog.md | 4 ++++ bfabric/src/bfabric/bfabric.py | 4 ++++ bfabric/src/bfabric/engine/engine_suds.py | 7 ++++++- bfabric/src/bfabric/engine/engine_zeep.py | 4 +++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bfabric/docs/changelog.md b/bfabric/docs/changelog.md index d2c28366c..0fcc9265c 100644 --- a/bfabric/docs/changelog.md +++ b/bfabric/docs/changelog.md @@ -9,6 +9,10 @@ Minor breaking changes are still possible in `1.X.Y` but we try to announce them ## \[Unreleased\] +### Added + +- `Bfabric.read` supports `method` parameter to specify alternative read methods. + ## \[1.16.1\] - 2025-12-15 ### Fixed diff --git a/bfabric/src/bfabric/bfabric.py b/bfabric/src/bfabric/bfabric.py index e27c8b263..e69658981 100644 --- a/bfabric/src/bfabric/bfabric.py +++ b/bfabric/src/bfabric/bfabric.py @@ -197,6 +197,7 @@ def read( offset: int = 0, check: bool = True, return_id_only: bool = False, + method: str = "read", ) -> ResultContainer: """Reads from the specified endpoint matching all specified attributes in `obj`. By setting `max_results` it is possible to change the number of results that are returned. @@ -211,6 +212,7 @@ def read( is 0 which means no skipping) :param check: whether to raise an error if the response is not successful :param return_id_only: whether to return only the ids of the found objects + :param method: alternative SOAP method to use for reading data :return: List of responses, packaged in the results container """ # Get the first page. @@ -219,6 +221,7 @@ def read( endpoint=endpoint, obj=obj, auth=self.auth, + method=method, page=1, return_id_only=return_id_only, ) @@ -248,6 +251,7 @@ def read( endpoint=endpoint, obj=obj, auth=self.auth, + method=method, page=i_page, return_id_only=return_id_only, ) diff --git a/bfabric/src/bfabric/engine/engine_suds.py b/bfabric/src/bfabric/engine/engine_suds.py index cc0b4764f..66e8b5c16 100644 --- a/bfabric/src/bfabric/engine/engine_suds.py +++ b/bfabric/src/bfabric/engine/engine_suds.py @@ -33,6 +33,7 @@ def read( endpoint: str, obj: ApiRequestObjectType, auth: BfabricAuth, + method: str = "read", page: int = 1, return_id_only: bool = False, include_deletable_and_updatable_fields: bool = False, @@ -42,6 +43,7 @@ def read( :param obj: a dictionary containing the query, for every field multiple possible values can be provided, the final query requires the condition for each field to be met :param auth: the authentication handle of the user performing the request + :param method: alternative SOAP method to use for reading data :param page: the page number to read :param return_id_only: whether to return only the ids of the objects :param include_deletable_and_updatable_fields: whether to include the deletable and updatable fields @@ -57,7 +59,10 @@ def read( "idonly": return_id_only, } service = self._get_suds_service(endpoint) - response = service.read(full_query) + try: + response = getattr(service, method)(full_query) + except MethodNotFound as e: + raise BfabricRequestError(f"SUDS failed to find method '{method}'") from e return self._convert_results(response=response, endpoint=endpoint) def save( diff --git a/bfabric/src/bfabric/engine/engine_zeep.py b/bfabric/src/bfabric/engine/engine_zeep.py index 13101601e..b731020a4 100644 --- a/bfabric/src/bfabric/engine/engine_zeep.py +++ b/bfabric/src/bfabric/engine/engine_zeep.py @@ -29,6 +29,7 @@ def read( endpoint: str, obj: ApiRequestObjectType, auth: BfabricAuth, + method: str = "read", page: int = 1, return_id_only: bool = False, include_deletable_and_updatable_fields: bool = False, @@ -38,6 +39,7 @@ def read( :param obj: a dictionary containing the query, for every field multiple possible values can be provided, the final query requires the condition for each field to be met :param auth: the authentication handle of the user performing the request + :param method: the method to use for the request, e.g. "read" :param page: the page number to read :param return_id_only: whether to return only the ids of the objects :param include_deletable_and_updatable_fields: whether to include the deletable and updatable fields @@ -69,7 +71,7 @@ def read( client = self._get_client(endpoint) with client.settings(strict=False, xml_huge_tree=True, xsd_ignore_sequence_order=True): - response = client.service.read(full_query) + response = getattr(client.service, method)(full_query) return self._convert_results(response=response, endpoint=endpoint) def save(