# 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.lse_project import LseProject
from ..types.project_template import ProjectTemplate
from .raw_client import AsyncRawProjectTemplatesClient, RawProjectTemplatesClient

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


class ProjectTemplatesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawProjectTemplatesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawProjectTemplatesClient
        """
        return self._raw_client

    def list(
        self, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ProjectTemplate]:
        """
        <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 a list of all project templates for an organization.

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

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

        Returns
        -------
        typing.List[ProjectTemplate]


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

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

    def create(
        self,
        *,
        name: str,
        project_id: int,
        assignment_settings: typing.Optional[typing.Any] = OMIT,
        created_by: typing.Optional[int] = OMIT,
        custom_script: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        organization: typing.Optional[int] = OMIT,
        project_settings: typing.Optional[typing.Any] = OMIT,
        require_comment_on_skip: typing.Optional[bool] = OMIT,
        review_settings: typing.Optional[typing.Any] = OMIT,
        show_unused_data_columns_to_annotators: typing.Optional[bool] = OMIT,
        tags: typing.Optional[typing.Any] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ProjectTemplate:
        """
        <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 project template for an organization.

        Parameters
        ----------
        name : str

        project_id : int

        assignment_settings : typing.Optional[typing.Any]
            general dict serialized assignment settings

        created_by : typing.Optional[int]

        custom_script : typing.Optional[str]
            custom script (Plugin) for projects created from this template

        description : typing.Optional[str]

        organization : typing.Optional[int]

        project_settings : typing.Optional[typing.Any]
            general dict serialized project settings

        require_comment_on_skip : typing.Optional[bool]
            flag to require comment on skip

        review_settings : typing.Optional[typing.Any]
            general dict serialized review settings

        show_unused_data_columns_to_annotators : typing.Optional[bool]

        tags : typing.Optional[typing.Any]

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

        Returns
        -------
        ProjectTemplate


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.project_templates.create(
            name="name",
            project_id=1,
        )
        """
        _response = self._raw_client.create(
            name=name,
            project_id=project_id,
            assignment_settings=assignment_settings,
            created_by=created_by,
            custom_script=custom_script,
            description=description,
            organization=organization,
            project_settings=project_settings,
            require_comment_on_skip=require_comment_on_skip,
            review_settings=review_settings,
            show_unused_data_columns_to_annotators=show_unused_data_columns_to_annotators,
            tags=tags,
            request_options=request_options,
        )
        return _response.data

    def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> ProjectTemplate:
        """
        <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 a specific project template by ID for an organization.

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

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

        Returns
        -------
        ProjectTemplate


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

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

    def delete(self, id: int, *, 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 specific project template by ID for an organization.

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

    def update(
        self,
        id: int,
        *,
        assignment_settings: typing.Optional[typing.Any] = OMIT,
        created_by: typing.Optional[int] = OMIT,
        custom_script: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        name: typing.Optional[str] = OMIT,
        organization: typing.Optional[int] = OMIT,
        project_id: typing.Optional[int] = OMIT,
        project_settings: typing.Optional[typing.Any] = OMIT,
        require_comment_on_skip: typing.Optional[bool] = OMIT,
        review_settings: typing.Optional[typing.Any] = OMIT,
        show_unused_data_columns_to_annotators: typing.Optional[bool] = OMIT,
        tags: typing.Optional[typing.Any] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ProjectTemplate:
        """
        <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 the details of a specific project template by ID for an organization.

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

        assignment_settings : typing.Optional[typing.Any]
            general dict serialized assignment settings

        created_by : typing.Optional[int]

        custom_script : typing.Optional[str]
            custom script (Plugin) for projects created from this template

        description : typing.Optional[str]

        name : typing.Optional[str]

        organization : typing.Optional[int]

        project_id : typing.Optional[int]

        project_settings : typing.Optional[typing.Any]
            general dict serialized project settings

        require_comment_on_skip : typing.Optional[bool]
            flag to require comment on skip

        review_settings : typing.Optional[typing.Any]
            general dict serialized review settings

        show_unused_data_columns_to_annotators : typing.Optional[bool]

        tags : typing.Optional[typing.Any]

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

        Returns
        -------
        ProjectTemplate


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.project_templates.update(
            id=1,
        )
        """
        _response = self._raw_client.update(
            id,
            assignment_settings=assignment_settings,
            created_by=created_by,
            custom_script=custom_script,
            description=description,
            name=name,
            organization=organization,
            project_id=project_id,
            project_settings=project_settings,
            require_comment_on_skip=require_comment_on_skip,
            review_settings=review_settings,
            show_unused_data_columns_to_annotators=show_unused_data_columns_to_annotators,
            tags=tags,
            request_options=request_options,
        )
        return _response.data

    def create_project_from_template(
        self,
        id: int,
        *,
        title: str,
        workspace_id: int,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LseProject:
        """
        <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 project from a specific project template by ID for an organization.

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

        title : str
            The title of the project to be created from the template.

        workspace_id : int
            A unique integer value identifying the workspace in which to create the project.

        description : typing.Optional[str]
            A description for the project.

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

        Returns
        -------
        LseProject
            Project created successfully

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.project_templates.create_project_from_template(
            id=1,
            title="title",
            workspace_id=1,
        )
        """
        _response = self._raw_client.create_project_from_template(
            id, title=title, workspace_id=workspace_id, description=description, request_options=request_options
        )
        return _response.data


class AsyncProjectTemplatesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawProjectTemplatesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawProjectTemplatesClient
        """
        return self._raw_client

    async def list(
        self, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ProjectTemplate]:
        """
        <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 a list of all project templates for an organization.

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

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

        Returns
        -------
        typing.List[ProjectTemplate]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def create(
        self,
        *,
        name: str,
        project_id: int,
        assignment_settings: typing.Optional[typing.Any] = OMIT,
        created_by: typing.Optional[int] = OMIT,
        custom_script: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        organization: typing.Optional[int] = OMIT,
        project_settings: typing.Optional[typing.Any] = OMIT,
        require_comment_on_skip: typing.Optional[bool] = OMIT,
        review_settings: typing.Optional[typing.Any] = OMIT,
        show_unused_data_columns_to_annotators: typing.Optional[bool] = OMIT,
        tags: typing.Optional[typing.Any] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ProjectTemplate:
        """
        <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 project template for an organization.

        Parameters
        ----------
        name : str

        project_id : int

        assignment_settings : typing.Optional[typing.Any]
            general dict serialized assignment settings

        created_by : typing.Optional[int]

        custom_script : typing.Optional[str]
            custom script (Plugin) for projects created from this template

        description : typing.Optional[str]

        organization : typing.Optional[int]

        project_settings : typing.Optional[typing.Any]
            general dict serialized project settings

        require_comment_on_skip : typing.Optional[bool]
            flag to require comment on skip

        review_settings : typing.Optional[typing.Any]
            general dict serialized review settings

        show_unused_data_columns_to_annotators : typing.Optional[bool]

        tags : typing.Optional[typing.Any]

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

        Returns
        -------
        ProjectTemplate


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.project_templates.create(
                name="name",
                project_id=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            name=name,
            project_id=project_id,
            assignment_settings=assignment_settings,
            created_by=created_by,
            custom_script=custom_script,
            description=description,
            organization=organization,
            project_settings=project_settings,
            require_comment_on_skip=require_comment_on_skip,
            review_settings=review_settings,
            show_unused_data_columns_to_annotators=show_unused_data_columns_to_annotators,
            tags=tags,
            request_options=request_options,
        )
        return _response.data

    async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> ProjectTemplate:
        """
        <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 a specific project template by ID for an organization.

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

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

        Returns
        -------
        ProjectTemplate


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def delete(self, id: int, *, 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 specific project template by ID for an organization.

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


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

    async def update(
        self,
        id: int,
        *,
        assignment_settings: typing.Optional[typing.Any] = OMIT,
        created_by: typing.Optional[int] = OMIT,
        custom_script: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        name: typing.Optional[str] = OMIT,
        organization: typing.Optional[int] = OMIT,
        project_id: typing.Optional[int] = OMIT,
        project_settings: typing.Optional[typing.Any] = OMIT,
        require_comment_on_skip: typing.Optional[bool] = OMIT,
        review_settings: typing.Optional[typing.Any] = OMIT,
        show_unused_data_columns_to_annotators: typing.Optional[bool] = OMIT,
        tags: typing.Optional[typing.Any] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ProjectTemplate:
        """
        <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 the details of a specific project template by ID for an organization.

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

        assignment_settings : typing.Optional[typing.Any]
            general dict serialized assignment settings

        created_by : typing.Optional[int]

        custom_script : typing.Optional[str]
            custom script (Plugin) for projects created from this template

        description : typing.Optional[str]

        name : typing.Optional[str]

        organization : typing.Optional[int]

        project_id : typing.Optional[int]

        project_settings : typing.Optional[typing.Any]
            general dict serialized project settings

        require_comment_on_skip : typing.Optional[bool]
            flag to require comment on skip

        review_settings : typing.Optional[typing.Any]
            general dict serialized review settings

        show_unused_data_columns_to_annotators : typing.Optional[bool]

        tags : typing.Optional[typing.Any]

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

        Returns
        -------
        ProjectTemplate


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            id,
            assignment_settings=assignment_settings,
            created_by=created_by,
            custom_script=custom_script,
            description=description,
            name=name,
            organization=organization,
            project_id=project_id,
            project_settings=project_settings,
            require_comment_on_skip=require_comment_on_skip,
            review_settings=review_settings,
            show_unused_data_columns_to_annotators=show_unused_data_columns_to_annotators,
            tags=tags,
            request_options=request_options,
        )
        return _response.data

    async def create_project_from_template(
        self,
        id: int,
        *,
        title: str,
        workspace_id: int,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LseProject:
        """
        <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 project from a specific project template by ID for an organization.

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

        title : str
            The title of the project to be created from the template.

        workspace_id : int
            A unique integer value identifying the workspace in which to create the project.

        description : typing.Optional[str]
            A description for the project.

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

        Returns
        -------
        LseProject
            Project created successfully

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.project_templates.create_project_from_template(
                id=1,
                title="title",
                workspace_id=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_project_from_template(
            id, title=title, workspace_id=workspace_id, description=description, request_options=request_options
        )
        return _response.data
