lookingglass/hyperglass/models/ui.py
2021-09-24 01:04:28 -07:00

74 lines
1.6 KiB
Python

"""UI Configuration models."""
# Standard Library
from typing import Any, Dict, List, Tuple, Union, Literal, Optional
# Third Party
from pydantic import StrictStr, StrictBool
# Local
from .main import HyperglassModel
from .config.web import WebPublic
from .config.cache import CachePublic
from .config.params import ParamsPublic
from .config.messages import Messages
Alignment = Union[Literal["left"], Literal["center"], Literal["right"], None]
StructuredDataField = Tuple[str, str, Alignment]
class UIDirectiveInfo(HyperglassModel):
"""UI: Directive Info."""
enable: StrictBool
params: Dict[str, str]
content: StrictStr
class UIDirective(HyperglassModel):
"""UI: Directive."""
id: StrictStr
name: StrictStr
field_type: StrictStr
groups: List[StrictStr]
description: StrictStr
info: Optional[UIDirectiveInfo] = None
options: Optional[List[Dict[str, Any]]]
class UILocation(HyperglassModel):
"""UI: Location (Device)."""
id: StrictStr
name: StrictStr
group: StrictStr
avatar: Optional[StrictStr]
description: Optional[StrictStr]
directives: List[UIDirective] = []
class UIDevices(HyperglassModel):
"""UI: Devices."""
group: StrictStr
locations: List[UILocation] = []
class UIContent(HyperglassModel):
"""UI: Content."""
credit: StrictStr
greeting: StrictStr
class UIParameters(ParamsPublic, HyperglassModel):
"""UI Configuration Parameters."""
cache: CachePublic
web: WebPublic
messages: Messages
version: StrictStr
devices: List[UIDevices] = []
parsed_data_fields: Tuple[StructuredDataField, ...]
content: UIContent