"""AI Infrastructure Service API Client."""

from functools import cached_property

from httpx import Client
from slices_clientlib_core.base.config import ApiEntry
from slices_clientlib_core.client import (
    SlicesClient as SlicesCoreClient,
)
from slices_clientlib_core.client import (
    SlicesExperimentClient as SlicesCoreExperimentClient,
)
from slices_clientlib_core.client import (
    SlicesProjectClient as SlicesCoreProjectClient,
)

from slices_clientlib_aiis.aiis_job import AIJobClient
from slices_clientlib_aiis.aiis_news import AINewsClient
from slices_clientlib_aiis.aiis_workers import AIWorkersClient


class AIInfraServiceClient:
    """AI Infrastructure Service Client."""

    def __init__(
        self,
        site_id: str,
        api_entry: ApiEntry,
        client: Client,
        slices_client: SlicesCoreProjectClient | SlicesCoreExperimentClient,
        slices_root_client: SlicesCoreClient,
    ) -> None:
        """Create AI Infrastructure Service Client."""
        self._site_id = site_id
        self._api_entry = api_entry
        self._client = client
        self._slices_client = slices_client
        self._slices_root_client = slices_root_client
        assert client.base_url is not None, "Expected base_url to be set"

    @cached_property
    def jobs(self) -> AIJobClient:
        """AI Jobs Client."""
        return AIJobClient(self._site_id, self._api_entry, self._client, self._slices_client, self._slices_root_client)

    @cached_property
    def news(self) -> AINewsClient:
        """AIIS News Client."""
        return AINewsClient(self._client)

    @cached_property
    def workers(self) -> AIWorkersClient:
        """AIIS Worker Client."""
        return AIWorkersClient(self._client)
