# 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.session_timeout_policy import SessionTimeoutPolicy
from .raw_client import AsyncRawSessionPolicyClient, RawSessionPolicyClient

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


class SessionPolicyClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawSessionPolicyClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawSessionPolicyClient
        """
        return self._raw_client

    def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> SessionTimeoutPolicy:
        """
        Retrieve session timeout policy for the currently active organization.

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

        Returns
        -------
        SessionTimeoutPolicy


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

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

    def update(
        self,
        *,
        max_session_age: typing.Optional[int] = OMIT,
        max_time_between_activity: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SessionTimeoutPolicy:
        """
        Update session timeout policy for the currently active organization.

        Parameters
        ----------
        max_session_age : typing.Optional[int]
            Number of minutes that a session can be active before needing to re-login

        max_time_between_activity : typing.Optional[int]
            Number of minutes that a session stays active without any activity

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

        Returns
        -------
        SessionTimeoutPolicy


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.session_policy.update()
        """
        _response = self._raw_client.update(
            max_session_age=max_session_age,
            max_time_between_activity=max_time_between_activity,
            request_options=request_options,
        )
        return _response.data


class AsyncSessionPolicyClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawSessionPolicyClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawSessionPolicyClient
        """
        return self._raw_client

    async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> SessionTimeoutPolicy:
        """
        Retrieve session timeout policy for the currently active organization.

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

        Returns
        -------
        SessionTimeoutPolicy


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def update(
        self,
        *,
        max_session_age: typing.Optional[int] = OMIT,
        max_time_between_activity: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SessionTimeoutPolicy:
        """
        Update session timeout policy for the currently active organization.

        Parameters
        ----------
        max_session_age : typing.Optional[int]
            Number of minutes that a session can be active before needing to re-login

        max_time_between_activity : typing.Optional[int]
            Number of minutes that a session stays active without any activity

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

        Returns
        -------
        SessionTimeoutPolicy


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.session_policy.update()


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            max_session_age=max_session_age,
            max_time_between_activity=max_time_between_activity,
            request_options=request_options,
        )
        return _response.data
