"""Adapter for transforming Collections API responses to SDK models.

This adapter provides minimal transformation from raw API responses to typed SDK models.
All transformations are documented to explain why they're needed.
"""

from typing import Any

from pinecone.models.collections import CollectionList, CollectionModel


class CollectionsAdapter:
    """Adapter for Collections API responses.

    This class transforms raw API responses into typed SDK models. Each transformation
    is kept minimal and documented.
    """

    @staticmethod
    def to_collection_model(data: dict[str, Any]) -> CollectionModel:
        """Transform collection API response to CollectionModel.

        Args:
            data: Raw API response dictionary

        Returns:
            Typed CollectionModel

        Transformations:
            - Maps all fields directly from API response
            - Handles all required fields (name, size, status, dimension, vector_count, environment)
        """
        return CollectionModel(
            name=data["name"],
            size=data["size"],
            status=data["status"],
            dimension=data["dimension"],
            vector_count=data["vector_count"],
            environment=data["environment"],
        )

    @staticmethod
    def to_collection_list(data: dict[str, Any]) -> CollectionList:
        """Transform list collections API response to CollectionList model.

        Args:
            data: Raw API response dictionary

        Returns:
            Typed CollectionList model

        Transformations:
            - Wraps collection data in CollectionModel objects
            - Preserves all collection metadata from API response
        """
        collections = [CollectionsAdapter.to_collection_model(item) for item in data["collections"]]

        return CollectionList(collections=collections)
