Skip to content

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 session, any provider of an ORM session (e.g. a test double). With neither, the models keep the session already bound, if any.

None

Examples:

>>> pms = PMSClient(session)
>>> device = pms.find_device_by_serial("SN-001234")
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/client.py
class 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.

    Args:
        session: The authenticated session whose PMS endpoint to bind.
        pms_api: Instead of ``session``, any provider of an ORM session (e.g. a test double).
            With neither, the models keep the session already bound, if any.

    Examples:
        >>> pms = PMSClient(session)
        >>> device = pms.find_device_by_serial("SN-001234")
    """

    def __init__(self, session: CloudSession | None = None, *, pms_api: JsonApiProtocol | None = None) -> None:
        if session is not None and pms_api is not None:
            raise TypeError("Pass either session or pms_api, not both.")
        provider = PMSApi(session) if session is not None else pms_api
        if provider is None:
            return

        bind_session(PMSApiModel, provider.api)

    # ------------------------------------------------------------------
    # Task-level calls
    # ------------------------------------------------------------------

    def find_device_by_serial(self, serial_number: str) -> PMSDevice | None:
        """Return the device with exactly this serial number, with its status, customer and tenants.

        Args:
            serial_number: The serial number, matched exactly.

        Returns:
            PMSDevice | None: The device, or None when there is none.

        Raises:
            PMSLookupError: If more than one device has this serial number.
        """
        query = ResourceQueryBuilder().add_filter("serial_number", serial_number, MatchType.MATCH).include("customer")
        # the server's match may be looser than ==, so the exact comparison is made here
        matches = [d for d in self.device.get_list(params=query) if _attr(d, "serial_number") == serial_number]
        if not matches:
            return None
        if len(matches) > 1:
            raise PMSLookupError(f"{len(matches)} PMS devices have serial number {serial_number!r}.")
        return _device_record(matches[0])

    def create_internal_event(  # noqa: PLR0913
        self,
        device: PMSDevice,
        *,
        event_type: str,
        event_id: str,
        event_date: datetime,
        operator_id: str,
        description: str,
        body: Mapping[str, Any],
    ) -> PMSInternalEvent:
        """Create an internal event linked to ``device`` and its customer, with the device's tenants.

        Args:
            device: The device, as returned by :meth:`find_device_by_serial`. It must have a customer.
            event_type: The event type, e.g. ``EventType.provisioning``.
            event_id: The event's own identifier.
            event_date: When the event happened; a timezone-aware datetime is recommended.
            operator_id: Who or what produced the event.
            description: A short summary.
            body: Free JSON-serialisable content, e.g. ``{"run_id": "..."}``.

        Returns:
            PMSInternalEvent: The created event.

        Raises:
            ValueError: If the device has no customer.
            RuntimeError: If the PMS did not return the created event.
        """
        if device.customer is None:
            raise ValueError(f"Device {device.serial_number!r} has no customer: cannot link the event to one.")
        event = self.internal_event.new()
        event.device = self.device.get_id(device.id)
        event.customer = self.customer.get_id(device.customer.id)
        event.event_type = _wire_value(event_type)
        event.event_id = event_id
        event.event_date = event_date.isoformat()
        event.operator_id = operator_id
        event.description = description
        event.body = dict(body)
        # the device's tenants, so the event is visible to whoever can see the device
        event.tenants = list(device.tenants)
        event.save()
        if not event.id:
            raise RuntimeError(f"The PMS did not return the internal event {event_id!r} it was asked to create.")
        logger.info("Internal event %s (%s) created for device %s.", event_id, event.event_type, device.serial_number)
        return _event_record(event, device_id=device.id, customer_id=device.customer.id)

    def list_internal_events(
        self,
        device: PMSDevice,
        *,
        event_type: str | None = None,
        event_id: str | None = None,
        body: Mapping[str, Any] | None = None,
    ) -> list[PMSInternalEvent]:
        """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.

        Args:
            device: The device, as returned by :meth:`find_device_by_serial`.
            event_type: Only events of this type.
            event_id: Only events with this event ID.
            body: Only events whose body contains these key/value pairs.

        Returns:
            list[PMSInternalEvent]: The matching events, in the order the PMS returned them.
        """
        query = (
            ResourceQueryBuilder()
            .add_related_resource_filter("device", "serial_number", device.serial_number, MatchType.MATCH)
            .include("device", "customer")
        )
        if event_type is not None:
            query.add_filter("event_type", _wire_value(event_type), MatchType.MATCH)
        if event_id is not None:
            query.add_filter("event_id", event_id, MatchType.MATCH)
        records = []
        for event in self.internal_event.get_list(params=query):
            record = _event_record(event)
            if record.device_id != device.id:
                continue
            if event_type is not None and record.event_type != _wire_value(event_type):
                continue
            if event_id is not None and record.event_id != event_id:
                continue
            if body and any(key not in record.body or record.body[key] != value for key, value in body.items()):
                continue
            records.append(record)
        return records

    def update_device_status(self, device_id: str, status: str, *, expected_status: str | None = None) -> None:
        """Set a device's status, e.g. from ``Status.in_stock`` to ``Status.available``.

        Args:
            device_id: The device's PMS ID (``PMSDevice.id``).
            status: The new status.
            expected_status: 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.

        Raises:
            DeviceStatusConflictError: If ``expected_status`` is given and the device is in another status.
        """
        if expected_status is not None:
            current = _attr(self.device.get_id(device_id), "status")
            if current != _wire_value(expected_status):
                raise DeviceStatusConflictError(device_id, _wire_value(expected_status), current)
        # a fresh object holding only the status, so the PATCH changes nothing else
        patch = jsonapi_models.Device(raw_object=data.JsonApiObject(type="devices", id=device_id))
        patch.status = _wire_value(status)
        patch.update()
        logger.info("Device %s status set to %s.", device_id, patch.status)

    # ------------------------------------------------------------------
    # JSON:API interfaces
    # ------------------------------------------------------------------

    @property
    def custom_part(self) -> CustomPartInterface:
        """Returns the interface for interacting with CustomPart resources.

        Returns:
            CustomPartInterface: The interface for managing CustomPart models.

        Examples:
            >>> client.custom_part.get("customer_pn", "CUST-123")
        """
        interface: CustomPartInterface = PMSInterfaceFactory.get_interface("custom_part")
        return interface

    @property
    def customer(self) -> CustomerInterface:
        """Returns the interface for interacting with Customer resources.

        Returns:
            CustomerInterface: The interface for managing Customer models.

        Examples:
            >>> client.customer.get("code", "ACME-CORP")
        """
        interface: CustomerInterface = PMSInterfaceFactory.get_interface("customer")
        return interface

    @property
    def device_group(self) -> DeviceGroupInterface:
        """Returns the interface for interacting with DeviceGroup resources.

        Returns:
            DeviceGroupInterface: The interface for managing DeviceGroup models.

        Examples:
            >>> client.device_group.get_all()
        """
        interface: DeviceGroupInterface = PMSInterfaceFactory.get_interface("device_group")
        return interface

    @property
    def device(self) -> DeviceInterface:
        """Returns the interface for interacting with Device resources.

        Returns:
            DeviceInterface: The interface for managing Device models.

        Examples:
            >>> client.device.get("serial_number", "SN12345")
        """
        interface: DeviceInterface = PMSInterfaceFactory.get_interface("device")
        return interface

    @property
    def filter(self) -> FilterInterface:
        """Returns the interface for interacting with Filter resources.

        Returns:
            FilterInterface: The interface for managing Filter models.

        Examples:
            >>> filters = client.filter.get_all()
        """
        interface: FilterInterface = PMSInterfaceFactory.get_interface("filter")
        return interface

    @property
    def internal_event(self) -> InternalEventInterface:
        """Returns the interface for interacting with InternalEvent resources.

        Returns:
            InternalEventInterface: The interface for managing InternalEvent models.

        Examples:
            >>> client.internal_event.exists("event_id", "INT-456")
        """
        interface: InternalEventInterface = PMSInterfaceFactory.get_interface("internal_event")
        return interface

    @property
    def part_family(self) -> PartFamilyInterface:
        """Returns the interface for interacting with PartFamily resources.

        Returns:
            PartFamilyInterface: The interface for managing PartFamily models.

        Examples:
            >>> families = client.part_family.get_all()
        """
        interface: PartFamilyInterface = PMSInterfaceFactory.get_interface("part_family")
        return interface

    @property
    def part_internal_info(self) -> PartInternalInfoInterface:
        """Returns the interface for interacting with PartInternalInfo resources.

        Returns:
            PartInternalInfoInterface: The interface for managing PartInternalInfo models.

        Examples:
            >>> info = client.part_internal_info.get("status", "approved")
        """
        interface: PartInternalInfoInterface = PMSInterfaceFactory.get_interface("part_internal_info")
        return interface

    @property
    def part(self) -> PartInterface:
        """Returns the interface for interacting with Part resources.

        Returns:
            PartInterface: The interface for managing Part models.

        Examples:
            >>> client.part.get("pn", "PART-789")
        """
        interface: PartInterface = PMSInterfaceFactory.get_interface("part")
        return interface

    @property
    def public_event(self) -> PublicEventInterface:
        """Returns the interface for interacting with PublicEvent resources.

        Returns:
            PublicEventInterface: The interface for managing PublicEvent models.

        Examples:
            >>> event = client.public_event.get("event_id", "PUB-987")
        """
        interface: PublicEventInterface = PMSInterfaceFactory.get_interface("public_event")
        return interface

custom_part property

Returns the interface for interacting with CustomPart resources.

Returns:

Name Type Description
CustomPartInterface CustomPartInterface

The interface for managing CustomPart models.

Examples:

>>> client.custom_part.get("customer_pn", "CUST-123")

customer property

Returns the interface for interacting with Customer resources.

Returns:

Name Type Description
CustomerInterface CustomerInterface

The interface for managing Customer models.

Examples:

>>> client.customer.get("code", "ACME-CORP")

device property

Returns the interface for interacting with Device resources.

Returns:

Name Type Description
DeviceInterface DeviceInterface

The interface for managing Device models.

Examples:

>>> client.device.get("serial_number", "SN12345")

device_group property

Returns the interface for interacting with DeviceGroup resources.

Returns:

Name Type Description
DeviceGroupInterface DeviceGroupInterface

The interface for managing DeviceGroup models.

Examples:

>>> client.device_group.get_all()

filter property

Returns the interface for interacting with Filter resources.

Returns:

Name Type Description
FilterInterface FilterInterface

The interface for managing Filter models.

Examples:

>>> filters = client.filter.get_all()

internal_event property

Returns the interface for interacting with InternalEvent resources.

Returns:

Name Type Description
InternalEventInterface InternalEventInterface

The interface for managing InternalEvent models.

Examples:

>>> client.internal_event.exists("event_id", "INT-456")

part property

Returns the interface for interacting with Part resources.

Returns:

Name Type Description
PartInterface PartInterface

The interface for managing Part models.

Examples:

>>> client.part.get("pn", "PART-789")

part_family property

Returns the interface for interacting with PartFamily resources.

Returns:

Name Type Description
PartFamilyInterface PartFamilyInterface

The interface for managing PartFamily models.

Examples:

>>> families = client.part_family.get_all()

part_internal_info property

Returns the interface for interacting with PartInternalInfo resources.

Returns:

Name Type Description
PartInternalInfoInterface PartInternalInfoInterface

The interface for managing PartInternalInfo models.

Examples:

>>> info = client.part_internal_info.get("status", "approved")

public_event property

Returns the interface for interacting with PublicEvent resources.

Returns:

Name Type Description
PublicEventInterface PublicEventInterface

The interface for managing PublicEvent models.

Examples:

>>> event = client.public_event.get("event_id", "PUB-987")

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:find_device_by_serial. It must have a customer.

required
event_type str

The event type, e.g. EventType.provisioning.

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. {"run_id": "..."}.

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
def create_internal_event(  # noqa: PLR0913
    self,
    device: PMSDevice,
    *,
    event_type: str,
    event_id: str,
    event_date: datetime,
    operator_id: str,
    description: str,
    body: Mapping[str, Any],
) -> PMSInternalEvent:
    """Create an internal event linked to ``device`` and its customer, with the device's tenants.

    Args:
        device: The device, as returned by :meth:`find_device_by_serial`. It must have a customer.
        event_type: The event type, e.g. ``EventType.provisioning``.
        event_id: The event's own identifier.
        event_date: When the event happened; a timezone-aware datetime is recommended.
        operator_id: Who or what produced the event.
        description: A short summary.
        body: Free JSON-serialisable content, e.g. ``{"run_id": "..."}``.

    Returns:
        PMSInternalEvent: The created event.

    Raises:
        ValueError: If the device has no customer.
        RuntimeError: If the PMS did not return the created event.
    """
    if device.customer is None:
        raise ValueError(f"Device {device.serial_number!r} has no customer: cannot link the event to one.")
    event = self.internal_event.new()
    event.device = self.device.get_id(device.id)
    event.customer = self.customer.get_id(device.customer.id)
    event.event_type = _wire_value(event_type)
    event.event_id = event_id
    event.event_date = event_date.isoformat()
    event.operator_id = operator_id
    event.description = description
    event.body = dict(body)
    # the device's tenants, so the event is visible to whoever can see the device
    event.tenants = list(device.tenants)
    event.save()
    if not event.id:
        raise RuntimeError(f"The PMS did not return the internal event {event_id!r} it was asked to create.")
    logger.info("Internal event %s (%s) created for device %s.", event_id, event.event_type, device.serial_number)
    return _event_record(event, device_id=device.id, customer_id=device.customer.id)

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
def find_device_by_serial(self, serial_number: str) -> PMSDevice | None:
    """Return the device with exactly this serial number, with its status, customer and tenants.

    Args:
        serial_number: The serial number, matched exactly.

    Returns:
        PMSDevice | None: The device, or None when there is none.

    Raises:
        PMSLookupError: If more than one device has this serial number.
    """
    query = ResourceQueryBuilder().add_filter("serial_number", serial_number, MatchType.MATCH).include("customer")
    # the server's match may be looser than ==, so the exact comparison is made here
    matches = [d for d in self.device.get_list(params=query) if _attr(d, "serial_number") == serial_number]
    if not matches:
        return None
    if len(matches) > 1:
        raise PMSLookupError(f"{len(matches)} PMS devices have serial number {serial_number!r}.")
    return _device_record(matches[0])

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:find_device_by_serial.

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
def list_internal_events(
    self,
    device: PMSDevice,
    *,
    event_type: str | None = None,
    event_id: str | None = None,
    body: Mapping[str, Any] | None = None,
) -> list[PMSInternalEvent]:
    """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.

    Args:
        device: The device, as returned by :meth:`find_device_by_serial`.
        event_type: Only events of this type.
        event_id: Only events with this event ID.
        body: Only events whose body contains these key/value pairs.

    Returns:
        list[PMSInternalEvent]: The matching events, in the order the PMS returned them.
    """
    query = (
        ResourceQueryBuilder()
        .add_related_resource_filter("device", "serial_number", device.serial_number, MatchType.MATCH)
        .include("device", "customer")
    )
    if event_type is not None:
        query.add_filter("event_type", _wire_value(event_type), MatchType.MATCH)
    if event_id is not None:
        query.add_filter("event_id", event_id, MatchType.MATCH)
    records = []
    for event in self.internal_event.get_list(params=query):
        record = _event_record(event)
        if record.device_id != device.id:
            continue
        if event_type is not None and record.event_type != _wire_value(event_type):
            continue
        if event_id is not None and record.event_id != event_id:
            continue
        if body and any(key not in record.body or record.body[key] != value for key, value in body.items()):
            continue
        records.append(record)
    return records

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 (PMSDevice.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 expected_status is given and the device is in another status.

Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/client.py
def update_device_status(self, device_id: str, status: str, *, expected_status: str | None = None) -> None:
    """Set a device's status, e.g. from ``Status.in_stock`` to ``Status.available``.

    Args:
        device_id: The device's PMS ID (``PMSDevice.id``).
        status: The new status.
        expected_status: 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.

    Raises:
        DeviceStatusConflictError: If ``expected_status`` is given and the device is in another status.
    """
    if expected_status is not None:
        current = _attr(self.device.get_id(device_id), "status")
        if current != _wire_value(expected_status):
            raise DeviceStatusConflictError(device_id, _wire_value(expected_status), current)
    # a fresh object holding only the status, so the PATCH changes nothing else
    patch = jsonapi_models.Device(raw_object=data.JsonApiObject(type="devices", id=device_id))
    patch.status = _wire_value(status)
    patch.update()
    logger.info("Device %s status set to %s.", device_id, patch.status)

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
class PMSDevice(_Record):
    """A PMS device with its status, customer and tenants."""

    id: str
    serial_number: str
    status: str | None = None
    connhex_id: str | None = None
    model_id: str | None = None
    tenants: list[str] = Field(default_factory=list)
    customer: PMSCustomer | None = None

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
class PMSCustomer(_Record):
    """A PMS customer, as linked to a device."""

    id: str
    code: str | None = None
    name: str | None = None
    tenant_id: str | None = None
    team_ids: list[str] = Field(default_factory=list)

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
class PMSInternalEvent(_Record):
    """A PMS internal event."""

    id: str
    event_type: str | None = None
    event_id: str | None = None
    event_date: datetime | None = None
    operator_id: str | None = None
    description: str | None = None
    body: dict[str, Any] = Field(default_factory=dict)
    tenants: list[str] = Field(default_factory=list)
    device_id: str | None = None
    customer_id: str | None = None

Errors

tlm_cloud_sdk.manufacturing.client.PMSLookupError

Bases: LookupError

A PMS lookup found nothing, or more than the one resource it expected.

Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/client.py
class PMSLookupError(LookupError):
    """A PMS lookup found nothing, or more than the one resource it expected."""

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
class DeviceStatusConflictError(RuntimeError):
    """A status update was refused because the device was not in the expected status."""

    def __init__(self, device_id: str, expected: str, actual: str | None) -> None:
        super().__init__(f"Device {device_id} is {actual!r}, not {expected!r}: status left unchanged.")
        self.device_id = device_id
        self.expected = expected
        self.actual = actual

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
class EventType(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:
        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'>
    """

    manufacturing = "MANUFACTURING"
    manufacturing_test = "MANUFACTURING_TEST"
    provisioning = "PROVISIONING"
    delivery = "DELIVERY"
    invoice = "INVOICE"
    rma = "RMA"
    disposal = "DISPOSAL"
    after_sales_incoming = "AFTER_SALES_INCOMING"

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:

>>> interface = PMSInterfaceFactory.get_interface("custom_part")
>>> custom_part = interface.new()
Source code in packages/tlm-cloud-sdk/tlm_cloud_sdk/manufacturing/client.py
class PMSInterfaceFactory(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:
        _model_map (dict): A mapping of model names to their interface classes.

    Examples:
        >>> interface = PMSInterfaceFactory.get_interface("custom_part")
        >>> custom_part = interface.new()
    """

    _model_map = {
        "custom_part": CustomPartInterface,
        "customer": CustomerInterface,
        "device": DeviceInterface,
        "device_group": DeviceGroupInterface,
        "filter": FilterInterface,
        "internal_event": InternalEventInterface,
        "part_family": PartFamilyInterface,
        "part_internal_info": PartInternalInfoInterface,
        "part": PartInterface,
        "public_event": PublicEventInterface,
    }