# 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 ..types.model_provider_connection import ModelProviderConnection
from ..types.provider_enum import ProviderEnum
from ..types.scope_enum import ScopeEnum
from .raw_client import AsyncRawModelProvidersClient, RawModelProvidersClient
from .types.list_model_provider_choices_model_providers_response import ListModelProviderChoicesModelProvidersResponse

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


class ModelProvidersClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawModelProvidersClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawModelProvidersClient
        """
        return self._raw_client

    def list(
        self, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ModelProviderConnection]:
        """
        <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>
        List all model provider connections.

        Parameters
        ----------
        ordering : typing.Optional[str]
            Which field to use when ordering the results.

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

        Returns
        -------
        typing.List[ModelProviderConnection]


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.model_providers.list()
        """
        _response = self._raw_client.list(ordering=ordering, request_options=request_options)
        return _response.data

    def create(
        self,
        *,
        api_key: typing.Optional[str] = OMIT,
        auth_token: typing.Optional[str] = OMIT,
        budget_alert_threshold: typing.Optional[float] = OMIT,
        cached_available_models: typing.Optional[str] = OMIT,
        deployment_name: typing.Optional[str] = OMIT,
        endpoint: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_location: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        is_internal: typing.Optional[bool] = OMIT,
        provider: typing.Optional[ProviderEnum] = OMIT,
        scope: typing.Optional[ScopeEnum] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelProviderConnection:
        """
        <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 a new model provider connection.

        Parameters
        ----------
        api_key : typing.Optional[str]
            Model provider API key

        auth_token : typing.Optional[str]
            Model provider Auth token

        budget_alert_threshold : typing.Optional[float]
            Budget alert threshold for the given provider connection

        cached_available_models : typing.Optional[str]
            List of available models from the provider

        deployment_name : typing.Optional[str]
            Azure OpenAI deployment name

        endpoint : typing.Optional[str]
            Azure OpenAI endpoint

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file

        google_location : typing.Optional[str]
            Google project location

        google_project_id : typing.Optional[str]
            Google project ID

        is_internal : typing.Optional[bool]
            Whether the model provider connection is internal, not visible to the user

        provider : typing.Optional[ProviderEnum]

        scope : typing.Optional[ScopeEnum]

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

        Returns
        -------
        ModelProviderConnection


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.model_providers.create()
        """
        _response = self._raw_client.create(
            api_key=api_key,
            auth_token=auth_token,
            budget_alert_threshold=budget_alert_threshold,
            cached_available_models=cached_available_models,
            deployment_name=deployment_name,
            endpoint=endpoint,
            google_application_credentials=google_application_credentials,
            google_location=google_location,
            google_project_id=google_project_id,
            is_internal=is_internal,
            provider=provider,
            scope=scope,
            request_options=request_options,
        )
        return _response.data

    def list_model_provider_choices(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ListModelProviderChoicesModelProvidersResponse:
        """
        <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>
        List all possible model provider choices

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

        Returns
        -------
        ListModelProviderChoicesModelProvidersResponse
            List of model provider choices

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.model_providers.list_model_provider_choices()
        """
        _response = self._raw_client.list_model_provider_choices(request_options=request_options)
        return _response.data

    def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ModelProviderConnection:
        """
        <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>
        Retrieve a specific model provider connection.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        ModelProviderConnection


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

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

    def delete(self, id: 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>
        Delete a model provider connection by ID

        Parameters
        ----------
        id : 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.model_providers.delete(
            id="id",
        )
        """
        _response = self._raw_client.delete(id, request_options=request_options)
        return _response.data

    def update(
        self,
        id: str,
        *,
        api_key: typing.Optional[str] = OMIT,
        auth_token: typing.Optional[str] = OMIT,
        budget_alert_threshold: typing.Optional[float] = OMIT,
        cached_available_models: typing.Optional[str] = OMIT,
        deployment_name: typing.Optional[str] = OMIT,
        endpoint: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_location: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        is_internal: typing.Optional[bool] = OMIT,
        provider: typing.Optional[ProviderEnum] = OMIT,
        scope: typing.Optional[ScopeEnum] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelProviderConnection:
        """
        <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 a specific model provider connection by ID.

        Parameters
        ----------
        id : str

        api_key : typing.Optional[str]
            Model provider API key

        auth_token : typing.Optional[str]
            Model provider Auth token

        budget_alert_threshold : typing.Optional[float]
            Budget alert threshold for the given provider connection

        cached_available_models : typing.Optional[str]
            List of available models from the provider

        deployment_name : typing.Optional[str]
            Azure OpenAI deployment name

        endpoint : typing.Optional[str]
            Azure OpenAI endpoint

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file

        google_location : typing.Optional[str]
            Google project location

        google_project_id : typing.Optional[str]
            Google project ID

        is_internal : typing.Optional[bool]
            Whether the model provider connection is internal, not visible to the user

        provider : typing.Optional[ProviderEnum]

        scope : typing.Optional[ScopeEnum]

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

        Returns
        -------
        ModelProviderConnection


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.model_providers.update(
            id="id",
        )
        """
        _response = self._raw_client.update(
            id,
            api_key=api_key,
            auth_token=auth_token,
            budget_alert_threshold=budget_alert_threshold,
            cached_available_models=cached_available_models,
            deployment_name=deployment_name,
            endpoint=endpoint,
            google_application_credentials=google_application_credentials,
            google_location=google_location,
            google_project_id=google_project_id,
            is_internal=is_internal,
            provider=provider,
            scope=scope,
            request_options=request_options,
        )
        return _response.data


class AsyncModelProvidersClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawModelProvidersClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawModelProvidersClient
        """
        return self._raw_client

    async def list(
        self, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ModelProviderConnection]:
        """
        <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>
        List all model provider connections.

        Parameters
        ----------
        ordering : typing.Optional[str]
            Which field to use when ordering the results.

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

        Returns
        -------
        typing.List[ModelProviderConnection]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.list()


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

    async def create(
        self,
        *,
        api_key: typing.Optional[str] = OMIT,
        auth_token: typing.Optional[str] = OMIT,
        budget_alert_threshold: typing.Optional[float] = OMIT,
        cached_available_models: typing.Optional[str] = OMIT,
        deployment_name: typing.Optional[str] = OMIT,
        endpoint: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_location: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        is_internal: typing.Optional[bool] = OMIT,
        provider: typing.Optional[ProviderEnum] = OMIT,
        scope: typing.Optional[ScopeEnum] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelProviderConnection:
        """
        <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 a new model provider connection.

        Parameters
        ----------
        api_key : typing.Optional[str]
            Model provider API key

        auth_token : typing.Optional[str]
            Model provider Auth token

        budget_alert_threshold : typing.Optional[float]
            Budget alert threshold for the given provider connection

        cached_available_models : typing.Optional[str]
            List of available models from the provider

        deployment_name : typing.Optional[str]
            Azure OpenAI deployment name

        endpoint : typing.Optional[str]
            Azure OpenAI endpoint

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file

        google_location : typing.Optional[str]
            Google project location

        google_project_id : typing.Optional[str]
            Google project ID

        is_internal : typing.Optional[bool]
            Whether the model provider connection is internal, not visible to the user

        provider : typing.Optional[ProviderEnum]

        scope : typing.Optional[ScopeEnum]

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

        Returns
        -------
        ModelProviderConnection


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.create()


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            api_key=api_key,
            auth_token=auth_token,
            budget_alert_threshold=budget_alert_threshold,
            cached_available_models=cached_available_models,
            deployment_name=deployment_name,
            endpoint=endpoint,
            google_application_credentials=google_application_credentials,
            google_location=google_location,
            google_project_id=google_project_id,
            is_internal=is_internal,
            provider=provider,
            scope=scope,
            request_options=request_options,
        )
        return _response.data

    async def list_model_provider_choices(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ListModelProviderChoicesModelProvidersResponse:
        """
        <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>
        List all possible model provider choices

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

        Returns
        -------
        ListModelProviderChoicesModelProvidersResponse
            List of model provider choices

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.list_model_provider_choices()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_model_provider_choices(request_options=request_options)
        return _response.data

    async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ModelProviderConnection:
        """
        <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>
        Retrieve a specific model provider connection.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        ModelProviderConnection


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.get(
                id="id",
            )


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

    async def delete(self, id: 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>
        Delete a model provider connection by ID

        Parameters
        ----------
        id : 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.model_providers.delete(
                id="id",
            )


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

    async def update(
        self,
        id: str,
        *,
        api_key: typing.Optional[str] = OMIT,
        auth_token: typing.Optional[str] = OMIT,
        budget_alert_threshold: typing.Optional[float] = OMIT,
        cached_available_models: typing.Optional[str] = OMIT,
        deployment_name: typing.Optional[str] = OMIT,
        endpoint: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_location: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        is_internal: typing.Optional[bool] = OMIT,
        provider: typing.Optional[ProviderEnum] = OMIT,
        scope: typing.Optional[ScopeEnum] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelProviderConnection:
        """
        <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 a specific model provider connection by ID.

        Parameters
        ----------
        id : str

        api_key : typing.Optional[str]
            Model provider API key

        auth_token : typing.Optional[str]
            Model provider Auth token

        budget_alert_threshold : typing.Optional[float]
            Budget alert threshold for the given provider connection

        cached_available_models : typing.Optional[str]
            List of available models from the provider

        deployment_name : typing.Optional[str]
            Azure OpenAI deployment name

        endpoint : typing.Optional[str]
            Azure OpenAI endpoint

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file

        google_location : typing.Optional[str]
            Google project location

        google_project_id : typing.Optional[str]
            Google project ID

        is_internal : typing.Optional[bool]
            Whether the model provider connection is internal, not visible to the user

        provider : typing.Optional[ProviderEnum]

        scope : typing.Optional[ScopeEnum]

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

        Returns
        -------
        ModelProviderConnection


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.update(
                id="id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            id,
            api_key=api_key,
            auth_token=auth_token,
            budget_alert_threshold=budget_alert_threshold,
            cached_available_models=cached_available_models,
            deployment_name=deployment_name,
            endpoint=endpoint,
            google_application_credentials=google_application_credentials,
            google_location=google_location,
            google_project_id=google_project_id,
            is_internal=is_internal,
            provider=provider,
            scope=scope,
            request_options=request_options,
        )
        return _response.data
