diff --git a/plugins/UM3NetworkPrinting/src/Network/ClusterApiClient.py b/plugins/UM3NetworkPrinting/src/Network/ClusterApiClient.py index e6a816abcd..3e3dbed46d 100644 --- a/plugins/UM3NetworkPrinting/src/Network/ClusterApiClient.py +++ b/plugins/UM3NetworkPrinting/src/Network/ClusterApiClient.py @@ -72,15 +72,15 @@ class ClusterApiClient: url = f"{self.CLUSTER_API_PREFIX}/print_jobs/{print_job_uuid}" self._manager.deleteResource(self._createEmptyRequest(url)) - ## Send a print job action to the cluster. - # \param print_job_uuid: The UUID of the print job to perform the action on. - # \param action: The action to perform. - # \param data: The optional data to send along, used for 'move' and 'duplicate'. - def doPrintJobAction(self, print_job_uuid: str, action: str, data: Optional[Dict[str, Union[str, int]]] = None - ) -> None: - url = f"{self.CLUSTER_API_PREFIX}/print_jobs/{print_job_uuid}/action/{action}/" - body = json.dumps(data).encode() if data else b"" - self._manager.put(self._createEmptyRequest(url), body) + ## Set the state of a print job. + def setPrintJobState(self, print_job_uuid: str, state: str) -> None: + url = f"{self.CLUSTER_API_PREFIX}/print_jobs/{print_job_uuid}/action" + # We rewrite 'resume' to 'print' here because we are using the old print job action endpoints. + action = "print" if state == "resume" else state + self._manager.put(self._createEmptyRequest(url), json.dumps({"action": action}).encode()) + + def forcePrintJob(self, print_job_uuid: str) -> None: + pass # TODO ## We override _createEmptyRequest in order to add the user credentials. # \param url: The URL to request diff --git a/plugins/UM3NetworkPrinting/src/Network/NetworkOutputDevice.py b/plugins/UM3NetworkPrinting/src/Network/NetworkOutputDevice.py index 523bb8a6af..0f516a8aeb 100644 --- a/plugins/UM3NetworkPrinting/src/Network/NetworkOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Network/NetworkOutputDevice.py @@ -96,13 +96,13 @@ class NetworkOutputDevice(UltimakerNetworkedPrinterOutputDevice): @pyqtSlot(str, name="forceSendJob") def forceSendJob(self, print_job_uuid: str) -> None: - self._cluster_api.doPrintJobAction(print_job_uuid, "force") + self._cluster_api.forcePrintJob(print_job_uuid) ## Set the remote print job state. # \param print_job_uuid: The UUID of the print job to set the state for. # \param action: The action to undertake ('pause', 'resume', 'abort'). def setJobState(self, print_job_uuid: str, action: str) -> None: - self._cluster_api.doPrintJobAction(print_job_uuid, action) + self._cluster_api.setPrintJobState(print_job_uuid, action) ## Handle network errors. @staticmethod