# DO NOT EDIT — generated by _gen/convenience_emitter.py from convenience.json.
# Regenerate with: cd clients/v2 && python -c "from _gen.convenience_emitter import generate_convenience; generate_convenience()"

"""Memories API namespace — generated from convenience.json."""

from __future__ import annotations

from typing import Any

from goodmem._api_base.memories import MemoriesAPIBase, AsyncMemoriesAPIBase


# --- Convenience imports ---
from goodmem._transforms import apply_convenience_transforms
from goodmem._transforms import _transform_list_kwargs
from goodmem._overrides import (
    memories_create_sync,
    memories_create_async,
    MemoryCreationRequest,
    memories_batch_create_sync,
    memories_batch_create_async,
    memories_retrieve_sync,
    memories_retrieve_async,
)
from goodmem.models.memory import Memory
from goodmem.models.retrieve_memory_event import RetrieveMemoryEvent
from goodmem.streaming import AsyncRetrieveMemoryStream, RetrieveMemoryStream


class MemoriesAPI(MemoriesAPIBase):
    def batch_create(self, *, requests: list[MemoryCreationRequest]) -> Any:
        return memories_batch_create_sync(self, requests=requests)

    def create(self, *, space_id: str | None = None, file_path: str | None = None, **kwargs: Any) -> Memory:
        return memories_create_sync(self, space_id=space_id, file_path=file_path, **kwargs)

    def list(self, *, space_id: str, **kwargs: Any) -> Paginator:
        max_items = _transform_list_kwargs(kwargs)
        paginator = super().list(space_id=space_id, **kwargs)
        paginator._max_items = max_items
        return paginator

    def retrieve(self, *, message: str, stream: bool = True, **kwargs: Any) -> RetrieveMemoryStream | list[RetrieveMemoryEvent]:
        return memories_retrieve_sync(self, message=message, stream=stream, **kwargs)



class AsyncMemoriesAPI(AsyncMemoriesAPIBase):
    async def batch_create(self, *, requests: list[MemoryCreationRequest]) -> Any:
        return await memories_batch_create_async(self, requests=requests)

    async def create(self, *, space_id: str | None = None, file_path: str | None = None, **kwargs: Any) -> Memory:
        return await memories_create_async(self, space_id=space_id, file_path=file_path, **kwargs)

    def list(self, *, space_id: str, **kwargs: Any) -> AsyncPaginator:
        max_items = _transform_list_kwargs(kwargs)
        paginator = super().list(space_id=space_id, **kwargs)
        paginator._max_items = max_items
        return paginator

    async def retrieve(self, *, message: str, stream: bool = True, **kwargs: Any) -> AsyncRetrieveMemoryStream | list[RetrieveMemoryEvent]:
        return await memories_retrieve_async(self, message=message, stream=stream, **kwargs)

