"""Permissions API endpoints."""

from __future__ import annotations

from typing import TYPE_CHECKING

from vikdata.models.permission import (
    PermissionListParams,
    PermissionListResponse,
)

if TYPE_CHECKING:
    from vikdata.client import VikdataClient


class PermissionsAPI:
    """Permissions API endpoints.

    Handles permission queries.
    """

    def __init__(self, client: "VikdataClient") -> None:
        """Initialize permissions API.

        Args:
            client: VikdataClient instance
        """
        self._client = client

    async def list(self, params: PermissionListParams | None = None) -> PermissionListResponse:
        """List available permissions.

        Args:
            params: Query parameters for filtering

        Returns:
            PermissionListResponse with list of permissions

        Raises:
            AuthenticationError: Not authenticated
        """
        query_params = params.model_dump(exclude_none=True) if params else {}
        return await self._client.request(
            "GET",
            "/api/v1/permissions",
            params=query_params,
            response_model=PermissionListResponse,
        )
