agenda/agenda/gandi.py

28 lines
670 B
Python

"""Gandi domain renewal dates."""
import os
from .event import Event
from datetime import datetime
import json
def get_events(data_dir: str) -> list[Event]:
"""Get subscription renewal dates."""
filename = os.path.join(data_dir, "gandi_domains.json")
with open(filename) as f:
items = json.load(f)
assert isinstance(items, list)
assert all(item["fqdn"] and item["dates"]["registry_ends_at"] for item in items)
return [
Event(
date=datetime.fromisoformat(item["dates"]["registry_ends_at"]).date(),
name="domain",
title=item["fqdn"] + " renewal",
)
for item in items
]