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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from .raw_client import AsyncRawFeedbackClient, RawFeedbackClient
from .types.feedback_target_type import FeedbackTargetType
from .types.submit_feedback_response import SubmitFeedbackResponse

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


class FeedbackClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawFeedbackClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawFeedbackClient
        """
        return self._raw_client

    def submit(
        self,
        *,
        target_type: FeedbackTargetType,
        target: str,
        feedback: str,
        goal: typing.Optional[str] = OMIT,
        reference_url: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SubmitFeedbackResponse:
        """
        Submit explicit user-approved feedback about Langfuse skills, MCP tools, CLI, docs, or public API. Do not include secrets, credentials, customer data, trace payloads, or unrelated use-case details.

        Parameters
        ----------
        target_type : FeedbackTargetType
            Category of the thing the feedback is about.

        target : str
            The specific instance within targetType: the skill name, MCP tool name, CLI command, API endpoint path, or docs page path (e.g. 'queryMetrics', '/docs/mcp'). An identifier, not a sentence. Must be between 1 and 200 characters.

        feedback : str
            Concise feedback text approved by the user. Must be between 1 and 3000 characters.

        goal : typing.Optional[str]
            Optional user-approved goal or use case they were trying to achieve. Must be between 1 and 1500 characters when provided. Do not include secrets, customer data, trace payloads, or broad unrelated context.

        reference_url : typing.Optional[str]
            Optional HTTP(S) reference URL. Langfuse stores it as text for triage and does not fetch it.

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

        Returns
        -------
        SubmitFeedbackResponse

        Examples
        --------
        from langfuse import LangfuseAPI
        from langfuse.feedback import FeedbackTargetType

        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.feedback.submit(
            target_type=FeedbackTargetType.SKILL,
            target="target",
            feedback="feedback",
        )
        """
        _response = self._raw_client.submit(
            target_type=target_type,
            target=target,
            feedback=feedback,
            goal=goal,
            reference_url=reference_url,
            request_options=request_options,
        )
        return _response.data


class AsyncFeedbackClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawFeedbackClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawFeedbackClient
        """
        return self._raw_client

    async def submit(
        self,
        *,
        target_type: FeedbackTargetType,
        target: str,
        feedback: str,
        goal: typing.Optional[str] = OMIT,
        reference_url: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SubmitFeedbackResponse:
        """
        Submit explicit user-approved feedback about Langfuse skills, MCP tools, CLI, docs, or public API. Do not include secrets, credentials, customer data, trace payloads, or unrelated use-case details.

        Parameters
        ----------
        target_type : FeedbackTargetType
            Category of the thing the feedback is about.

        target : str
            The specific instance within targetType: the skill name, MCP tool name, CLI command, API endpoint path, or docs page path (e.g. 'queryMetrics', '/docs/mcp'). An identifier, not a sentence. Must be between 1 and 200 characters.

        feedback : str
            Concise feedback text approved by the user. Must be between 1 and 3000 characters.

        goal : typing.Optional[str]
            Optional user-approved goal or use case they were trying to achieve. Must be between 1 and 1500 characters when provided. Do not include secrets, customer data, trace payloads, or broad unrelated context.

        reference_url : typing.Optional[str]
            Optional HTTP(S) reference URL. Langfuse stores it as text for triage and does not fetch it.

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

        Returns
        -------
        SubmitFeedbackResponse

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI
        from langfuse.feedback import FeedbackTargetType

        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.feedback.submit(
                target_type=FeedbackTargetType.SKILL,
                target="target",
                feedback="feedback",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.submit(
            target_type=target_type,
            target=target,
            feedback=feedback,
            goal=goal,
            reference_url=reference_url,
            request_options=request_options,
        )
        return _response.data
