# 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.view import View
from .raw_client import AsyncRawViewsClient, RawViewsClient
from .types.create_views_request_data import CreateViewsRequestData
from .types.update_views_request_data import UpdateViewsRequestData

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


class ViewsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawViewsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawViewsClient
        """
        return self._raw_client

    def list(
        self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[View]:
        """
        List all views for a specific project.

        Parameters
        ----------
        project : typing.Optional[int]
            Project ID

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

        Returns
        -------
        typing.List[View]


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

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

    def create(
        self,
        *,
        data: typing.Optional[CreateViewsRequestData] = OMIT,
        project: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> View:
        """
        Create a view for a specific project.

        Parameters
        ----------
        data : typing.Optional[CreateViewsRequestData]
            Custom view data

        project : typing.Optional[int]
            Project ID

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

        Returns
        -------
        View


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.views.create()
        """
        _response = self._raw_client.create(data=data, project=project, request_options=request_options)
        return _response.data

    def update_order(
        self, *, ids: typing.Sequence[int], project: int, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Update the order field of views based on the provided list of view IDs

        Parameters
        ----------
        ids : typing.Sequence[int]
            A list of view IDs in the desired order.

        project : int

        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.views.update_order(
            ids=[1],
            project=1,
        )
        """
        _response = self._raw_client.update_order(ids=ids, project=project, request_options=request_options)
        return _response.data

    def delete_all(self, *, project: int, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete all views for a specific project.

        Parameters
        ----------
        project : int
            Project ID

        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.views.delete_all(
            project=1,
        )
        """
        _response = self._raw_client.delete_all(project=project, request_options=request_options)
        return _response.data

    def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> View:
        """
        Get the details about a specific view in the data manager

        Parameters
        ----------
        id : str
            View ID

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

        Returns
        -------
        View


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.views.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:
        """
        Delete a specific view by ID.

        Parameters
        ----------
        id : str
            View ID

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

    def update(
        self,
        id: str,
        *,
        data: typing.Optional[UpdateViewsRequestData] = OMIT,
        project: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> View:
        """
        Update view data with additional filters and other information for a specific project.

        Parameters
        ----------
        id : str
            View ID

        data : typing.Optional[UpdateViewsRequestData]
            Custom view data

        project : typing.Optional[int]
            Project ID

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

        Returns
        -------
        View


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.views.update(
            id="id",
        )
        """
        _response = self._raw_client.update(id, data=data, project=project, request_options=request_options)
        return _response.data


class AsyncViewsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawViewsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawViewsClient
        """
        return self._raw_client

    async def list(
        self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[View]:
        """
        List all views for a specific project.

        Parameters
        ----------
        project : typing.Optional[int]
            Project ID

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

        Returns
        -------
        typing.List[View]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def create(
        self,
        *,
        data: typing.Optional[CreateViewsRequestData] = OMIT,
        project: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> View:
        """
        Create a view for a specific project.

        Parameters
        ----------
        data : typing.Optional[CreateViewsRequestData]
            Custom view data

        project : typing.Optional[int]
            Project ID

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

        Returns
        -------
        View


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def update_order(
        self, *, ids: typing.Sequence[int], project: int, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Update the order field of views based on the provided list of view IDs

        Parameters
        ----------
        ids : typing.Sequence[int]
            A list of view IDs in the desired order.

        project : int

        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.views.update_order(
                ids=[1],
                project=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_order(ids=ids, project=project, request_options=request_options)
        return _response.data

    async def delete_all(self, *, project: int, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete all views for a specific project.

        Parameters
        ----------
        project : int
            Project ID

        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.views.delete_all(
                project=1,
            )


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

    async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> View:
        """
        Get the details about a specific view in the data manager

        Parameters
        ----------
        id : str
            View ID

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

        Returns
        -------
        View


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.views.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:
        """
        Delete a specific view by ID.

        Parameters
        ----------
        id : str
            View ID

        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.views.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,
        *,
        data: typing.Optional[UpdateViewsRequestData] = OMIT,
        project: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> View:
        """
        Update view data with additional filters and other information for a specific project.

        Parameters
        ----------
        id : str
            View ID

        data : typing.Optional[UpdateViewsRequestData]
            Custom view data

        project : typing.Optional[int]
            Project ID

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

        Returns
        -------
        View


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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