maintnote
maintnote is a Python 3.10+ library and command-line tool (CLI) for network maintenance notifications.
It implements IETF draft-gunter-calext-maintenance-notifications-00 (Maintenance Notification Improvements Using iCalendar).
Network operators usually send maintenance notifications as free-form emails that make automation unreliable.
This specification puts structured X-MAINTNOTE-* fields inside standard RFC 5545 iCalendar (.ics) events.
With maintnote, software developers, network engineers, and DevOps engineers can generate, validate, and automate maintenance windows.
maintnote uses only the Python standard library at runtime and includes full mypy --strict type annotations (py.typed).
Core Concepts
Two roles use maintnote:
- Provider: A carrier, internet exchange, or cloud operator that creates and updates maintenance notifications for customer accounts.
- Consumer: A customer network operations center (NOC), DevOps pipeline, or ticketing service that parses notifications, tracks state, and runs automation.
Each notification identifies one maintenance event with a unique UID and a SEQUENCE number that increases on each update.
It also lists one or more affected service objects, an impact level, and an optional lifecycle status.
Features
- RFC 5545 and
X-MAINTNOTE-*parsing and validation- Parse and validate all mandatory and optional properties:
X-MAINTNOTE-PROVIDER,X-MAINTNOTE-ACCOUNT,X-MAINTNOTE-MAINTENANCE-ID,X-MAINTNOTE-OBJECT-ID(with optionalALTREPURIs),X-MAINTNOTE-IMPACT, andX-MAINTNOTE-STATUS. - Keep unknown
x-nameoriana-tokenimpact values as sent, and mapeffective_impacttoImpact.OUTAGE(Section 2.5.5). - Omit the
METHODproperty by default so email clients do not automatically add notifications to personal calendars (Section 2.3.1). - Support per-recipient
METHODopt-in for providers andMETHODremoval for consumers. - Support
LANGUAGEproperty parameters and 75-octet line folding that is safe for UTF-8 (Section 5.1). - Accept common third-party quirks in lenient mode (
strict=False) and return structured warnings.
- Parse and validate all mandatory and optional properties:
- Provider and consumer workflow engine (Section 3)
- Run all five lifecycle stages: Initial (3.1), Updated (3.2), Cancelled (3.3), Open or
IN-PROCESS(3.4), and Closed orCOMPLETED(3.5). - Keep
UIDvalues stable across updates, increaseSEQUENCEnumbers, and ignore duplicate or stale notifications. - Isolate object IDs by
(provider, object_id)so identical circuit IDs from different carriers do not collide. - Connect custom storage (
StateStore), ticketing (TicketHandler), and out-of-band checks (OutOfBandVerifier). - Use the built-in
InMemoryStateStore,SQLiteStateStore, andInMemoryTicketHandlerclasses directly.
- Run all five lifecycle stages: Initial (3.1), Updated (3.2), Cancelled (3.3), Open or
- Email, OpenPGP,
ALTREP, and CalDAV transport (Section 5.2)- Build and parse RFC 5322 emails with
text/calendar(.ics) attachments. - Sign and verify RFC 3156
multipart/signedOpenPGP emails over raw MIME bytes. - Get external JSON metadata (for example, PeeringDB data) from
ALTREPURIs over HTTPS with redirect and private-IP protection. - Discover, query, get, publish, and delete events on a CalDAV server over TLS (RFC 4791).
- Build and parse RFC 5322 emails with
- Built-in CLI (
maintnote)- Validate, parse, generate, transition, remove
METHOD, and extract notifications from.icsand.emlfiles. - Support
--jsonoutput andstdin(-) for shell scripts and DevOps pipelines.
- Validate, parse, generate, transition, remove
Installation
Install maintnote from PyPI:
pip install maintnote
For local development, install the package with test, lint, and type-check tools (pytest, pytest-cov, ruff, and mypy):
pip install -e ".[dev]"
To build the documentation locally, install the documentation tools (mkdocs and mkdocs-material):
pip install -e ".[docs]"
Quick Start
1. Create and Update a Notification as a Provider
Use MaintenanceProvider to create an initial notification and move it through each lifecycle state:
from datetime import datetime, timezone
from maintnote import (
Impact,
MaintenanceProvider,
Organizer,
ServiceObject,
dumps,
)
provider = MaintenanceProvider(
provider="example.com",
organizer=Organizer("noc@example.com", cn="Example NOC"),
)
# Section 3.1: Initial notification (SEQUENCE=0, STATUS=TENTATIVE, no METHOD)
initial = provider.create_initial(
account="137.035999173",
maintenance_id="WorkOrder-31415",
objects=[
ServiceObject(
object_id="2718281828459",
altrep="https://example.org/maintenance?id=2718281828459",
),
ServiceObject(object_id="2001:db8::d06:f00d"),
],
dtstart=datetime(2026, 10, 10, 8, 0, tzinfo=timezone.utc),
dtend=datetime(2026, 10, 10, 10, 0, tzinfo=timezone.utc),
summary="Core optical linecard upgrade",
impact=Impact.OUTAGE,
)
# Section 3.2: Confirm and reschedule (same UID, SEQUENCE=1)
confirmed = provider.confirm(
initial,
dtstart=datetime(2026, 10, 12, 8, 0, tzinfo=timezone.utc),
dtend=datetime(2026, 10, 12, 10, 0, tzinfo=timezone.utc),
)
# Section 3.4: Open the maintenance window (SEQUENCE=2, STATUS=IN-PROCESS)
opened = provider.open_window(confirmed, description="Maintenance window is now open.")
# Section 3.5: Close the maintenance window (SEQUENCE=3, STATUS=COMPLETED)
closed = provider.close_window(opened, description="Work complete; services restored.")
# Section 3.3: Cancel an active maintenance window instead
cancelled = provider.cancel(confirmed, description="Maintenance no longer required.")
print(dumps(initial))
2. Process Notifications as a Consumer
Use MaintenanceConsumer with SQLiteStateStore to track (provider, uid) state, check SEQUENCE order, and call a ticket handler:
from maintnote import (
InMemoryTicketHandler,
MaintenanceConsumer,
SQLiteStateStore,
dumps,
)
store = SQLiteStateStore("maintenances.db")
handler = InMemoryTicketHandler(prefix="OPS")
consumer = MaintenanceConsumer(store=store, handler=handler)
result = consumer.process(dumps(initial))
print(result.action, result.ticket_id, result.priority, result.assign_to_remediation_queue)
# WorkflowAction.INITIAL OPS-0001 TicketPriority.CRITICAL False
store.close()
3. Send and Extract Email Attachments
Call build_notification_email() to attach an .ics notification to an email.
Call extract_notifications_from_email() to parse received emails:
from maintnote import build_notification_email, extract_notifications_from_email
msg = build_notification_email(
initial,
sender="noc@example.com",
recipient="ops@customer.example",
)
notifications = extract_notifications_from_email(msg, strip_method=True)
4. Use the Command-Line Interface
Run maintnote directly on .ics and .eml files, or pass - to read from stdin:
# Validate a maintenance notification and print JSON diagnostics
maintnote validate examples/samples/01_initial.ics --json
# Parse a notification and show its fields
maintnote parse examples/samples/01_initial.ics
# Generate an initial notification and transition it to open and closed
maintnote generate --action initial \
--provider example.com --account 137.035999173 \
--maintenance-id WorkOrder-31415 --object-id acme-widgets-as-a-service \
--impact OUTAGE --summary "Router upgrade" \
--organizer noc@example.com --organizer-cn "Example NOC" \
--dtstart 2026-10-10T08:00:00Z --dtend 2026-10-10T10:00:00Z \
-o initial.ics
maintnote generate --action open --from-file initial.ics -o open.ics
maintnote generate --action close --from-file open.ics -o close.ics
# Remove METHOD before you forward a notification to personal calendars (Section 2.3.1)
maintnote strip-method examples/samples/legacy_with_method.ics
# Extract notifications from an email file
maintnote extract-email examples/samples/legacy_provider.eml --strip-method --json
Examples
Python example scripts, sample .ics and .eml files, and a CLI walkthrough are in examples/:
| Example | Purpose |
|---|---|
examples/provider_lifecycle.py |
Run the provider lifecycle from initial notification through completion |
examples/consumer_pipeline.py |
Extract emails, track state in SQLite, and reject stale notifications |
examples/multi_customer_batch.py |
Send one maintenance notification to more than one account with per-account METHOD settings and cancel the batch |
examples/multi_provider_automation.py |
Isolate (provider, object_id) pairs, use a custom TicketHandler, test OUTAGE fallback, and run OutOfBandVerifier |
examples/signed_email_and_sanitization.py |
Sign and verify RFC 3156 OpenPGP emails, detect tampering, and remove METHOD from emails |
examples/caldav_and_altrep_demo.py |
Run an offline mock CalDAV server (PROPFIND, PUT with ETag, REPORT, GET, DELETE) and test ALTREP SSRF checks |
examples/localization_and_lenient_parsing.py |
Use LocalizationStrings, LANGUAGE parameters, VTIMEZONE, VALARM, and lenient diagnostics |
examples/cli_walkthrough.sh |
Run every maintnote CLI subcommand against the files in examples/samples/ |
Documentation
Read the full guides in docs/:
- Overview
- Getting Started
- Specification Compliance Matrix
- Provider and Consumer Workflows
- Security and Transport
- API Reference
Development and Testing
Run the local checks before you open a Pull Request:
# Run unit and integration tests
PYTHONPATH=src pytest -v
# Check lint rules and formatting
ruff check src tests
ruff format --check src tests
# Run strict static type checks
MYPYPATH=src mypy src tests
To run lint, type checks, and tests with one command, run:
make check
To build the documentation in strict mode, run:
make docs
Read CONTRIBUTING.md for the full Pull Request and coding rules.
License
This project uses the GNU General Public License v3.0 or later (GPL-3.0-or-later).
Read LICENSE for the full license text.
Metadata
Release files for maintnote 0.2.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 |
|---|---|---|---|---|
| maintnote-0.2.0.tar.gz | 79.0 kB | With provenance | Details for maintnote-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| maintnote-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for maintnote-0.2.0-py3-none-any.whl |
Total release size: 138.1 kB
Release files / maintnote-0.2.0.tar.gz
| Download URL | maintnote-0.2.0.tar.gz |
|---|---|
| Size | 79.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6a48875d74ccc4181ff4cf3f4fc1054e68bbdea9512d548a45a3c9b49061f2a
|
|
BLAKE2b-256 checksum How to use checksums |
02eb9d6076b5e72d35e95fed585310823f02a0d356073134f973d9ac9c66aadd
|
| 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 26, 2026.
Transparency logRelease files / maintnote-0.2.0-py3-none-any.whl
| Download URL | maintnote-0.2.0-py3-none-any.whl |
|---|---|
| Size | 59.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
812f96aea222d8969b499f98e646610fa45d30fbabe86fd9a885fe23fa858059
|
|
BLAKE2b-256 checksum How to use checksums |
a8f353471e16ec4cd1a590f7a5b988edec4cb1ee820c401bade226804d0c8430
|
| 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 26, 2026.
Transparency logSecurity for maintnote 0.2.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 maintnote-0.2.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 26, 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.