"""Sync namespace management operations for a Pinecone index."""

from __future__ import annotations

from typing import TYPE_CHECKING, Any


if TYPE_CHECKING:
    from pinecone.models.namespaces.delete import DeleteNamespaceResponse
    from pinecone.models.namespaces.list import ListNamespacesResponse
    from pinecone.models.namespaces.namespace import NamespaceDescription


class Namespaces:
    """Sub-namespace for namespace management operations on a Pinecone index.

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

        index = Index(host="...", api_key="...")
        ns_list = index.namespaces.list()

    Args:
        http: HTTP client for making requests.
        base_url: Base URL for the index data plane API.
    """

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

        from pinecone.namespaces import (
            _create,
            _delete,
            _describe,
            _helpers,
            _list,
        )

        self._make_data_plane_request = _helpers._make_data_plane_request.__get__(self, type(self))
        self.create = _create.create.__get__(self, type(self))  # type: ignore[method-assign]
        self.list = _list.list.__get__(self, type(self))  # type: ignore[method-assign]
        self.describe = _describe.describe.__get__(self, type(self))  # type: ignore[method-assign]
        self.delete = _delete.delete.__get__(self, type(self))  # type: ignore[method-assign]

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

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

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

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

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