"""
AgniPod SDK — Models
======================

Usage::

    from agnipod import AgniPod

    client = AgniPod()

    # List all models
    models = client.models.list()
    for m in models:
        print(m.name, m.context_length)

    # Get a specific model
    model = client.models.get("qwen3:8b")
    print(model.name, model.context_length)
"""

from __future__ import annotations

from ._client import HttpClient
from ._types import Model, ModelList

_PREFIX = "/models"


class Models:
    """Namespace for ``/models`` operations."""

    def __init__(self, client: HttpClient):
        self._client = client

    def list(self) -> ModelList:
        """List all available models.

        Returns
        -------
        ModelList
            Iterable of ``Model`` objects.
        """
        data = self._client.get(_PREFIX)
        return ModelList(data)

    def get(self, model_id: str) -> Model:
        """Retrieve a specific model by name.

        Parameters
        ----------
        model_id : str
            The model name / identifier.

        Returns
        -------
        Model
        """
        data = self._client.get(f"{_PREFIX}/{model_id}")
        model_data = data.get("model", data)
        return Model(model_data)
