"""List bulk imports method for BulkImports."""

from __future__ import annotations

from typing import Any

import msgspec

from pinecone.models.bulk_imports.list import ListImportsResponse


_DECODER = msgspec.json.Decoder(ListImportsResponse)


def list(
    self: Any,
    *,
    limit: int | None = None,
    pagination_token: str | None = None,
) -> ListImportsResponse:
    """List bulk import operations.

    Args:
        limit (int | None): Maximum number of imports to return (default 100,
            max 100).
        pagination_token (str | None): Token to resume from a previous call.

    Returns:
        ListImportsResponse with import operations and pagination info.

    Raises:
        PineconeApiException: If the API request fails.

    Examples:
        >>> response = index.bulk_imports.list(limit=10)
        >>> for imp in response.data:
        ...     print(f"{imp.id}: {imp.status}")
    """
    params: dict[str, Any] = {}
    if limit is not None:
        params["limit"] = limit
    if pagination_token is not None:
        params["paginationToken"] = pagination_token

    data = self._make_data_plane_request("GET", "/bulk/imports", params=params)
    return _DECODER.decode(data)
