s365b.modules.exchange.items ============================ .. py:module:: s365b.modules.exchange.items .. autoapi-nested-parse:: Calendars and contacts of a mailbox. Graph (v1.0) has no change feed for every calendar (only the primary calendar's date-windowed view), so both are backed up the same way: each folder is listed with only IDs and change keys, compared with what the catalog has, and only new or changed items are fetched in full. A folder's first backup lists full items instead, 50 at a time. Items are stored as Graph's JSON. Graph is asked for immutable IDs, so an item keeps its ID when it moves between folders. An item missing from its folder's listing is a deletion only if it is in none of the folders backed up (a deleted item usually moves to Deleted Items, a mail folder). Restore copies (Exchange's export, as for mail) are added by the core after each mailbox's backup, like for messages. Attributes ---------- .. autoapisummary:: s365b.modules.exchange.items.IMMUTABLE s365b.modules.exchange.items.LIST_PAGE s365b.modules.exchange.items.FETCH_PARALLEL s365b.modules.exchange.items.DEFAULT_CONTACTS s365b.modules.exchange.items.CALENDARS s365b.modules.exchange.items.CONTACTS Classes ------- .. autoapisummary:: s365b.modules.exchange.items.Kind Functions --------- .. autoapisummary:: s365b.modules.exchange.items.normalise s365b.modules.exchange.items.when s365b.modules.exchange.items.event_metadata s365b.modules.exchange.items.contact_metadata s365b.modules.exchange.items.modified s365b.modules.exchange.items.version s365b.modules.exchange.items.calendars s365b.modules.exchange.items.contact_folders s365b.modules.exchange.items.folder_changes s365b.modules.exchange.items.backup_folders Module Contents --------------- .. py:data:: IMMUTABLE .. py:data:: LIST_PAGE :value: '100' .. py:data:: FETCH_PARALLEL :value: 4 .. py:data:: DEFAULT_CONTACTS :value: 'Contacts' .. py:class:: Kind Calendars or contacts: where Graph keeps them and how they are stored. :ivar item_type: Item type of the items. :ivar state_key: Key of the folder list in the mailbox's sync state. :ivar label: Progress text. .. py:attribute:: item_type :type: str .. py:attribute:: state_key :type: str .. py:attribute:: label :type: str .. py:method:: items_url(user: str, fid: str, default: bool) -> str The collection holding a folder's items. .. py:method:: item_url(user: str, key: str) -> str One item, wherever it is. .. py:method:: in_folder_url(user: str, fid: str, key: str) -> str One item, only if it is in this folder (404 otherwise). .. py:data:: CALENDARS .. py:data:: CONTACTS .. py:function:: normalise(item: dict[str, Any]) -> bytes Graph JSON without request context, with sorted keys. :param item: An event or contact from Graph. :returns: UTF-8 JSON. .. py:function:: when(value: dict[str, Any] | None, *, date_only: bool = False) -> str | None A Graph date and time with zone, for the browse view. :param value: A Graph ``dateTimeTimeZone``. :param date_only: Return just the date (``YYYY-MM-DD``): for all-day events and To Do due dates, which are days, not instants. :returns: The date, or the instant in UTC as ISO 8601 (``...Z``). .. py:function:: event_metadata(event: dict[str, Any], folder_id: str) -> dict[str, Any] Fields shown and searched in the browse view. :param event: Event from Graph. :param folder_id: Its calendar. :returns: Metadata for the item version. .. py:function:: contact_metadata(contact: dict[str, Any], folder_id: str) -> dict[str, Any] Fields shown and searched in the browse view. :param contact: Contact from Graph. :param folder_id: Its contact folder. :returns: Metadata for the item version. .. py:function:: modified(item: dict[str, Any]) -> datetime.datetime | None An item's ``lastModifiedDateTime``, if it has a readable one. .. py:function:: version(kind: Kind, item: dict[str, Any], fid: str, path: str) -> s365b.modules.sdk.ItemVersion The item version for an event or contact. :param kind: Calendars or contacts. :param item: The full item from Graph. :param fid: Its folder. :param path: The folder's path. :returns: The version to store. .. py:function:: calendars(ctx: s365b.modules.sdk.ModuleContext, user: str, mail: str | None) -> dict[str, str] :async: The mailbox's own calendars: ID → name. Calendars shared by other people, which appear in the list, are theirs to back up and are left out. :param ctx: Module context. :param user: The mailbox's user ID. :param mail: The mailbox's address, to recognise its own calendars. :returns: Calendar names by ID. .. py:function:: contact_folders(ctx: s365b.modules.sdk.ModuleContext, user: str) -> tuple[dict[str, str], str | None] :async: The mailbox's contact folders: ID → path, and the default folder's ID. The default folder ("Contacts") holds the other folders; its own contacts are read from ``/users/{id}/contacts``. :param ctx: Module context. :param user: The mailbox's user ID. :returns: Paths by folder ID, and the default folder's ID if known. .. py:function:: folder_changes(folders: dict[str, str], saved: dict[str, Any]) -> list[s365b.modules.sdk.GroupChange] Folders removed or renamed since the last run; ``saved`` is updated. :param folders: The folders now, ID → path. :param saved: The folders at the last run, ID → path; updated in place. :returns: A removal or rename for each. .. py:function:: backup_folders(ctx: s365b.modules.sdk.ModuleContext, user: str, kind: Kind, folders: dict[str, str], saved: dict[str, Any], default: str | None = None) -> collections.abc.AsyncIterator[s365b.modules.sdk.ItemVersion | s365b.modules.sdk.GroupChange | None] :async: Back up calendars or contact folders. ``None`` means "checkpoint now". :param ctx: Module context (with ``current_items``). :param user: The mailbox's user ID. :param kind: Calendars or contacts. :param folders: The folders now, ID → path. :param saved: The folders at the last run, ID → path; updated in place. :param default: The default contact folder's ID (its contacts are read from ``/users/{id}/contacts``). :Yields: New and changed items, deletions, folder renames and removals.