Tool Assembly

Model

class pytm4srv.models.tool.assembly.ToolAssembly

A grouping to make referencing whole tools easier.

id: MappedColumn object at 0x7ec1c1979d80>]]

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: Mapped[bool]

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 specified process will be included. Ignored if process is not specified.

Status Codes:
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:
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:
DELETE /api/tools/assemblies/(int: asm_id)

Delete a tool assembly.

Parameters:
  • asm_id – the ID of the assembly to delete

Status Codes:
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:
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:
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:
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:
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:
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:
Returns:

the modified ToolAssembly