s365b.modules.exchange.items¶
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¶
Classes¶
Calendars or contacts: where Graph keeps them and how they are stored. |
Functions¶
|
Graph JSON without request context, with sorted keys. |
|
A Graph date and time with zone, for the browse view. |
|
Fields shown and searched in the browse view. |
|
Fields shown and searched in the browse view. |
|
An item's |
|
The item version for an event or contact. |
|
The mailbox's own calendars: ID → name. |
|
The mailbox's contact folders: ID → path, and the default folder's ID. |
|
Folders removed or renamed since the last run; |
|
Back up calendars or contact folders. |
Module Contents¶
- class s365b.modules.exchange.items.Kind[source]¶
Calendars or contacts: where Graph keeps them and how they are stored.
- Variables:
item_type – Item type of the items.
state_key – Key of the folder list in the mailbox’s sync state.
label – Progress text.
- s365b.modules.exchange.items.normalise(item: dict[str, Any]) bytes[source]¶
Graph JSON without request context, with sorted keys.
- Parameters:
item – An event or contact from Graph.
- Returns:
UTF-8 JSON.
- s365b.modules.exchange.items.when(value: dict[str, Any] | None, *, date_only: bool = False) str | None[source]¶
A Graph date and time with zone, for the browse view.
- Parameters:
value – A Graph
dateTimeTimeZone.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).
- s365b.modules.exchange.items.event_metadata(event: dict[str, Any], folder_id: str) dict[str, Any][source]¶
Fields shown and searched in the browse view.
- Parameters:
event – Event from Graph.
folder_id – Its calendar.
- Returns:
Metadata for the item version.
- s365b.modules.exchange.items.contact_metadata(contact: dict[str, Any], folder_id: str) dict[str, Any][source]¶
Fields shown and searched in the browse view.
- Parameters:
contact – Contact from Graph.
folder_id – Its contact folder.
- Returns:
Metadata for the item version.
- s365b.modules.exchange.items.modified(item: dict[str, Any]) datetime.datetime | None[source]¶
An item’s
lastModifiedDateTime, if it has a readable one.
- s365b.modules.exchange.items.version(kind: Kind, item: dict[str, Any], fid: str, path: str) s365b.modules.sdk.ItemVersion[source]¶
The item version for an event or contact.
- Parameters:
kind – Calendars or contacts.
item – The full item from Graph.
fid – Its folder.
path – The folder’s path.
- Returns:
The version to store.
- async s365b.modules.exchange.items.calendars(ctx: s365b.modules.sdk.ModuleContext, user: str, mail: str | None) dict[str, str][source]¶
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.
- Parameters:
ctx – Module context.
user – The mailbox’s user ID.
mail – The mailbox’s address, to recognise its own calendars.
- Returns:
Calendar names by ID.
- async s365b.modules.exchange.items.contact_folders(ctx: s365b.modules.sdk.ModuleContext, user: str) tuple[dict[str, str], str | None][source]¶
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.- Parameters:
ctx – Module context.
user – The mailbox’s user ID.
- Returns:
Paths by folder ID, and the default folder’s ID if known.
- s365b.modules.exchange.items.folder_changes(folders: dict[str, str], saved: dict[str, Any]) list[s365b.modules.sdk.GroupChange][source]¶
Folders removed or renamed since the last run;
savedis updated.- Parameters:
folders – The folders now, ID → path.
saved – The folders at the last run, ID → path; updated in place.
- Returns:
A removal or rename for each.
- async s365b.modules.exchange.items.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][source]¶
Back up calendars or contact folders.
Nonemeans “checkpoint now”.- Parameters:
ctx – Module context (with
current_items).user – The mailbox’s user ID.
kind – Calendars or contacts.
folders – The folders now, ID → path.
saved – The folders at the last run, ID → path; updated in place.
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.