"""Examples for retried HTTP calls with infra_core."""

from __future__ import annotations

from typing import Any, cast

from infra_core import fetch, request_async


def fetch_healthcheck() -> str:
    """Fetch a plain-text health endpoint with retry defaults."""
    return fetch("https://example.com/healthz", timeout=15, max_retries=2)


async def create_remote_job() -> dict[str, Any]:
    """POST JSON to an API and return the decoded response body."""
    response = await request_async(
        "POST",
        "https://example.com/api/jobs",
        json={"kind": "demo"},
        timeout=20.0,
        max_retries=2,
    )
    return cast(dict[str, Any], response.json())


def main() -> None:
    print(fetch_healthcheck())


if __name__ == "__main__":
    main()
