Clean up CloudApiClient.py

This commit is contained in:
Frederic Meeuwissen 2024-03-14 16:30:53 +01:00 committed by Remco Burema
parent 8012df6518
commit 484cc6d42f

View file

@ -178,6 +178,7 @@ class CloudApiClient:
:param cluster_id: The ID of the cluster. :param cluster_id: The ID of the cluster.
:param cluster_job_id: The ID of the print job within the cluster. :param cluster_job_id: The ID of the print job within the cluster.
:param action: The name of the action to execute. :param action: The name of the action to execute.
:param data: Optional data to send with the POST request
""" """
body = json.dumps({"data": data}).encode() if data else b"" body = json.dumps({"data": data}).encode() if data else b""
@ -220,8 +221,11 @@ class CloudApiClient:
Logger.logException("e", "Could not parse the stardust response: %s", error.toDict()) Logger.logException("e", "Could not parse the stardust response: %s", error.toDict())
return status_code, {"errors": [error.toDict()]} return status_code, {"errors": [error.toDict()]}
def _parseResponse(self, response: Dict[str, Any], on_finished: Union[Callable[[CloudApiClientModel], Any], def _parseResponse(self,
Callable[[List[CloudApiClientModel]], Any]], model_class: Type[CloudApiClientModel]) -> None: response: Dict[str, Any],
on_finished: Union[Callable[[CloudApiClientModel], Any],
Callable[[List[CloudApiClientModel]], Any]],
model_class: Type[CloudApiClientModel]) -> None:
"""Parses the given response and calls the correct callback depending on the result. """Parses the given response and calls the correct callback depending on the result.
:param response: The response from the server, after being converted to a dict. :param response: The response from the server, after being converted to a dict.