ovdashboard/api/ovdashboard_api/settings.py

48 lines
1.2 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/ovdashboard"
dav_protocol: str = "https"
dav_host: str = "example.com"
dav_username: str = "ovdashboard"
dav_password: str = "changeme"
dav_path: str = "ovdashboard"
ticker_separator: str = " +++ "
cache_seconds: int = 30
@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")