mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Add basic support for print job actions via Cloud output device
This commit is contained in:
parent
c65fefce67
commit
eb8d353e11
7 changed files with 50 additions and 34 deletions
|
@ -96,6 +96,21 @@ class CloudApiClient:
|
|||
reply = self._manager.post(self._createEmptyRequest(url), b"")
|
||||
self._addCallback(reply, on_finished, CloudPrintResponse)
|
||||
|
||||
## Send a print job action to the cluster for the given print job.
|
||||
# \param cluster_id: The ID of the cluster.
|
||||
# \param cluster_job_id: The ID of the print job within the cluster.
|
||||
# \param action: The name of the action to execute.
|
||||
def doPrintJobAction(self, cluster_id: str, cluster_job_id: str, action: str, data: Dict[str, any] = None) -> None:
|
||||
body = b""
|
||||
if data:
|
||||
try:
|
||||
body = json.dumps({"data": data}).encode()
|
||||
except JSONDecodeError as err:
|
||||
Logger.log("w", "Could not encode body: %s", err)
|
||||
return
|
||||
url = "{}/clusters/{}/print_jobs/{}/action/{}".format(self.CLUSTER_API_ROOT, cluster_id, cluster_job_id, action)
|
||||
self._manager.post(self._createEmptyRequest(url), body)
|
||||
|
||||
## We override _createEmptyRequest in order to add the user credentials.
|
||||
# \param url: The URL to request
|
||||
# \param content_type: The type of the body contents.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue