# 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.lsejwt_settings import LsejwtSettings
from .raw_client import AsyncRawJwtSettingsClient, RawJwtSettingsClient

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


class JwtSettingsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawJwtSettingsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawJwtSettingsClient
        """
        return self._raw_client

    def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> LsejwtSettings:
        """
        Retrieve JWT settings for the currently active organization.

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

        Returns
        -------
        LsejwtSettings


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

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

    def update(
        self,
        *,
        api_token_ttl_days: int,
        api_tokens_enabled: typing.Optional[bool] = OMIT,
        legacy_api_tokens_enabled: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LsejwtSettings:
        """
        Update JWT settings for the currently active organization.

        Parameters
        ----------
        api_token_ttl_days : int

        api_tokens_enabled : typing.Optional[bool]
            Enable JWT API token authentication for this organization

        legacy_api_tokens_enabled : typing.Optional[bool]
            Enable legacy API token authentication for this organization

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

        Returns
        -------
        LsejwtSettings


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.jwt_settings.update(
            api_token_ttl_days=1,
        )
        """
        _response = self._raw_client.update(
            api_token_ttl_days=api_token_ttl_days,
            api_tokens_enabled=api_tokens_enabled,
            legacy_api_tokens_enabled=legacy_api_tokens_enabled,
            request_options=request_options,
        )
        return _response.data


class AsyncJwtSettingsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawJwtSettingsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawJwtSettingsClient
        """
        return self._raw_client

    async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> LsejwtSettings:
        """
        Retrieve JWT settings for the currently active organization.

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

        Returns
        -------
        LsejwtSettings


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.jwt_settings.get()


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

    async def update(
        self,
        *,
        api_token_ttl_days: int,
        api_tokens_enabled: typing.Optional[bool] = OMIT,
        legacy_api_tokens_enabled: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LsejwtSettings:
        """
        Update JWT settings for the currently active organization.

        Parameters
        ----------
        api_token_ttl_days : int

        api_tokens_enabled : typing.Optional[bool]
            Enable JWT API token authentication for this organization

        legacy_api_tokens_enabled : typing.Optional[bool]
            Enable legacy API token authentication for this organization

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

        Returns
        -------
        LsejwtSettings


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.jwt_settings.update(
                api_token_ttl_days=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            api_token_ttl_days=api_token_ttl_days,
            api_tokens_enabled=api_tokens_enabled,
            legacy_api_tokens_enabled=legacy_api_tokens_enabled,
            request_options=request_options,
        )
        return _response.data
