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