scalio-m365
Shared code that reads («Scalio Lesen») and writes («Scalio Schreiben») Microsoft 365 settings of a live tenant: one
reader and one writer per
Microsoft365DSC resource type (Entra ID, SharePoint, Intune, Exchange Online / Defender for Office 365, Teams), with the
property names of the governance catalog (scalio-catalog). Foundry rolls baselines out with it, Citadel heals
deviations. Decision: scalio-docs concepts/m365-schreibpaket.md (m365pkg/P1–P4), ADR 0089.
Nothing in this package is secret and it holds no content: the baselines stay in the private repo
scalio_blueprint, tokens and certificates stay in the app (scalio-tenant).
Use in an app
import scalio_m365 as m365
g = m365.Graph(call, exo, create=True) # Foundry; Citadel: create=False (keeps existing objects only)
reason = m365.why_not(type_, desired) # Citadel: why_not(type_, desired, change_only=True)
actual = await m365.read_one(g, type_, match) # catalog names
after = m365.fields(type_, {**(actual or {}), **desired})
if not m365.same(actual, after):
await m365.kind(type_).write(g, actual, after)
call(method, path, body) -> dict: one Microsoft Graph call (pathrelative to/v1.0, or a full@odata.nextLink); raise on an error.exo(cmdlet, parameters) -> list[dict]: one cmdlet through the Exchange admin API (InvokeCommand, app-only token).teams(method, path, body): one call of the Teams admin API (pathbelowteams.API, app-only token forteams.RESOURCE, Entra role Teams Administrator); passed asGraph(call, exo, teams=teams). The app brings token, HTTP client and logging.WriteError: the step cannot be written as asked (missing group, empty break-glass group, object missing, no reviewer, no notification address); the text says what to do.SCOPES(Graph permissions),exchange.SCOPES,teams.SCOPES,DIRECTORY_ROLES(Exchange and Teams Administrator),READ_ALONGandneeds(type_): what the «Scalio Schreiben» registration needs.- Exchange in a fresh tenant:
exchange.prepare(g, is_dehydrated=..., customised_at=...)runsEnable-OrganizationCustomizationonce and says when to wait; the app stores the time. - Conditional access:
AADNamedLocationPolicy(named locations: countries as ISO codes or IP ranges,IsTrusted; the type of an existing location cannot change) and the device filter of a policy (DeviceFilterModeinclude/exclude,DeviceFilterRule). Write a location before the policy that names it. No new scope (Policy.ReadWrite.ConditionalAccess). - Purview DLP (
compliance, 0.10.0):SCDLPCompliancePolicyandSCDLPComplianceRulethrough Security & Compliance PowerShell, the sameInvokeCommandAPI as Exchange on its own host (exo.SCC_API, token forexo.SCC_RESOURCE), passed asGraph(call, exo, scc=scc). Needs Exchange.ManageAsApp and the Entra role Compliance Administrator (compliance.SCOPES); opt-in: the role is not inDIRECTORY_ROLES, an app that writes DLP addscompliance.ROLEto its profile. Locations are added and removed (Add…/Remove…Location), sensitive information types compared without case or order. Not yet tested against a live tenant. scalio_m365.mapping: pure name mappings (Graph answer -> catalog names) for the apps' readers.
Exchange admin API
from scalio_m365 import AsyncExo
exo = AsyncExo(token, tenant_id, app="ScalioRosetta") # token(): app-only token for EXO_RESOURCE (may be async)
rows = await exo("Get-OrganizationConfig") # every page
await exo.invoke("Set-Mailbox", {"Identity": "a@b.ch", "EmailAddresses": DeltaUpdate(add=["smtp:x@b.ch"])})
g = m365.Graph(call, exo, create=False) # fits the writers
- One client for the API behind ExchangeOnlineManagement (
InvokeCommand, not documented by Microsoft), ADR 0105.SyncExois the same for synchronous code (the readers). - Retries: 429 always (after
Retry-After), 5xx and network errors only forGet-(aNew-never runs twice), 401 once with a new token. Paging ends afterMAX_PAGES. ExoErrorwithstatus,kind(not_found, denied, auth, throttled, server, cmdlet),exception_type,request_id; the reason comes fromdetails. Never the token or the parameters.observe(step)gets every change and every error (for the app's log);anchored(mailbox)routes to a mailbox.- Not here:
Get-EXO*(own endpoints; useGet-Mailbox,Get-CASMailbox), Teams. Security & Compliance (IPPS):AsyncExo(token, tenant, api=SCC_API)with a token forSCC_RESOURCE.
Read
from scalio_m365 import readers
resources, fields, problems = readers.read(graph_token, types, client=httpx.Client(timeout=60),
tokens=admin_token, tenant=tenant_id, app="ScalioCitadel")
resources:{"type", "properties"}with the catalog names (ids of groups, users, roles and locations become display names, as in DSC).fields[type]: the properties read; a type left out counts as «not read», never as a deviation.problems[type]: why Microsoft refused a type (missing permission ...); a 401 of Graph stops the read.- Graph v1.0/beta for Entra, SharePoint and Intune; Exchange through
SyncExoand Teams through the Teams admin API with app-only tokens fromtokens(resource)(readers.EXO_RESOURCE,readers.TEAMS_RESOURCE). READERS(type -> reader),FIELDS,DYNAMIC(types whose answer decides the fields),ADMIN_APIS.scalio_m365.testing.FakeMicrosoft: fake Graph, Exchange and Teams admin API for the apps' tests.
Delivery of Intune policies (0.11.0, ADR 0138)
scalio_m365.delivery.read_delivery(session, resource_type, policy_id) tells how many devices applied an Intune
policy: {"total", "succeeded", "error", "conflict", "pending", "notApplicable", "source"}. Compliance policies use
deviceStatusOverview (v1.0), BitLocker and LAPS the report getConfigurationPolicyDeviceSummaryReport (beta, the
first row stays in raw for the check in the lab). Read only, no new permission (DeviceManagementConfiguration.Read.All).
Export (Rosetta's Graph collection)
from scalio_m365 import export
ex = export.GraphExport(client, out_dir, include_user_details=False, audit_days=30) # client: httpx.Client, app-only Graph token
result = ex.run(on_step=lambda i, name: ...) # export.GraphExport.STEPS: Entra ID, Intune, Windows 365, Defender
result.org, result.domains, result.areas; ex.errors; ex.users_by_id
- Read only (GET), no scope beyond what Rosetta asks today. Writes the
g_*,i_*,w_*andd_*JSON files ofExport-M365Inventory.ps1(secrets removed, licence hints instead of errors for areas the tenant has no licence for); metadata,errors.json, Exchange, Purview, Teams and the zip stay in the app. ADR 0089,m365pkg/P5. - Tests:
FakeMicrosoft.sync_client()serves the same table asclient()to a synchronous httpx client.
Modes
Foundry (create=True) |
Citadel (create=False, change_only=True) |
|
|---|---|---|
| Entra, SharePoint | creates or changes | creates or changes |
| Intune policy missing | creates (compliance with a block action) | refuses: create it with its assignments first |
| BitLocker, LAPS (settings catalog) | creates a missing policy without assignments; adds missing settings from the template | changes and adds settings; never creates a policy |
| Exchange policy missing | Defender policies with a rule per accepted domain, DKIM | refuses |
| Names of Intune/Exchange objects | set on create | never changed (why_not says so) |
Development
pip install -e ".[dev]"
pytest && ruff check .
Release: bump pyproject.toml and __version__, reserve the version in scalio-docs REGISTER.md, run
tools/changelog.py --repo scalio-m365 release <version> there, then «Freigeben» in the cockpit (workflow
publish.yml, PyPI trusted publishing, environment pypi). Tags without v.
Metadata
Release files for scalio-m365 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scalio_m365-0.11.0.tar.gz | 87.6 kB | With provenance | Details for scalio_m365-0.11.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scalio_m365-0.11.0-py3-none-any.whl | Python 3 | none | any | Details for scalio_m365-0.11.0-py3-none-any.whl |
Total release size: 151.5 kB
Release files / scalio_m365-0.11.0.tar.gz
| Download URL | scalio_m365-0.11.0.tar.gz |
|---|---|
| Size | 87.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
38be37e60b81da680ac16415cae20cf43b1945b1ad10722708757248e3c028cb
|
|
BLAKE2b-256 checksum How to use checksums |
14b6e94dc3b0d51c59aa1ed8c8252c74329d23ce76b6c492fac0f8c4d560b41e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / scalio_m365-0.11.0-py3-none-any.whl
| Download URL | scalio_m365-0.11.0-py3-none-any.whl |
|---|---|
| Size | 63.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
467e73d64d048126bfb08a1d7ba5f2289d2c6a2c585032541fa8e2a772b51e03
|
|
BLAKE2b-256 checksum How to use checksums |
3b565ef50ca3798c836b99a9a331ce97f8587352a7942716e1c16a84c3766362
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for scalio-m365 0.11.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for scalio_m365-0.11.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.