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

import typing

from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...commons.types.create_score_value import CreateScoreValue
from ...commons.types.score_data_type import ScoreDataType
from ...scores.client import (
    AsyncScoresClient as CanonicalAsyncScoresClient,
    ScoresClient as CanonicalScoresClient,
    OMIT,
)
from ...scores.types.create_score_response import CreateScoreResponse
from ...scores.types.create_score_source import CreateScoreSource
from ...core.request_options import RequestOptions
from .raw_client import AsyncRawScoreV1Client, RawScoreV1Client


class ScoreV1Client:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawScoreV1Client(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawScoreV1Client
        """
        return self._raw_client

    def create(
        self,
        *,
        name: str,
        value: CreateScoreValue,
        id: typing.Optional[str] = OMIT,
        trace_id: typing.Optional[str] = OMIT,
        session_id: typing.Optional[str] = OMIT,
        observation_id: typing.Optional[str] = OMIT,
        dataset_run_id: typing.Optional[str] = OMIT,
        comment: typing.Optional[str] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        environment: typing.Optional[str] = OMIT,
        queue_id: typing.Optional[str] = OMIT,
        data_type: typing.Optional[ScoreDataType] = OMIT,
        config_id: typing.Optional[str] = OMIT,
        source: typing.Optional[CreateScoreSource] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateScoreResponse:
        """**Deprecated compatibility alias.** Use ``client.scores.create``."""
        return CanonicalScoresClient(
            client_wrapper=self._raw_client._client_wrapper
        ).create(
            name=name,
            value=value,
            id=id,
            trace_id=trace_id,
            session_id=session_id,
            observation_id=observation_id,
            dataset_run_id=dataset_run_id,
            comment=comment,
            metadata=metadata,
            environment=environment,
            queue_id=queue_id,
            data_type=data_type,
            config_id=config_id,
            source=source,
            request_options=request_options,
        )

    def delete(
        self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a score (supports both trace and session scores)

        Parameters
        ----------
        score_id : str
            The unique langfuse identifier of a score

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

        Returns
        -------
        None

        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.legacy.score_v1.delete(
            score_id="scoreId",
        )
        """
        _response = self._raw_client.delete(score_id, request_options=request_options)
        return _response.data


class AsyncScoreV1Client:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawScoreV1Client(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawScoreV1Client
        """
        return self._raw_client

    async def create(
        self,
        *,
        name: str,
        value: CreateScoreValue,
        id: typing.Optional[str] = OMIT,
        trace_id: typing.Optional[str] = OMIT,
        session_id: typing.Optional[str] = OMIT,
        observation_id: typing.Optional[str] = OMIT,
        dataset_run_id: typing.Optional[str] = OMIT,
        comment: typing.Optional[str] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        environment: typing.Optional[str] = OMIT,
        queue_id: typing.Optional[str] = OMIT,
        data_type: typing.Optional[ScoreDataType] = OMIT,
        config_id: typing.Optional[str] = OMIT,
        source: typing.Optional[CreateScoreSource] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateScoreResponse:
        """**Deprecated compatibility alias.** Use ``client.scores.create``."""
        return await CanonicalAsyncScoresClient(
            client_wrapper=self._raw_client._client_wrapper
        ).create(
            name=name,
            value=value,
            id=id,
            trace_id=trace_id,
            session_id=session_id,
            observation_id=observation_id,
            dataset_run_id=dataset_run_id,
            comment=comment,
            metadata=metadata,
            environment=environment,
            queue_id=queue_id,
            data_type=data_type,
            config_id=config_id,
            source=source,
            request_options=request_options,
        )

    async def delete(
        self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a score (supports both trace and session scores)

        Parameters
        ----------
        score_id : str
            The unique langfuse identifier of a score

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

        Returns
        -------
        None

        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.legacy.score_v1.delete(
                score_id="scoreId",
            )


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