From 4bba344e8abcd64947c06b371ae84ca8f0591a9c Mon Sep 17 00:00:00 2001 From: Artur Borecki Date: Thu, 5 Mar 2026 21:25:11 +0100 Subject: [PATCH] feat(message.py): add `Message.Telemetry` factory class --- src/judas_protocol/message.py | 67 ++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/judas_protocol/message.py b/src/judas_protocol/message.py index 0139619..39e8027 100644 --- a/src/judas_protocol/message.py +++ b/src/judas_protocol/message.py @@ -5,7 +5,12 @@ import json import uuid from typing import Any, override -from judas_protocol.types import ActionType, Category, ControlAction +from judas_protocol.types import ( + ActionType, + Category, + ControlAction, + TelemetryAction, +) class Message: @@ -108,6 +113,66 @@ class Message: ack_required=True, ) + class Telemetry: + """TELEMETRY category message factory methods.""" + + @staticmethod + def initial(payload: dict[str, Any]) -> Message: + """Create an INITIAL telemetry message. + + Args: + payload (dict[str, Any]): The payload of the message. + + Returns: + Message: The created INITIAL telemetry message. + """ + return Message( + id_=None, + category=Category.TELEMETRY, + action=TelemetryAction.INITIAL, + payload=payload, + acknowledged=False, + ack_required=True, + ) + + @staticmethod + def update(payload: dict[str, Any]) -> Message: + """Create an UPDATE telemetry message. + + Args: + payload (dict[str, Any]): The payload of the message. + + Returns: + Message: The created UPDATE telemetry message. + """ + return Message( + id_=None, + category=Category.TELEMETRY, + action=TelemetryAction.UPDATE, + payload=payload, + acknowledged=False, + ack_required=False, + ) + + @staticmethod + def on_demand(payload: dict[str, Any]) -> Message: + """Create an ON_DEMAND telemetry message. + + Args: + payload (dict[str, Any]): The payload of the message. + + Returns: + Message: The created ON_DEMAND telemetry message. + """ + return Message( + id_=None, + category=Category.TELEMETRY, + action=TelemetryAction.ON_DEMAND, + payload=payload, + acknowledged=False, + ack_required=True, + ) + def to_dict(self) -> dict[str, Any]: """Convert the message to a dictionary.