s365b.modules.registry¶
Finding, loading and validating modules.
Modules register under the s365b.modules entry point group, e.g. in a
module package’s pyproject.toml:
[project.entry-points."s365b.modules"]
exchange = "s365b.modules.exchange:ExchangeModule"
Two layers decide whether a module runs:
Allowed (this file): the
S365B_MODULESallow-list. A module not on the list is never imported.Enabled (database, toggled in the UI): checked by the core before it schedules work. A module that is allowed but disabled is still loaded so its existing backups can be browsed and restored.
Attributes¶
Exceptions¶
Raised when a module is invalid or cannot be found. |
Classes¶
Summary of a module for the API and UI. |
|
The set of modules this process may use. |
Functions¶
|
Check that a class meets the module contract's static rules. |
Module Contents¶
- exception s365b.modules.registry.RegistryError[source]¶
Bases:
ExceptionRaised when a module is invalid or cannot be found.
- class s365b.modules.registry.ModuleInfo[source]¶
Summary of a module for the API and UI.
- Variables:
id – Module ID.
display_name – Name shown in the UI.
description – One-line description.
version – Module version.
- s365b.modules.registry.validate_module_class(cls: type[s365b.modules.sdk.BackupModule], expected_id: str | None = None) None[source]¶
Check that a class meets the module contract’s static rules.
- Parameters:
cls – The module class.
expected_id – Entry point name it was registered under, if any.
- Raises:
RegistryError – Describing the first problem found.
- class s365b.modules.registry.ModuleRegistry(modules: dict[str, type[s365b.modules.sdk.BackupModule]])[source]¶
The set of modules this process may use.
- Parameters:
modules – Module classes, keyed by ID.
- classmethod from_entry_points(allowed: collections.abc.Iterable[str] = ()) ModuleRegistry[source]¶
Load modules from installed entry points.
Invalid modules are logged and skipped, so one broken third-party module cannot stop the whole application.
- Parameters:
allowed – Allow-list of module IDs; empty allows all installed.
- Returns:
The registry.
- classmethod from_classes(classes: collections.abc.Iterable[type[s365b.modules.sdk.BackupModule]]) ModuleRegistry[source]¶
Build a registry from classes directly (tests, embedding).
- Parameters:
classes – Module classes.
- Returns:
The registry.
- Raises:
RegistryError – If a class is invalid or IDs collide.
- get(module_id: str) s365b.modules.sdk.BackupModule[source]¶
Return the (shared) instance of a module.
- Parameters:
module_id – Module ID.
- Returns:
The module instance.
- Raises:
RegistryError – If the module is not loaded.
- info(module_id: str) ModuleInfo[source]¶
Return a module’s summary.
- Parameters:
module_id – Module ID.
- Returns:
The summary.
- parse_config(module_id: str, raw: dict[str, object] | None) pydantic.BaseModel[source]¶
Validate stored settings against a module’s config model.
- Parameters:
module_id – Module ID.
raw – Stored settings;
Nonemeans defaults.
- Returns:
The config model instance.
- required_permissions(enabled: dict[str, pydantic.BaseModel], *, restore: bool) dict[str, set[str]][source]¶
Return the Graph permissions needed by the enabled modules.
- Parameters:
enabled – Enabled module IDs mapped to their config.
restore – Restore-app permissions instead of backup-app ones.
- Returns:
Permission name mapped to the IDs of the modules that need it, so the UI can explain why each permission is requested.