s365b.modules.entra.module ========================== .. py:module:: s365b.modules.entra.module .. autoapi-nested-parse:: The Entra ID backup module. Attributes ---------- .. autoapisummary:: s365b.modules.entra.module.READ_PERMISSIONS s365b.modules.entra.module.LINK_CONCURRENCY s365b.modules.entra.module.CHANGE_EVENTS Classes ------- .. autoapisummary:: s365b.modules.entra.module.EntraModule Functions --------- .. autoapisummary:: s365b.modules.entra.module.normalise s365b.modules.entra.module.unavailable s365b.modules.entra.module.display_name Module Contents --------------- .. py:data:: READ_PERMISSIONS .. py:data:: LINK_CONCURRENCY :value: 8 .. py:data:: CHANGE_EVENTS :type: dict[str, str] .. py:function:: normalise(item: s365b.modules.entra.sources.Item) -> bytes 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 :func:`_canonical`). :param item: A Graph object. :returns: UTF-8 JSON. .. py:function:: unavailable(exc: s365b.graph.client.GraphError) -> bool 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. :param exc: The Graph error. :returns: True for licence / feature-not-available errors. .. py:function:: display_name(item: s365b.modules.entra.sources.Item, role_names: dict[str, str]) -> str Choose a readable name for an item. :param item: A Graph object. :param role_names: Role definition names by ID (for role assignments). :returns: A name for the browse view. .. py:class:: EntraModule Bases: :py:obj:`s365b.modules.sdk.BackupModule` Backs up Entra ID (Azure AD) directory objects and policies. .. py:attribute:: id :type: ClassVar[str] :value: 'entra' .. py:attribute:: display_name :type: ClassVar[str] :value: 'Entra ID' .. py:attribute:: description :type: ClassVar[str] :value: 'Users, groups, apps, roles, Conditional Access and tenant policies.' .. py:attribute:: version :type: ClassVar[str] :value: '0.2.0' .. py:attribute:: config_model :type: ClassVar[type[pydantic.BaseModel]] .. py:attribute:: object_noun :type: ClassVar[tuple[str, str]] :value: ('category', 'categories') .. py:method:: required_permissions(config: pydantic.BaseModel, *, restore: bool) -> set[str] Return the Graph application permissions needed. :param config: Module settings (none). :param restore: Restore is not implemented yet, so it needs nothing. :returns: Read permissions for backup; nothing for restore. .. py:method:: event_types() -> list[s365b.modules.sdk.EventType] Alerts for security-relevant directory changes. :returns: The event types. .. py:method:: change_event(item_type: str, change: str, version: s365b.modules.sdk.ItemVersion) -> str | None Map a change to an alert (see ``CHANGE_EVENTS``). :param item_type: The item's type. :param change: ``new``, ``changed`` or ``deleted``. :param version: The new version. :returns: The event ID, or ``None`` for changes that do not alert. .. py:method:: item_types() -> list[s365b.modules.sdk.ItemTypeInfo] Describe the item types. :returns: One entry per Graph object type. .. py:method:: discover(ctx: s365b.modules.sdk.ModuleContext) -> collections.abc.AsyncIterator[s365b.modules.sdk.ProtectedObject] :async: Yield one protected object per category. :param ctx: Module context. :Yields: The categories. .. py:method:: state_for_new_repository(state: s365b.modules.sdk.SyncState) -> s365b.modules.sdk.SyncState Keep the state: every run reads everything, and it finds deletions. :param state: The state saved by the backup into the other repository. :returns: The same state. .. py:method:: 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] :async: 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. :param ctx: Module context. :param obj: The category. :param state: ``{"seen": {source key: [item keys]}}`` from the last run. :Yields: Item versions and checkpoints. :raises ModuleError: For an unknown category or missing permissions.