s365b.core.settings_store¶
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 SecretBox into
secret_enc and are never returned by the API.
Classes¶
Base class for a group of runtime settings. |
Functions¶
|
Load a settings group, falling back to defaults. |
|
Store a settings group (non-secret fields only). |
|
Load the secret part of a settings group. |
|
Store the secret part of a settings group, replacing what was there. |
Module Contents¶
- class s365b.core.settings_store.SettingsGroup[source]¶
Bases:
pydantic.BaseModelBase class for a group of runtime settings.
Subclasses set
keyand give every field a default, so a missing row simply means “defaults”.
- async s365b.core.settings_store.load[T: SettingsGroup](session: sqlalchemy.ext.asyncio.AsyncSession, model: type[T]) T[source]¶
Load a settings group, falling back to defaults.
- Parameters:
session – Open session.
model – The settings model.
- Returns:
The settings.
- async s365b.core.settings_store.save(session: sqlalchemy.ext.asyncio.AsyncSession, settings: SettingsGroup) None[source]¶
Store a settings group (non-secret fields only).
- Parameters:
session – Open session; the caller commits.
settings – The settings to store.
- async s365b.core.settings_store.load_secrets(session: sqlalchemy.ext.asyncio.AsyncSession, key: str, box: s365b.core.secrets.SecretBox) dict[str, str][source]¶
Load the secret part of a settings group.
- Parameters:
session – Open session.
key – Settings key.
box – Secret box holding the master key.
- Returns:
Secret values by name; empty if none stored.
- async s365b.core.settings_store.save_secrets(session: sqlalchemy.ext.asyncio.AsyncSession, key: str, secrets: dict[str, str], box: s365b.core.secrets.SecretBox) None[source]¶
Store the secret part of a settings group, replacing what was there.
- Parameters:
session – Open session; the caller commits.
key – Settings key.
secrets – Secret values by name.
box – Secret box holding the master key.