s365b.core.settings_store ========================= .. py:module:: s365b.core.settings_store .. autoapi-nested-parse:: Typed access to runtime settings stored in the ``setting`` table. Each settings group is a Pydantic model with a fixed key. Non-secret fields are stored as JSON in ``value``; secrets go through :class:`SecretBox` into ``secret_enc`` and are never returned by the API. Classes ------- .. autoapisummary:: s365b.core.settings_store.SettingsGroup Functions --------- .. autoapisummary:: s365b.core.settings_store.load s365b.core.settings_store.save s365b.core.settings_store.load_secrets s365b.core.settings_store.save_secrets Module Contents --------------- .. py:class:: SettingsGroup Bases: :py:obj:`pydantic.BaseModel` Base class for a group of runtime settings. Subclasses set :attr:`key` and give every field a default, so a missing row simply means "defaults". .. py:attribute:: key :type: ClassVar[str] .. py:function:: load[T: SettingsGroup](session: sqlalchemy.ext.asyncio.AsyncSession, model: type[T]) -> T :async: Load a settings group, falling back to defaults. :param session: Open session. :param model: The settings model. :returns: The settings. .. py:function:: save(session: sqlalchemy.ext.asyncio.AsyncSession, settings: SettingsGroup) -> None :async: Store a settings group (non-secret fields only). :param session: Open session; the caller commits. :param settings: The settings to store. .. py:function:: load_secrets(session: sqlalchemy.ext.asyncio.AsyncSession, key: str, box: s365b.core.secrets.SecretBox) -> dict[str, str] :async: Load the secret part of a settings group. :param session: Open session. :param key: Settings key. :param box: Secret box holding the master key. :returns: Secret values by name; empty if none stored. .. py:function:: save_secrets(session: sqlalchemy.ext.asyncio.AsyncSession, key: str, secrets: dict[str, str], box: s365b.core.secrets.SecretBox) -> None :async: Store the secret part of a settings group, replacing what was there. :param session: Open session; the caller commits. :param key: Settings key. :param secrets: Secret values by name. :param box: Secret box holding the master key.