# 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 AsyncRawCustomClient, RawCustomClient
from .types.get_lambda_custom_response import GetLambdaCustomResponse

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


class CustomClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawCustomClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawCustomClient
        """
        return self._raw_client

    def get_lambda(
        self, id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetLambdaCustomResponse:
        """
        <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 AWS Lambda code for the custom metric configured for this project.

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

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

        Returns
        -------
        GetLambdaCustomResponse
            Lambda code and deployment status

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

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

    def update_lambda(
        self,
        id: int,
        *,
        code: str,
        region: typing.Optional[str] = OMIT,
        role: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        <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>
        Create or update the AWS Lambda function used for custom metrics in this project.

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

        code : str
            The Python code for the custom metric function.

        region : typing.Optional[str]
            The AWS region for the Lambda function. Uses default if not provided.

        role : typing.Optional[str]
            The AWS IAM role ARN for the Lambda function. Uses default if not provided.

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

        Returns
        -------
        None

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.metrics.custom.update_lambda(
            id=1,
            code="code",
        )
        """
        _response = self._raw_client.update_lambda(
            id, code=code, region=region, role=role, request_options=request_options
        )
        return _response.data

    def logs(
        self,
        id: int,
        *,
        end_date: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        start_date: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        <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 AWS lambda logs for project, including filtering by start and end dates

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

        end_date : typing.Optional[str]
            End date for AWS logs filtering in format %Y-%m-%d

        limit : typing.Optional[int]
            Limit the number of logs to return

        start_date : typing.Optional[str]
            Start date for AWS logs filtering in format %Y-%m-%d

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

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful response returns list of AWS lambda logs

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.metrics.custom.logs(
            id=1,
        )
        """
        _response = self._raw_client.logs(
            id, end_date=end_date, limit=limit, start_date=start_date, request_options=request_options
        )
        return _response.data

    def check_function(self, id: int, *, code: str, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        <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>
        Validate custom matching function code for the project.

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

        code : str

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

        Returns
        -------
        None

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

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


class AsyncCustomClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawCustomClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawCustomClient
        """
        return self._raw_client

    async def get_lambda(
        self, id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetLambdaCustomResponse:
        """
        <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 AWS Lambda code for the custom metric configured for this project.

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

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

        Returns
        -------
        GetLambdaCustomResponse
            Lambda code and deployment status

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def update_lambda(
        self,
        id: int,
        *,
        code: str,
        region: typing.Optional[str] = OMIT,
        role: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        <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>
        Create or update the AWS Lambda function used for custom metrics in this project.

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

        code : str
            The Python code for the custom metric function.

        region : typing.Optional[str]
            The AWS region for the Lambda function. Uses default if not provided.

        role : typing.Optional[str]
            The AWS IAM role ARN for the Lambda function. Uses default if not provided.

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.metrics.custom.update_lambda(
                id=1,
                code="code",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_lambda(
            id, code=code, region=region, role=role, request_options=request_options
        )
        return _response.data

    async def logs(
        self,
        id: int,
        *,
        end_date: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        start_date: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        <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 AWS lambda logs for project, including filtering by start and end dates

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

        end_date : typing.Optional[str]
            End date for AWS logs filtering in format %Y-%m-%d

        limit : typing.Optional[int]
            Limit the number of logs to return

        start_date : typing.Optional[str]
            Start date for AWS logs filtering in format %Y-%m-%d

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

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful response returns list of AWS lambda logs

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.logs(
            id, end_date=end_date, limit=limit, start_date=start_date, request_options=request_options
        )
        return _response.data

    async def check_function(
        self, id: int, *, code: str, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        <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>
        Validate custom matching function code for the project.

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

        code : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.metrics.custom.check_function(
                id=1,
                code="code",
            )


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