Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
5 changes: 5 additions & 0 deletions Python/elasticai-stubs/protocol/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import base as base
from . import data_requester as data_requester
from . import exceptions as exceptions

__all__ = ["base", "data_requester", "exceptions"]
58 changes: 58 additions & 0 deletions Python/elasticai-stubs/protocol/base.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from enum import Enum
from typing import Callable

from elasticai.protocol.client_interface import PubSubInterface as PubSubInterface

class DeviceType(str, Enum):
APPLICATION = "APP"
NODE = "NODE"

class DeviceState(str, Enum):
OFFLINE = "OFFLINE"
ONLINE = "ONLINE"

class Protocol:
def __init__(
self,
handler: PubSubInterface,
device_type: DeviceType = ...,
base_url: str = "eaip://uni-due.de",
) -> None: ...
def publish_status(
self,
device_state: DeviceState,
additional_information: dict[str, str] | None = None,
) -> None: ...
def publish_data(self, data_id: str, data: str) -> None: ...
def publish_start(self, device_id: str, data_id: str) -> None: ...
def publish_stop(self, device_id: str, data_id: str) -> None: ...
def publish_do(
self, device_id: str, command: str, settings: str | None = None
) -> None: ...
def publish_done(self, device_id: str, command: str, result: str) -> None: ...
def subscribe_status(
self, device_id: str, handler: Callable[[str, str], None]
) -> None: ...
def subscribe_data(
self, device_id: str, data_id: str, handler: Callable[[str, str], None]
) -> None: ...
def subscribe_start(
self, data_id: str, handler: Callable[[str, str], None]
) -> None: ...
def subscribe_stop(
self, data_id: str, handler: Callable[[str, str], None]
) -> None: ...
def subscribe_do(
self, command: str, handler: Callable[[str, str], None]
) -> None: ...
def subscribe_done(
self, device_id: str, command: str, handler: Callable[[str, str], None]
) -> None: ...
def unsubscribe_status(self, device_id: str) -> None: ...
def unsubscribe_data(self, device_id: str, data_id: str) -> None: ...
def unsubscribe_start(self, data_id: str) -> None: ...
def unsubscribe_stop(self, data_id: str) -> None: ...
def unsubscribe_do(self, command: str) -> None: ...
def unsubscribe_done(self, device_id: str, command: str) -> None: ...
@staticmethod
def parse_status(status: str) -> dict[str, str]: ...
14 changes: 14 additions & 0 deletions Python/elasticai-stubs/protocol/client_interface.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from abc import ABCMeta, abstractmethod
from typing import Callable

class PubSubInterface(metaclass=ABCMeta):
@classmethod
def __subclasshook__(cls, subclass: type) -> bool: ...
@abstractmethod
def get_client_id(self) -> str: ...
@abstractmethod
def publish(self, topic: str, message: str, retain: bool = False) -> None: ...
@abstractmethod
def subscribe(self, topic: str, handler: Callable[[str, str], None]) -> None: ...
@abstractmethod
def unsubscribe(self, topic: str) -> None: ...
13 changes: 13 additions & 0 deletions Python/elasticai-stubs/protocol/data_requester.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from elasticai.protocol.base import DeviceState as DeviceState
from elasticai.protocol.base import Protocol as Protocol
from elasticai.protocol.exceptions import (
DeviceNotAvailableError as DeviceNotAvailableError,
)

class DataRequester:
def __init__(
self, protocol: Protocol, target_device: str, data_id: str
) -> None: ...
def start(self) -> None: ...
def stop(self) -> None: ...
def get_data(self) -> str | None: ...
1 change: 1 addition & 0 deletions Python/elasticai-stubs/protocol/exceptions.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class DeviceNotAvailableError(Exception): ...
Empty file added Python/elasticai-stubs/py.typed
Empty file.
Empty file added Python/mqtt-stubs/__init__.pyi
Empty file.
24 changes: 24 additions & 0 deletions Python/mqtt-stubs/client.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from typing import Callable

import paho.mqtt.client as paho_client
from elasticai.protocol.client_interface import PubSubInterface

class PublishError(Exception): ...
class SubscribeError(Exception): ...
class UnsubscribeError(Exception): ...

class MQTTClient(PubSubInterface):
def __init__(
self,
client_id: str,
clean_session: bool = False,
mqtt_version: paho_client.MQTTProtocolVersion = ...,
auto_reconnect: bool = True,
) -> None: ...
def __del__(self) -> None: ...
def connect(self, mqtt_broker_address: str, mqtt_broker_port: int) -> None: ...
def disconnect(self) -> None: ...
def get_client_id(self) -> str: ...
def publish(self, topic: str, message: str, retain: bool = False) -> None: ...
def subscribe(self, topic: str, handler: Callable[[str, str], None]) -> None: ...
def unsubscribe(self, topic: str) -> None: ...
Empty file added Python/mqtt-stubs/py.typed
Empty file.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["Python/elasticai", "Python/mqtt"]
packages = ["Python/elasticai","Python/elasticai-stubs" , "Python/mqtt", "Python/mqtt-stubs"]
exclude = [
"*_test.py",
]
Expand Down
Loading
Loading