"""Sub-namespace for records API operations on a Pinecone index.

This module provides the sync ``Records`` class that exposes methods
for upserting and searching records using integrated inference.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Any


if TYPE_CHECKING:
    from pinecone.models.records.search import SearchRecordsResponse
    from pinecone.records import _helpers, _search, _upsert


class Records:
    """Sub-namespace for records API operations on a Pinecone index.

    Access via the ``records`` property on an Index instance::

        index = Index(host="...", api_key="...")
        results = index.records.search(
            namespace="ns",
            top_k=10,
            inputs={"text": "hello"},
        )

    Args:
        http: HTTP client instance for making requests.
        base_url: Base URL of the index (e.g., ``"https://my-index.svc.pinecone.io"``).
    """

    def __init__(self, *, http: Any, base_url: str) -> None:
        self._http = http
        self._base_url = base_url

        from pinecone.records import _helpers, _search, _upsert

        self._make_data_plane_request = _helpers._make_data_plane_request.__get__(self, type(self))
        self._make_ndjson_request = _helpers._make_ndjson_request.__get__(self, type(self))
        self.upsert = _upsert.upsert.__get__(self, type(self))  # type: ignore[method-assign]
        self.search = _search.search.__get__(self, type(self))  # type: ignore[method-assign]

    # Protocol method stubs (overridden in __init__)
    def upsert(self, *args: Any, **kwargs: Any) -> None:
        """Stub for upsert method (overridden in __init__)."""
        raise NotImplementedError  # pragma: no cover

    def search(self, *args: Any, **kwargs: Any) -> SearchRecordsResponse:
        """Stub for search method (overridden in __init__)."""
        raise NotImplementedError  # pragma: no cover

    def __repr__(self) -> str:
        """Return string representation."""
        return f"Records(base_url={self._base_url!r})"
