Skip to content

Manufacturing Module (PMS)

Python API reference for the tlm_cli.manufacturing package.

Use this package to interact with the Product Management System programmatically. PMSClient gives you typed access to all PMS resources — devices, parts, events, customers, models, and more — using the same interfaces that power the tlm-cli pms commands.


PMSClient

tlm_cli.manufacturing.client.PMSClient

Client interface for accessing PMS API interfaces.

This class exposes a property-based interface for accessing various PMS API model interfaces. Each property returns an interface responsible for interacting with a specific PMS model (e.g., Part, Customer, Event).

Parameters:

Name Type Description Default
pms_api JsonApiProtocol | None

Optional PMS API provider. When omitted, the models keep their lazily built PMSApi session. Inject a custom implementation for testing.

None

Examples:

>>> client = PMSClient()
>>> part_interface = client.custom_part
>>> part = part_interface.get("pn", "PART-123")
Source code in tlm_cli/manufacturing/client.py
class PMSClient:
    """Client interface for accessing PMS API interfaces.

    This class exposes a property-based interface for accessing various PMS API
    model interfaces. Each property returns an interface responsible for
    interacting with a specific PMS model (e.g., Part, Customer, Event).

    Args:
        pms_api: Optional PMS API provider. When omitted, the models keep their lazily built
            ``PMSApi`` session. Inject a custom implementation for testing.

    Examples:
        >>> client = PMSClient()
        >>> part_interface = client.custom_part
        >>> part = part_interface.get("pn", "PART-123")
    """

    def __init__(self, pms_api: JsonApiProtocol | None = None) -> None:
        if pms_api is None:
            return

        bind_session(PMSApiModel, pms_api.api)

    @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")

PMSInterfaceFactory

tlm_cli.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 tlm_cli/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,
    }