ovdashboard/api/ovkiosk/config.py

48 lines
1.1 KiB
Python
Raw Normal View History

2022-08-28 23:59:57 +00:00
"""
Configuration definition.
Converts per-run (environment) variables and config files into the
"python world" using `pydantic`.
Pydantic models might have convenience methods attached.
"""
2022-08-29 00:36:13 +00:00
from typing import Optional
2022-08-28 23:59:57 +00:00
from pydantic import BaseSettings
class Settings(BaseSettings):
"""
Per-run settings
"""
production_mode: bool = False
api_v1_prefix: str = "api/v1"
openapi_url: str = "/openapi.json"
2022-08-29 00:36:13 +00:00
docs_url: Optional[str] = "/docs"
redoc_url: Optional[str] = "/redoc"
caldav_base_url: str = "/remote.php/dav"
2022-08-29 11:27:18 +00:00
webdav_base_url: str = "/remote.php/webdav/ovkiosk"
2022-08-29 00:36:13 +00:00
dav_protocol: str = "https"
dav_host: str = "example.com"
dav_username: str = "ovkiosk"
dav_password: str = "changeme"
2022-08-29 11:27:18 +00:00
dav_path: str = "ovkiosk"
2022-08-29 00:36:13 +00:00
2022-08-29 19:20:03 +00:00
ticker_separator: str = " +++ "
2022-08-29 00:36:13 +00:00
@property
def caldav_url(self) -> str:
return f"{self.dav_protocol}://" + \
f"{self.dav_host}{self.caldav_base_url}"
2022-08-28 23:59:57 +00:00
@property
2022-08-29 00:36:13 +00:00
def webdav_url(self) -> str:
return f"{self.dav_protocol}://" + \
f"{self.dav_host}{self.webdav_base_url}"
2022-08-28 23:59:57 +00:00
2022-08-29 00:36:13 +00:00
SETTINGS = Settings(_env_file=".env")