Version v1.0.0-alpha (latest)
Operations
Poll and manage the long-running operations started by endpoints called with ?async=true. /v1/operation/get/ returns one operation's status and, once finished, its result. See the Asynchronous requests section of the introduction.
Get one operation's status and result#
GET/v1/operation/get/
Returns the full record of one operation started by a ?async=true request: its status, its progress, and, once status is SUCCEEDED or FAILED, the result the originating endpoint would have returned synchronously. This is the URL returned in operation_url (and the Location header) of every 202 Accepted response.
With mode=oneshot, a finished operation's record is deleted after this response, so the result can be fetched exactly once and needs no separate /v1/operation/delete/ call. An IN_PROGRESS operation is never deleted. The default, mode=persistent, never deletes.
Error codes#
| HTTP | error.code | Cause |
|---|---|---|
| 400 | MISSING_QUERY_PARAMETER | No operation_id query parameter was given. |
| 400 | INVALID_QUERY_PARAMETER | mode is present but not oneshot or persistent. |
| 404 | NOT_FOUND | No operation with that id exists (never started, deleted, or fetched with mode=oneshot, or the server restarted). |
Query parameters
operation_idstring (uuid)RequiredId of the operation, as received in
operation_idfrom the202 Acceptedresponse that started it.modestringWhether fetching a finished operation deletes its record (
oneshot) or keeps it (persistent, the default).oneshotpersistent
ReturnsOperationWithResult
idstring (uuid)RequiredThe operation's id, as returned in
operation_idwhen it was started.The current state of a long-running operation.
IN_PROGRESS- The operation has not finished yet.
SUCCEEDED- The operation finished successfully.
FAILED- The operation finished with an error. The error envelope is available in the
resultfield of/v1/operation/get/./v1/operation/list/reports the status only.
progressnumber (float)RequiredProgress of the operation, from 0.0 to 1.0.
resultobjectPresent once
statusisSUCCEEDEDorFAILED, absent whileIN_PROGRESS. On success this is the JSON body the originating endpoint documents as its200response. On failure it is the standard error envelope (error.code,error.message). Endpoints whose synchronous success response has no body leaveresultabsent even after success.
The operation's current record.
/v1/operation/get/from formlabs_sdk import FormlabsClient
with FormlabsClient() as client:
preform = client.preform.connect()
result = preform.get_operation(
operation_id="3fa85f64-5717-4562-b3fc-2c963f66afa6",
)curl "http://localhost:44388/v1/operation/get/?operation_id=3fa85f64-5717-4562-b3fc-2c963f66afa6"{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"status": "IN_PROGRESS",
"progress": 0.42
}{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"status": "SUCCEEDED",
"progress": 1,
"result": {
"job_id": "8f14e45f-ceea-467f-a34e-9b6d2d7a90ae"
}
}{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"status": "FAILED",
"progress": 1,
"result": {
"error": {
"code": "OPERATION_FAILED",
"message": "Cannot print: the printer is busy"
}
}
}List operations#
POST/v1/operation/list/
List all in-progress, succeeded, and failed operations started by ?async=true requests since this server was launched. Operations are not persisted across server restarts. An optional operations array filters the results to specific operation ids. Only statuses are reported. Use /v1/operation/get/ to retrieve an operation's result.
Error codes#
| HTTP | error.code | Cause |
|---|---|---|
| 404 | NOT_FOUND | An id in operations does not correspond to any known operation. |
Request bodyobject
operationsarray of string (uuid)sOperation ids to return, as received in
operation_idfrom the202 Acceptedresponse that started each one. Omitting this field, or sending an empty array, selects every known operation.
Returnsobject
countintegerRequiredNumber of operations in the response.
operationsarray of OperationsRequiredShow child attributes
idstring (uuid)RequiredThe operation's id, as returned in
operation_idwhen it was started.The current state of a long-running operation.
IN_PROGRESS- The operation has not finished yet.
SUCCEEDED- The operation finished successfully.
FAILED- The operation finished with an error. The error envelope is available in the
resultfield of/v1/operation/get/./v1/operation/list/reports the status only.
progressnumber (float)RequiredProgress of the operation, from 0.0 to 1.0.
The requested operations, or every known operation if operations was omitted, empty, or malformed.
/v1/operation/list/from formlabs_sdk import FormlabsClient
with FormlabsClient() as client:
preform = client.preform.connect()
result = preform.list_operations()curl -X POST "http://localhost:44388/v1/operation/list/" \
-H "Content-Type: application/json" \
-d '{}'from formlabs_sdk import FormlabsClient
with FormlabsClient() as client:
preform = client.preform.connect()
result = preform.list_operations(
operations=["7c9e6679-7425-40de-944b-e07fc1f90ae7"],
)curl -X POST "http://localhost:44388/v1/operation/list/" \
-H "Content-Type: application/json" \
-d '{
"operations": [
"7c9e6679-7425-40de-944b-e07fc1f90ae7"
]
}'{
"count": 1,
"operations": [
{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"status": "IN_PROGRESS",
"progress": 0.42
}
]
}Delete operations#
DELETE/v1/operation/delete/
Removes one or more operation records from the server. Operations are validated before any are deleted: if any requested operation does not exist, or is still IN_PROGRESS, nothing is deleted.
Error codes#
| HTTP | error.code | Cause |
|---|---|---|
| 400 | JSON_PARSE_ERROR | The request body is not a valid JSON object. |
| 400 | JSON_SCHEMA_MATCH_ERROR | operations is missing, empty, or not an array of strings, or an unrecognized field is present. |
| 404 | NOT_FOUND | An id in operations does not correspond to any known operation. Nothing was deleted. |
| 409 | OPERATION_IN_PROGRESS | An operation in operations is still IN_PROGRESS. Nothing was deleted. |
Request bodyobject
operationsarray of string (uuid)sRequiredIds of the operations to delete, as received in
operation_idwhen each was started.
Returnsno body
The operations were deleted. The response has no body.
/v1/operation/delete/from formlabs_sdk import FormlabsClient
with FormlabsClient() as client:
preform = client.preform.connect()
preform.delete_operations(
operations=["7c9e6679-7425-40de-944b-e07fc1f90ae7"],
)curl -X DELETE "http://localhost:44388/v1/operation/delete/" \
-H "Content-Type: application/json" \
-d '{
"operations": [
"7c9e6679-7425-40de-944b-e07fc1f90ae7"
]
}'No response body.