"""Adapter for transforming Restore Job 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

import msgspec

from pinecone.models.restore_jobs import RestoreJobModel


class RestoreJobsAdapter:
    """Adapter for Restore Job API responses.

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

    @staticmethod
    def to_restore_job_model(data: dict[str, Any]) -> RestoreJobModel:
        """Transform restore job API response to RestoreJobModel.

        Args:
            data: Raw API response dictionary

        Returns:
            Typed RestoreJobModel

        Transformations:
            - Convert to model with msgspec (10-30x faster than manual construction)
        """
        return msgspec.convert(data, RestoreJobModel)

    @staticmethod
    def to_restore_job_list(data: dict[str, Any]) -> list[RestoreJobModel]:
        """Transform paginated list response to list of RestoreJobModel.

        Args:
            data: Raw API response dictionary containing paginated list

        Returns:
            List of typed RestoreJobModel objects

        Transformations:
            - Extract 'data' array from response
            - Convert each item using msgspec (10-30x faster than manual construction)
        """
        items = data.get("data", [])
        return [msgspec.convert(item, RestoreJobModel) for item in items]
