from __future__ import annotations

from uuid import UUID

from .base import SubclientBase
from ..schemas import ItemTypeDisplayAttributesResponse, ItemTypeMetadataResponse


class MetadataClient(SubclientBase):
    async def get_item_type_metadata(
        self,
        item_type_id: UUID,
    ) -> ItemTypeMetadataResponse:
        response = await self._client.get(
            self._client.path(f"/queries/item-types/{item_type_id}")
        )
        return self._client.parse(response, ItemTypeMetadataResponse)

    async def get_item_type_display_attributes(
        self,
        item_type_id: UUID,
        version: str,
    ) -> ItemTypeDisplayAttributesResponse:
        if not version:
            raise ValueError("version must be a non-empty string")

        response = await self._client.get(
            self._client.path(
                f"/metadata/json-schema/{item_type_id}/display-attributes"
            ),
            params={"version": version},
        )
        return self._client.parse(response, ItemTypeDisplayAttributesResponse)
