Adding OData Import

This commit is contained in:
Ian Roddis committed 2026-06-25 15:52:21 -03:00
1 parent c8696e67b5
commit 291416544e
18 files changed
+547 -3

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
"""Fetch records from an OData v4 JSON endpoint, following pagination."""
import httpx
async def fetch(
url: str,
username: str | None = None,
password: str | None = None,
) -> list[dict]:
auth = (username, password) if username and password else None
records: list[dict] = []
next_url: str | None = url
headers= {"Accept": "application/json" }
async with httpx.AsyncClient(timeout=30.0) as client:
while next_url:
response = await client.get(next_url, auth=auth, headers=headers)
response.raise_for_status()
body = response.json()
records.extend(body.get("value", []))
next_url = body.get("@odata.nextLink")
return records