Manufacturing Module (PMS)¶
SDK API reference for the tlm_cloud_sdk.manufacturing package.
Use this package to interact with the Product Management System programmatically. PMSClient(session) offers
task-level calls that return plain records (find_device_by_serial, create_internal_event, list_internal_events,
update_device_status), and typed access to all PMS resources — devices, parts, events, customers, models, and
more — through the same interfaces that power the tlm-cli pms commands.
PMSClient¶
tlm_cloud_sdk.manufacturing.client.PMSClient
¶
Client for the PMS (manufacturing) API.
Task-level calls (:meth:find_device_by_serial, :meth:create_internal_event,
:meth:list_internal_events, :meth:update_device_status) return plain records. The properties
(client.device, client.internal_event, ...) give the lower-level JSON:API interfaces.
The PMS session is process-wide: jsonapi-requests keeps it on the model classes, so constructing a
PMSClient binds its session for every PMS model, and a process talks to one PMS instance at a time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
CloudSession | None
|
The authenticated session whose PMS endpoint to bind. |
None
|
pms_api
|
JsonApiProtocol | None
|
Instead of |
None
|
Examples:
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/client.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
custom_part
property
¶
customer
property
¶
device
property
¶
device_group
property
¶
filter
property
¶
internal_event
property
¶
part
property
¶
part_family
property
¶
part_internal_info
property
¶
public_event
property
¶
create_internal_event(device, *, event_type, event_id, event_date, operator_id, description, body)
¶
Create an internal event linked to device and its customer, with the device's tenants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
PMSDevice
|
The device, as returned by :meth: |
required |
event_type
|
str
|
The event type, e.g. |
required |
event_id
|
str
|
The event's own identifier. |
required |
event_date
|
datetime
|
When the event happened; a timezone-aware datetime is recommended. |
required |
operator_id
|
str
|
Who or what produced the event. |
required |
description
|
str
|
A short summary. |
required |
body
|
Mapping[str, Any]
|
Free JSON-serialisable content, e.g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PMSInternalEvent |
PMSInternalEvent
|
The created event. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the device has no customer. |
RuntimeError
|
If the PMS did not return the created event. |
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/client.py
find_device_by_serial(serial_number)
¶
Return the device with exactly this serial number, with its status, customer and tenants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serial_number
|
str
|
The serial number, matched exactly. |
required |
Returns:
| Type | Description |
|---|---|
PMSDevice | None
|
PMSDevice | None: The device, or None when there is none. |
Raises:
| Type | Description |
|---|---|
PMSLookupError
|
If more than one device has this serial number. |
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/client.py
list_internal_events(device, *, event_type=None, event_id=None, body=None)
¶
Return the internal events of device, optionally narrowed down.
Device, event_type and event_id are filtered by the PMS. body is matched here, on the events
it returned: an event matches when its body holds every key of body with an equal value, so
body={"run_id": run_id} finds the event an earlier attempt of the same run created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
PMSDevice
|
The device, as returned by :meth: |
required |
event_type
|
str | None
|
Only events of this type. |
None
|
event_id
|
str | None
|
Only events with this event ID. |
None
|
body
|
Mapping[str, Any] | None
|
Only events whose body contains these key/value pairs. |
None
|
Returns:
| Type | Description |
|---|---|
list[PMSInternalEvent]
|
list[PMSInternalEvent]: The matching events, in the order the PMS returned them. |
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/client.py
update_device_status(device_id, status, *, expected_status=None)
¶
Set a device's status, e.g. from Status.in_stock to Status.available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_id
|
str
|
The device's PMS ID ( |
required |
status
|
str
|
The new status. |
required |
expected_status
|
str | None
|
When given, the device is read first and left unchanged unless it is in this status. The read and the write are two requests, so this guards against mistakes, not races. |
None
|
Raises:
| Type | Description |
|---|---|
DeviceStatusConflictError
|
If |
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/client.py
Records¶
tlm_cloud_sdk.manufacturing.records.PMSDevice
¶
Bases: _Record
A PMS device with its status, customer and tenants.
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/records.py
tlm_cloud_sdk.manufacturing.records.PMSCustomer
¶
Bases: _Record
A PMS customer, as linked to a device.
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/records.py
tlm_cloud_sdk.manufacturing.records.PMSInternalEvent
¶
Bases: _Record
A PMS internal event.
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/records.py
Errors¶
tlm_cloud_sdk.manufacturing.client.PMSLookupError
¶
tlm_cloud_sdk.manufacturing.client.DeviceStatusConflictError
¶
Bases: RuntimeError
A status update was refused because the device was not in the expected status.
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/client.py
Event types¶
tlm_cloud_sdk.manufacturing.models.event_type.EventType
¶
Bases: StrEnum
Enumerates the event types the SDK knows of, shared by internal and public events.
The list is not exhaustive: the PMS accepts other types, and :class:InternalEvent and
:class:PublicEvent keep them as plain strings.
Attributes:
| Name | Type | Description |
|---|---|---|
manufacturing |
str
|
A manufacturing event. |
manufacturing_test |
str
|
A manufacturing test event. |
provisioning |
str
|
A provisioning run (e.g. by the ToloMEO provisioner). |
delivery |
str
|
A delivery event. |
invoice |
str
|
An invoice event. |
rma |
str
|
A Return Merchandise Authorization (RMA) event. |
disposal |
str
|
A disposal event. |
after_sales_incoming |
str
|
An after-sales incoming event. |
Examples:
>>> EventType.provisioning
<EventType.provisioning: 'PROVISIONING'>
>>> EventType("DELIVERY")
<EventType.delivery: 'DELIVERY'>
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/models/event_type.py
PMSInterfaceFactory¶
tlm_cloud_sdk.manufacturing.client.PMSInterfaceFactory
¶
Bases: BaseInterfaceFactory
Factory class for retrieving PMS API interface instances.
This class provides access to interface classes responsible for interacting with various PMS API models such as devices, filters, and events. It also supports data population for those models through their corresponding interfaces.
Attributes:
| Name | Type | Description |
|---|---|---|
_model_map |
dict
|
A mapping of model names to their interface classes. |
Examples: