import json
import os
from pathlib import Path
import httpx

request = {
    "input": "Book a one-hour review on October 5, 2026, starting at 10:00 UTC, within the permitted window.",
    "policy": {
        "engine": "opa",
        "entrypoint": "data.schedule.allow",
        "modules": {
            "schedule.rego": Path("schedule.rego").read_text(encoding="utf-8"),
        },
    },
    "policy_max_retries": 8,
    "schema": json.loads(Path("schedule.schema.json").read_text(encoding="utf-8")),
    "state": json.loads(Path("schedule.state.json").read_text(encoding="utf-8")),
}
with httpx.Client(
    base_url="https://api.blatent.ai",
    headers={"Authorization": f"Bearer {os.environ['BLATENT_API_KEY']}"},
    timeout=195,
) as client:
    response = client.post("/v1/resolve", json=request)
    response.raise_for_status()
    print(json.dumps(response.json()["output"]))
