Skip to content
Snippets Groups Projects
Commit 30f591e5 authored by istmxrein's avatar istmxrein
Browse files

Add update models to meta events

parent 5c09b46b
Branches
No related tags found
No related merge requests found
...@@ -15,10 +15,9 @@ from pilab.events import utils ...@@ -15,10 +15,9 @@ from pilab.events import utils
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class EventType(str, Enum):
CREATE = 'create' def convert_to_optional(schema):
UPDATE = 'update' return {k: Optional[v] for k, v in schema.__annotations__.items() if k != "id"}
DELETE = 'delete'
class Host(BaseModel): class Host(BaseModel):
...@@ -31,6 +30,13 @@ class Host(BaseModel): ...@@ -31,6 +30,13 @@ class Host(BaseModel):
hostname: str hostname: str
class HostUpdate(Host):
"""
representation of host for update
"""
__annotations__ = convert_to_optional(Host)
class Pi(Host): class Pi(Host):
""" """
representation of pi object with host id representation of pi object with host id
...@@ -39,7 +45,13 @@ class Pi(Host): ...@@ -39,7 +45,13 @@ class Pi(Host):
display: bool display: bool
position: int position: int
ssh_host_ed25519_key: Optional[str] ssh_host_ed25519_key: Optional[str]
pass
class PiUpdate(HostUpdate):
"""
representation of pi object for update
"""
__annotations__ = convert_to_optional(Pi)
class Cube(BaseModel): class Cube(BaseModel):
...@@ -51,14 +63,18 @@ class Cube(BaseModel): ...@@ -51,14 +63,18 @@ class Cube(BaseModel):
switch: Host switch: Host
head: Pi head: Pi
workers: List[Pi] workers: List[Pi]
pass
class EventType(str, Enum):
CREATE = 'create'
UPDATE = 'update'
DELETE = 'delete'
class Event(BaseModel): class Event(BaseModel):
type: EventType type: EventType
timestamp: float timestamp: float
payload: Cube payload: Cube
pass
class EventListener(threading.Thread): class EventListener(threading.Thread):
......
...@@ -2,7 +2,7 @@ from setuptools import setup, find_packages ...@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name='pilab', name='pilab',
version='2.0.0', version='2.1.0',
description='Shared-Libs for the pi-lab microservices', description='Shared-Libs for the pi-lab microservices',
url='https://code.fbi.h-da.de/api/v4/projects/27896/packages/pypi/pilab', url='https://code.fbi.h-da.de/api/v4/projects/27896/packages/pypi/pilab',
author='Max Reinheimer', author='Max Reinheimer',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment