# This file was auto-generated by Fern from our API Definition.

import typing

from ..commons.types.comment import Comment
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from .raw_client import AsyncRawCommentsClient, RawCommentsClient
from .types.create_comment_response import CreateCommentResponse
from .types.get_comments_response import GetCommentsResponse

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class CommentsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawCommentsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawCommentsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawCommentsClient
        """
        return self._raw_client

    def create(
        self,
        *,
        project_id: str,
        object_type: str,
        object_id: str,
        content: str,
        author_user_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateCommentResponse:
        """
        Create a comment. Comments may be attached to different object types (trace, observation, session, prompt).

        Parameters
        ----------
        project_id : str
            The id of the project to attach the comment to.

        object_type : str
            The type of the object to attach the comment to (trace, observation, session, prompt).

        object_id : str
            The id of the object to attach the comment to. If this does not reference a valid existing object, an error will be thrown.

        content : str
            The content of the comment. May include markdown. Currently limited to 5000 characters.

        author_user_id : typing.Optional[str]
            The id of the user who created the comment.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        CreateCommentResponse

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.comments.create(
            project_id="projectId",
            object_type="objectType",
            object_id="objectId",
            content="content",
        )
        """
        _response = self._raw_client.create(
            project_id=project_id,
            object_type=object_type,
            object_id=object_id,
            content=content,
            author_user_id=author_user_id,
            request_options=request_options,
        )
        return _response.data

    def get(
        self,
        *,
        page: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        object_type: typing.Optional[str] = None,
        object_id: typing.Optional[str] = None,
        author_user_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetCommentsResponse:
        """
        Get all comments

        Parameters
        ----------
        page : typing.Optional[int]
            Page number, starts at 1.

        limit : typing.Optional[int]
            Limit of items per page. If you encounter api issues due to too large page sizes, try to reduce the limit

        object_type : typing.Optional[str]
            Filter comments by object type (trace, observation, session, prompt).

        object_id : typing.Optional[str]
            Filter comments by object id. If objectType is not provided, an error will be thrown.

        author_user_id : typing.Optional[str]
            Filter comments by author user id.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetCommentsResponse

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.comments.get()
        """
        _response = self._raw_client.get(
            page=page,
            limit=limit,
            object_type=object_type,
            object_id=object_id,
            author_user_id=author_user_id,
            request_options=request_options,
        )
        return _response.data

    def get_by_id(
        self,
        comment_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Comment:
        """
        Get a comment by id

        Parameters
        ----------
        comment_id : str
            The unique langfuse identifier of a comment

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Comment

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.comments.get_by_id(
            comment_id="commentId",
        )
        """
        _response = self._raw_client.get_by_id(
            comment_id, request_options=request_options
        )
        return _response.data


class AsyncCommentsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawCommentsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawCommentsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawCommentsClient
        """
        return self._raw_client

    async def create(
        self,
        *,
        project_id: str,
        object_type: str,
        object_id: str,
        content: str,
        author_user_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateCommentResponse:
        """
        Create a comment. Comments may be attached to different object types (trace, observation, session, prompt).

        Parameters
        ----------
        project_id : str
            The id of the project to attach the comment to.

        object_type : str
            The type of the object to attach the comment to (trace, observation, session, prompt).

        object_id : str
            The id of the object to attach the comment to. If this does not reference a valid existing object, an error will be thrown.

        content : str
            The content of the comment. May include markdown. Currently limited to 5000 characters.

        author_user_id : typing.Optional[str]
            The id of the user who created the comment.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        CreateCommentResponse

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.comments.create(
                project_id="projectId",
                object_type="objectType",
                object_id="objectId",
                content="content",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            project_id=project_id,
            object_type=object_type,
            object_id=object_id,
            content=content,
            author_user_id=author_user_id,
            request_options=request_options,
        )
        return _response.data

    async def get(
        self,
        *,
        page: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        object_type: typing.Optional[str] = None,
        object_id: typing.Optional[str] = None,
        author_user_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetCommentsResponse:
        """
        Get all comments

        Parameters
        ----------
        page : typing.Optional[int]
            Page number, starts at 1.

        limit : typing.Optional[int]
            Limit of items per page. If you encounter api issues due to too large page sizes, try to reduce the limit

        object_type : typing.Optional[str]
            Filter comments by object type (trace, observation, session, prompt).

        object_id : typing.Optional[str]
            Filter comments by object id. If objectType is not provided, an error will be thrown.

        author_user_id : typing.Optional[str]
            Filter comments by author user id.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetCommentsResponse

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.comments.get()


        asyncio.run(main())
        """
        _response = await self._raw_client.get(
            page=page,
            limit=limit,
            object_type=object_type,
            object_id=object_id,
            author_user_id=author_user_id,
            request_options=request_options,
        )
        return _response.data

    async def get_by_id(
        self,
        comment_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Comment:
        """
        Get a comment by id

        Parameters
        ----------
        comment_id : str
            The unique langfuse identifier of a comment

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Comment

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.comments.get_by_id(
                comment_id="commentId",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_by_id(
            comment_id, request_options=request_options
        )
        return _response.data
