s365b.modules.entra.module¶
The Entra ID backup module.
Attributes¶
Classes¶
Backs up Entra ID (Azure AD) directory objects and policies. |
Functions¶
|
Serialise an object so unchanged objects produce identical bytes. |
|
Whether an error means "this tenant does not have the feature". |
|
Choose a readable name for an item. |
Module Contents¶
- s365b.modules.entra.module.normalise(item: s365b.modules.entra.sources.Item) bytes[source]¶
Serialise an object so unchanged objects produce identical bytes.
Drops OData annotations other than
@odata.type(they carry request context, not data), sorts keys, and sorts lists (see_canonical()).- Parameters:
item – A Graph object.
- Returns:
UTF-8 JSON.
Whether an error means “this tenant does not have the feature”.
Conditional Access and PIM need Entra ID P1/P2; tenants without them get an error, which is not a backup failure.
- Parameters:
exc – The Graph error.
- Returns:
True for licence / feature-not-available errors.
- s365b.modules.entra.module.display_name(item: s365b.modules.entra.sources.Item, role_names: dict[str, str]) str[source]¶
Choose a readable name for an item.
- Parameters:
item – A Graph object.
role_names – Role definition names by ID (for role assignments).
- Returns:
A name for the browse view.
- class s365b.modules.entra.module.EntraModule[source]¶
Bases:
s365b.modules.sdk.BackupModuleBacks up Entra ID (Azure AD) directory objects and policies.
- description: ClassVar[str] = 'Users, groups, apps, roles, Conditional Access and tenant policies.'[source]¶
- required_permissions(config: pydantic.BaseModel, *, restore: bool) set[str][source]¶
Return the Graph application permissions needed.
- Parameters:
config – Module settings (none).
restore – Restore is not implemented yet, so it needs nothing.
- Returns:
Read permissions for backup; nothing for restore.
- event_types() list[s365b.modules.sdk.EventType][source]¶
Alerts for security-relevant directory changes.
- Returns:
The event types.
- change_event(item_type: str, change: str, version: s365b.modules.sdk.ItemVersion) str | None[source]¶
Map a change to an alert (see
CHANGE_EVENTS).- Parameters:
item_type – The item’s type.
change –
new,changedordeleted.version – The new version.
- Returns:
The event ID, or
Nonefor changes that do not alert.
- item_types() list[s365b.modules.sdk.ItemTypeInfo][source]¶
Describe the item types.
- Returns:
One entry per Graph object type.
- async discover(ctx: s365b.modules.sdk.ModuleContext) collections.abc.AsyncIterator[s365b.modules.sdk.ProtectedObject][source]¶
Yield one protected object per category.
- Parameters:
ctx – Module context.
- Yields:
The categories.
- state_for_new_repository(state: s365b.modules.sdk.SyncState) s365b.modules.sdk.SyncState[source]¶
Keep the state: every run reads everything, and it finds deletions.
- Parameters:
state – The state saved by the backup into the other repository.
- Returns:
The same state.
- async backup(ctx: s365b.modules.sdk.ModuleContext, obj: s365b.modules.sdk.ProtectedObject, state: s365b.modules.sdk.SyncState) collections.abc.AsyncIterator[s365b.modules.sdk.ItemVersion | s365b.modules.sdk.Checkpoint][source]¶
Snapshot one category.
Every object is yielded each run (the catalog keeps only changed ones); objects seen last time but not now are yielded as deleted. A checkpoint follows each source.
- Parameters:
ctx – Module context.
obj – The category.
state –
{"seen": {source key: [item keys]}}from the last run.
- Yields:
Item versions and checkpoints.
- Raises:
ModuleError – For an unknown category or missing permissions.