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

import datetime as dt
import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from .raw_client import AsyncRawScoresV3Client, RawScoresV3Client
from .types.get_scores_v3response import GetScoresV3Response


class ScoresV3Client:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawScoresV3Client(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawScoresV3Client
        """
        return self._raw_client

    def get_many_v3(
        self,
        *,
        limit: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        fields: typing.Optional[str] = None,
        id: typing.Optional[str] = None,
        name: typing.Optional[str] = None,
        source: typing.Optional[str] = None,
        data_type: typing.Optional[str] = None,
        environment: typing.Optional[str] = None,
        config_id: typing.Optional[str] = None,
        queue_id: typing.Optional[str] = None,
        author_user_id: typing.Optional[str] = None,
        value: typing.Optional[str] = None,
        value_min: typing.Optional[float] = None,
        value_max: typing.Optional[float] = None,
        trace_id: typing.Optional[str] = None,
        session_id: typing.Optional[str] = None,
        observation_id: typing.Optional[str] = None,
        experiment_id: typing.Optional[str] = None,
        from_timestamp: typing.Optional[dt.datetime] = None,
        to_timestamp: typing.Optional[dt.datetime] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetScoresV3Response:
        """
        Get a list of scores with a polymorphic `value` field (v3).

        The `value` field type depends on `dataType`:
        - `NUMERIC` → number
        - `BOOLEAN` → boolean
        - `CATEGORICAL`, `TEXT`, `CORRECTION` → string

        The response always includes the core fields: id, projectId, name,
        value, dataType, source, timestamp, environment, createdAt, updatedAt.

        Additional field groups can be requested via the `fields` parameter:
        - `details` — adds comment, configId, metadata
        - `subject` — adds the subject object describing the entity the score
          is attached to: kind (trace, observation, session, or experiment),
          id, and traceId for observation-level scores
        - `annotation` — adds authorUserId, queueId

        Unknown group names return HTTP 400.

        Parameters
        ----------
        limit : typing.Optional[int]
            Number of items per page. Maximum 100, default 50. Requests with a limit greater than 100 return HTTP 400.

        cursor : typing.Optional[str]
            URL-safe base64 (base64url) cursor for pagination. Use the cursor from the previous response to get the next page. Absent on the final page.

        fields : typing.Optional[str]
            Comma-separated field groups to include in addition to the always-returned core fields. Allowed: details, subject, annotation — see the endpoint description for the fields each group adds. Unknown names return HTTP 400.

        id : typing.Optional[str]
            Comma-separated list of score IDs to filter by (OR within, AND across filters).

        name : typing.Optional[str]
            Comma-separated list of score names to filter by.

        source : typing.Optional[str]
            Comma-separated list of score sources to filter by (e.g. API, ANNOTATION, EVAL). Case-insensitive — `api` and `API` are equivalent.

        data_type : typing.Optional[str]
            Comma-separated list of data types to filter by (NUMERIC, BOOLEAN, CATEGORICAL, TEXT, CORRECTION). Case-insensitive — `numeric` and `NUMERIC` are equivalent. Must be a single value when used with value, valueMin, or valueMax; otherwise the request returns HTTP 400. Must be NUMERIC when used with valueMin or valueMax.

        environment : typing.Optional[str]
            Comma-separated list of environments to filter by.

        config_id : typing.Optional[str]
            Comma-separated list of score config IDs to filter by.

        queue_id : typing.Optional[str]
            Comma-separated list of annotation queue IDs to filter by.

        author_user_id : typing.Optional[str]
            Comma-separated list of author user IDs to filter by.

        value : typing.Optional[str]
            Comma-separated list of exact values to filter by. Requires a single dataType from NUMERIC, BOOLEAN, or CATEGORICAL; any other dataType, multiple dataTypes, or omitting dataType returns HTTP 400. For BOOLEAN, each value must be "true" or "false"; for NUMERIC, each value must be a finite number. Otherwise the request returns HTTP 400.

        value_min : typing.Optional[float]
            Inclusive lower bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400.

        value_max : typing.Optional[float]
            Inclusive upper bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400.

        trace_id : typing.Optional[str]
            Comma-separated list of trace IDs to filter by. Mutually exclusive with sessionId, experimentId. May be combined with observationId to scope the observation lookup to a specific trace.

        session_id : typing.Optional[str]
            Comma-separated list of session IDs to filter by. Mutually exclusive with traceId, observationId, experimentId.

        observation_id : typing.Optional[str]
            Comma-separated list of observation IDs to filter by. Requires traceId to be specified, because observation IDs are scoped to a trace. Mutually exclusive with sessionId, experimentId. Returns HTTP 400 when used without traceId.

        experiment_id : typing.Optional[str]
            Comma-separated list of dataset run IDs (experiment IDs) to filter by. Mutually exclusive with traceId, sessionId, observationId.

        from_timestamp : typing.Optional[dt.datetime]
            Inclusive lower bound on the score timestamp.

        to_timestamp : typing.Optional[dt.datetime]
            Exclusive upper bound on the score timestamp.

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

        Returns
        -------
        GetScoresV3Response

        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.scores_v3.get_many_v3()
        """
        _response = self._raw_client.get_many_v3(
            limit=limit,
            cursor=cursor,
            fields=fields,
            id=id,
            name=name,
            source=source,
            data_type=data_type,
            environment=environment,
            config_id=config_id,
            queue_id=queue_id,
            author_user_id=author_user_id,
            value=value,
            value_min=value_min,
            value_max=value_max,
            trace_id=trace_id,
            session_id=session_id,
            observation_id=observation_id,
            experiment_id=experiment_id,
            from_timestamp=from_timestamp,
            to_timestamp=to_timestamp,
            request_options=request_options,
        )
        return _response.data


class AsyncScoresV3Client:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawScoresV3Client(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawScoresV3Client
        """
        return self._raw_client

    async def get_many_v3(
        self,
        *,
        limit: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        fields: typing.Optional[str] = None,
        id: typing.Optional[str] = None,
        name: typing.Optional[str] = None,
        source: typing.Optional[str] = None,
        data_type: typing.Optional[str] = None,
        environment: typing.Optional[str] = None,
        config_id: typing.Optional[str] = None,
        queue_id: typing.Optional[str] = None,
        author_user_id: typing.Optional[str] = None,
        value: typing.Optional[str] = None,
        value_min: typing.Optional[float] = None,
        value_max: typing.Optional[float] = None,
        trace_id: typing.Optional[str] = None,
        session_id: typing.Optional[str] = None,
        observation_id: typing.Optional[str] = None,
        experiment_id: typing.Optional[str] = None,
        from_timestamp: typing.Optional[dt.datetime] = None,
        to_timestamp: typing.Optional[dt.datetime] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetScoresV3Response:
        """
        Get a list of scores with a polymorphic `value` field (v3).

        The `value` field type depends on `dataType`:
        - `NUMERIC` → number
        - `BOOLEAN` → boolean
        - `CATEGORICAL`, `TEXT`, `CORRECTION` → string

        The response always includes the core fields: id, projectId, name,
        value, dataType, source, timestamp, environment, createdAt, updatedAt.

        Additional field groups can be requested via the `fields` parameter:
        - `details` — adds comment, configId, metadata
        - `subject` — adds the subject object describing the entity the score
          is attached to: kind (trace, observation, session, or experiment),
          id, and traceId for observation-level scores
        - `annotation` — adds authorUserId, queueId

        Unknown group names return HTTP 400.

        Parameters
        ----------
        limit : typing.Optional[int]
            Number of items per page. Maximum 100, default 50. Requests with a limit greater than 100 return HTTP 400.

        cursor : typing.Optional[str]
            URL-safe base64 (base64url) cursor for pagination. Use the cursor from the previous response to get the next page. Absent on the final page.

        fields : typing.Optional[str]
            Comma-separated field groups to include in addition to the always-returned core fields. Allowed: details, subject, annotation — see the endpoint description for the fields each group adds. Unknown names return HTTP 400.

        id : typing.Optional[str]
            Comma-separated list of score IDs to filter by (OR within, AND across filters).

        name : typing.Optional[str]
            Comma-separated list of score names to filter by.

        source : typing.Optional[str]
            Comma-separated list of score sources to filter by (e.g. API, ANNOTATION, EVAL). Case-insensitive — `api` and `API` are equivalent.

        data_type : typing.Optional[str]
            Comma-separated list of data types to filter by (NUMERIC, BOOLEAN, CATEGORICAL, TEXT, CORRECTION). Case-insensitive — `numeric` and `NUMERIC` are equivalent. Must be a single value when used with value, valueMin, or valueMax; otherwise the request returns HTTP 400. Must be NUMERIC when used with valueMin or valueMax.

        environment : typing.Optional[str]
            Comma-separated list of environments to filter by.

        config_id : typing.Optional[str]
            Comma-separated list of score config IDs to filter by.

        queue_id : typing.Optional[str]
            Comma-separated list of annotation queue IDs to filter by.

        author_user_id : typing.Optional[str]
            Comma-separated list of author user IDs to filter by.

        value : typing.Optional[str]
            Comma-separated list of exact values to filter by. Requires a single dataType from NUMERIC, BOOLEAN, or CATEGORICAL; any other dataType, multiple dataTypes, or omitting dataType returns HTTP 400. For BOOLEAN, each value must be "true" or "false"; for NUMERIC, each value must be a finite number. Otherwise the request returns HTTP 400.

        value_min : typing.Optional[float]
            Inclusive lower bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400.

        value_max : typing.Optional[float]
            Inclusive upper bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400.

        trace_id : typing.Optional[str]
            Comma-separated list of trace IDs to filter by. Mutually exclusive with sessionId, experimentId. May be combined with observationId to scope the observation lookup to a specific trace.

        session_id : typing.Optional[str]
            Comma-separated list of session IDs to filter by. Mutually exclusive with traceId, observationId, experimentId.

        observation_id : typing.Optional[str]
            Comma-separated list of observation IDs to filter by. Requires traceId to be specified, because observation IDs are scoped to a trace. Mutually exclusive with sessionId, experimentId. Returns HTTP 400 when used without traceId.

        experiment_id : typing.Optional[str]
            Comma-separated list of dataset run IDs (experiment IDs) to filter by. Mutually exclusive with traceId, sessionId, observationId.

        from_timestamp : typing.Optional[dt.datetime]
            Inclusive lower bound on the score timestamp.

        to_timestamp : typing.Optional[dt.datetime]
            Exclusive upper bound on the score timestamp.

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

        Returns
        -------
        GetScoresV3Response

        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.scores_v3.get_many_v3()


        asyncio.run(main())
        """
        _response = await self._raw_client.get_many_v3(
            limit=limit,
            cursor=cursor,
            fields=fields,
            id=id,
            name=name,
            source=source,
            data_type=data_type,
            environment=environment,
            config_id=config_id,
            queue_id=queue_id,
            author_user_id=author_user_id,
            value=value,
            value_min=value_min,
            value_max=value_max,
            trace_id=trace_id,
            session_id=session_id,
            observation_id=observation_id,
            experiment_id=experiment_id,
            from_timestamp=from_timestamp,
            to_timestamp=to_timestamp,
            request_options=request_options,
        )
        return _response.data
