mirror of
https://github.com/home-assistant/core.git
synced 2026-06-03 06:04:06 +01:00
ef29183160
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: balloob <1444314+balloob@users.noreply.github.com>
23 lines
625 B
Python
23 lines
625 B
Python
"""HTTP client for fetching remote calendar data."""
|
|
|
|
from httpx import AsyncClient, Auth, BasicAuth, Response, Timeout
|
|
|
|
|
|
async def get_calendar(
|
|
client: AsyncClient,
|
|
url: str,
|
|
username: str | None = None,
|
|
password: str | None = None,
|
|
) -> Response:
|
|
"""Make an HTTP GET request using Home Assistant's async HTTPX client."""
|
|
auth: Auth | None = None
|
|
if username is not None and password is not None:
|
|
auth = BasicAuth(username, password)
|
|
|
|
return await client.get(
|
|
url,
|
|
auth=auth,
|
|
follow_redirects=True,
|
|
timeout=Timeout(5, read=30, write=5, pool=5),
|
|
)
|