ovdashboard/api/ovkiosk/config.py

44 lines
1 KiB
Python

"""
Configuration definition.
Converts per-run (environment) variables and config files into the
"python world" using `pydantic`.
Pydantic models might have convenience methods attached.
"""
from typing import Optional
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"
docs_url: Optional[str] = "/docs"
redoc_url: Optional[str] = "/redoc"
caldav_base_url: str = "/remote.php/dav"
webdav_base_url: str = "/remote.php/webdav"
dav_protocol: str = "https"
dav_host: str = "example.com"
dav_username: str = "ovkiosk"
dav_password: str = "changeme"
@property
def caldav_url(self) -> str:
return f"{self.dav_protocol}://" + \
f"{self.dav_host}{self.caldav_base_url}"
@property
def webdav_url(self) -> str:
return f"{self.dav_protocol}://" + \
f"{self.dav_host}{self.webdav_base_url}"
SETTINGS = Settings(_env_file=".env")