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

from __future__ import annotations

import typing

from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.request_options import RequestOptions
from ...types.metric_param import MetricParam
from .raw_client import AsyncRawMetricsClient, RawMetricsClient

if typing.TYPE_CHECKING:
    from .custom.client import AsyncCustomClient, CustomClient
# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class MetricsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawMetricsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._custom: typing.Optional[CustomClient] = None

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

        Returns
        -------
        RawMetricsClient
        """
        return self._raw_client

    def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> MetricParam:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get the current metrics configuration for a project.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        MetricParam
            Current metrics configuration

        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.metrics.get(
            id=1,
        )
        """
        _response = self._raw_client.get(id, request_options=request_options)
        return _response.data

    def update(
        self,
        id: int,
        *,
        additional_params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        agreement_threshold: typing.Optional[int] = OMIT,
        max_additional_annotators_assignable: typing.Optional[int] = OMIT,
        metric_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MetricParam:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Update metrics strategy and parameters for a project.

        Parameters
        ----------
        id : int

        additional_params : typing.Optional[typing.Dict[str, typing.Any]]

        agreement_threshold : typing.Optional[int]

        max_additional_annotators_assignable : typing.Optional[int]

        metric_name : typing.Optional[str]

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

        Returns
        -------
        MetricParam
            Updated metrics configuration

        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.metrics.update(
            id=1,
        )
        """
        _response = self._raw_client.update(
            id,
            additional_params=additional_params,
            agreement_threshold=agreement_threshold,
            max_additional_annotators_assignable=max_additional_annotators_assignable,
            metric_name=metric_name,
            request_options=request_options,
        )
        return _response.data

    @property
    def custom(self):
        if self._custom is None:
            from .custom.client import CustomClient  # noqa: E402

            self._custom = CustomClient(client_wrapper=self._client_wrapper)
        return self._custom


class AsyncMetricsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawMetricsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._custom: typing.Optional[AsyncCustomClient] = None

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

        Returns
        -------
        AsyncRawMetricsClient
        """
        return self._raw_client

    async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> MetricParam:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get the current metrics configuration for a project.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        MetricParam
            Current metrics configuration

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.metrics.get(
                id=1,
            )


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

    async def update(
        self,
        id: int,
        *,
        additional_params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        agreement_threshold: typing.Optional[int] = OMIT,
        max_additional_annotators_assignable: typing.Optional[int] = OMIT,
        metric_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MetricParam:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Update metrics strategy and parameters for a project.

        Parameters
        ----------
        id : int

        additional_params : typing.Optional[typing.Dict[str, typing.Any]]

        agreement_threshold : typing.Optional[int]

        max_additional_annotators_assignable : typing.Optional[int]

        metric_name : typing.Optional[str]

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

        Returns
        -------
        MetricParam
            Updated metrics configuration

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.metrics.update(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            id,
            additional_params=additional_params,
            agreement_threshold=agreement_threshold,
            max_additional_annotators_assignable=max_additional_annotators_assignable,
            metric_name=metric_name,
            request_options=request_options,
        )
        return _response.data

    @property
    def custom(self):
        if self._custom is None:
            from .custom.client import AsyncCustomClient  # noqa: E402

            self._custom = AsyncCustomClient(client_wrapper=self._client_wrapper)
        return self._custom
