|
9 | 9 |
|
10 | 10 | from bfabric.engine.response_format_suds import suds_asdict_recursive |
11 | 11 | from bfabric.errors import BfabricRequestError, get_response_errors |
12 | | -from bfabric.results.result_container import ResultContainer |
| 12 | +from bfabric.results.response_delete import ResponseDelete |
13 | 13 | from bfabric.results.response_format_dict import clean_result |
| 14 | +from bfabric.results.result_container import ResultContainer |
14 | 15 |
|
15 | 16 | if TYPE_CHECKING: |
16 | 17 | from suds.serviceproxy import ServiceProxy |
@@ -46,13 +47,13 @@ def read( |
46 | 47 | query = copy.deepcopy(obj) |
47 | 48 | query["includedeletableupdateable"] = include_deletable_and_updatable_fields |
48 | 49 |
|
49 | | - full_query = dict( |
50 | | - login=auth.login, |
51 | | - page=page, |
52 | | - password=auth.password.get_secret_value(), |
53 | | - query=query, |
54 | | - idonly=return_id_only, |
55 | | - ) |
| 50 | + full_query = { |
| 51 | + "login": auth.login, |
| 52 | + "page": page, |
| 53 | + "password": auth.password.get_secret_value(), |
| 54 | + "query": query, |
| 55 | + "idonly": return_id_only, |
| 56 | + } |
56 | 57 | service = self._get_suds_service(endpoint) |
57 | 58 | response = service.read(full_query) |
58 | 59 | return self._convert_results(response=response, endpoint=endpoint) |
@@ -80,14 +81,11 @@ def delete(self, endpoint: str, id: int | list[int], auth: BfabricAuth) -> Resul |
80 | 81 | :param auth: the authentication handle of the user performing the request |
81 | 82 | """ |
82 | 83 | if isinstance(id, list) and len(id) == 0: |
83 | | - print("Warning, attempted to delete an empty list, ignoring") |
84 | | - # TODO maybe use error here (and make sure it's consistent) |
85 | | - return ResultContainer([], total_pages_api=0) |
86 | | - |
| 84 | + return ResponseDelete.from_empty_request() |
87 | 85 | query = {"login": auth.login, "password": auth.password.get_secret_value(), "id": id} |
88 | 86 | service = self._get_suds_service(endpoint) |
89 | 87 | response = service.delete(query) |
90 | | - return self._convert_results(response=response, endpoint=endpoint) |
| 88 | + return ResponseDelete.from_suds(suds_response=response, endpoint=endpoint) |
91 | 89 |
|
92 | 90 | def _get_suds_service(self, endpoint: str) -> ServiceProxy: |
93 | 91 | """Returns a SUDS service for the given endpoint. Reuses existing instances when possible.""" |
|
0 commit comments