from __future__ import annotations

from .base import SubclientBase
from ..schemas import QueryRequest, ReportGenerationResponse


class ReportsClient(SubclientBase):
    async def start_report_generation(
        self,
        request: QueryRequest,
        include_alias: bool = False,
    ) -> ReportGenerationResponse:
        response = await self._client.post(
            self._client.path("/reports/items"),
            json=self._client.dump(request),
            params={"includeAlias": include_alias},
        )
        return self._client.parse(response, ReportGenerationResponse)

    async def download_report(self, job_id: str) -> bytes:
        if not job_id:
            raise ValueError("job_id must be a non-empty string")
        return await self._client.get_bytes(self._client.path(f"/reports/{job_id}"))
