Tool Assembly
Model
- class pytm4srv.models.tool.assembly.ToolAssembly
A grouping to make referencing whole tools easier.
- id: MappedColumn object at 0x7d28dc361c60>]]
Unique, numeric ID for this tool assembly in OnTakt.
- image: Mapped[bytes | None]
A user-provided image of this tool.
- image_type: Mapped[str | None]
The MIME type of the file stored in
image
.
- location: Mapped[int | None]
User-specified location of the assembly for identification.
Usually the tool pot number in the machine.
- name: Mapped[str]
User-specified name of this tool assembly.
- notes: Mapped[str]
User-specified notes about the assembly.
- process_id: Mapped[int | None]
The ID of the process this assembly is currently being used for.
Shared tools are associated with a machine instead of a single process.
When OnTakt detects that a machine has switched processes, it will reassign all shared tools in any process associated with that machine to the newly loaded process.
Endpoints
- GET /api/tools/assemblies/
Get all current tool assemblies.
- Query Parameters:
process (int) – if set, only tool assemblies with the specified process ID will be returned.
shared (int) – if set to
1
, shared tool assemblies from other processes on the same machine as the specifiedprocess
will be included. Ignored ifprocess
is not specified.
- Status Codes:
424 Failed Dependency – if the process ID specified does not exist
- Return:
an object mapping IDs to assembly objects
- PUT /api/tools/assemblies/
Create a new tool assembly.
- Reqjson:
partial ToolAssembly object (name is required, everything else is optional)
- Status Codes:
400 Bad Request – if the name is missing
201 Created – on success
- Returns:
the new assembly object
- PATCH /api/tools/assemblies/(int: asm_id)
Edit an existing assembly.
- Parameters:
asm_id – the ID of the assembly to edit
- Return:
the modified assembly object.
- Status Codes:
404 Not Found – if the assembly does not exist
- DELETE /api/tools/assemblies/(int: asm_id)
Delete a tool assembly.
- Parameters:
asm_id – the ID of the assembly to delete
- Status Codes:
404 Not Found – if the assembly does not exist
204 No Content – on success
- POST /api/tools/assemblies/(int: asm_id)/duplicate
Duplicate a tool assembly.
- Parameters:
asm_id – the ID of the original assembly to duplicate
- Request JSON Array of Objects:
tools (int) – optional list of tool IDs to place into the new assembly. Tools listed must not already be in an assembly.
- Resjsonobj:
the new assembly object
- Returns:
the new ToolAssembly object
- Status Codes:
201 Created – on success
400 Bad Request – if any tools referenced in provided fields do not exist or are already used in an assembly
404 Not Found – if the original assembly does not exist
Example request body:
{ "assembly": { "name": "My new assembly", "notes": "This assembly, which will be part of process 34, was duplicated from an existing assembly. It will contain tools 224 and 226, and duplicates of tools 176 and 120.", "process_id": 34 }, "tools": [224, 226], "duplicate": { "176": "Copy of tool with ID 176", "120": "Another of tool with ID 120" } }
- POST /api/tools/assemblies/(int: asm_id)/addTools
Add tools to an assembly.
Any tools that are already in the assembly will be silently ignored.
- Parameters:
asm_id – the ID of the target assembly
- Request JSON Array of Objects:
tools (int) – list of tool IDs to add
- Return:
the modified assembly object
- Status Codes:
400 Bad Request – if the tools array is missing or invalid
404 Not Found – if the assembly does not exist
- GET /api/tools/assemblies/(int: asm_id)/replacements
Get the replacement history for a tool.
- Query Parameters:
limit (int) – maximum number of items to return (defaults to all). More recent replacements are returned first.
offset (int) – skip past this many results
- Parameters:
asm_id – The ID of the tool assembly to query.
- Returns:
an object mapping replacement ID to replacement object
- Status Codes:
404 Not Found – if the tool assembly doesn’t exist
- POST /api/tools/assemblies/(int: asm_id)/merge
Merge several source tool assemblies into this one destination tool assembly. This will move all tools from the source assemblies into the destination assembly, and then delete the now-empty source assemblies.
- Parameters:
asm_id – the ID of the destination assembly
- Reqjsonarr:
list of source assembly IDs
- Resjsonobj:
destination assembly object after the merge
- Status Codes:
412 Precondition Failed – if any assembly IDs listed do not exist
- GET /api/tools/assemblies/(int: obj_id)/image
Get the current image file of the ToolAssembly.
- Parameters:
obj_id – ID of the ToolAssembly to get the image for
- Status Codes:
200 OK – if the ToolAssembly exists and an image is set
404 Not Found – if the ToolAssembly does not exist
412 Precondition Failed – if the ToolAssembly exists but does not have an image
- Returns:
the image file, with the
Content-Type
header set to its MIME type
- POST /api/tools/assemblies/(int: obj_id)/image
Upload a new image file for the ToolAssembly.
The request body should be an image file, and the
Content-Type
header should contain its MIME type.- Parameters:
obj_id – ID of the ToolAssembly to set the image for
- Status Codes:
200 OK – on success
404 Not Found – if the ToolAssembly does not exist
413 Request Entity Too Large – if the image file is larger than 5 MB
415 Unsupported Media Type – if the image file is invalid or of an unsupported type
- Returns:
the modified ToolAssembly
- DELETE /api/tools/assemblies/(int: obj_id)/image
Remove the image from the ToolAssembly.
- Parameters:
obj_id – ID of the ToolAssembly to clear the image from
- Status Codes:
404 Not Found – if the ToolAssembly does not exist
200 OK – on success
- Returns:
the modified ToolAssembly