# This file was auto-generated by Fern from our API Definition.

import typing
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.request_options import RequestOptions
from ..core.unchecked_base_model import construct_type
from ..types.lse_project import LseProject
from ..types.project_template import ProjectTemplate

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


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

    def list(
        self, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[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
        -------
        HttpResponse[typing.List[ProjectTemplate]]

        """
        _response = self._client_wrapper.httpx_client.request(
            "api/project-templates/",
            method="GET",
            params={
                "ordering": ordering,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[ProjectTemplate],
                    construct_type(
                        type_=typing.List[ProjectTemplate],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> HttpResponse[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
        -------
        HttpResponse[ProjectTemplate]

        """
        _response = self._client_wrapper.httpx_client.request(
            "api/project-templates/",
            method="POST",
            json={
                "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,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ProjectTemplate,
                    construct_type(
                        type_=ProjectTemplate,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[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
        -------
        HttpResponse[ProjectTemplate]

        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/project-templates/{jsonable_encoder(id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ProjectTemplate,
                    construct_type(
                        type_=ProjectTemplate,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[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
        -------
        HttpResponse[None]
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/project-templates/{jsonable_encoder(id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return HttpResponse(response=_response, data=None)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> HttpResponse[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
        -------
        HttpResponse[ProjectTemplate]

        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/project-templates/{jsonable_encoder(id)}",
            method="PATCH",
            json={
                "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,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ProjectTemplate,
                    construct_type(
                        type_=ProjectTemplate,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def create_project_from_template(
        self,
        id: int,
        *,
        title: str,
        workspace_id: int,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[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
        -------
        HttpResponse[LseProject]
            Project created successfully
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/project-templates/{jsonable_encoder(id)}/create-project",
            method="POST",
            json={
                "description": description,
                "title": title,
                "workspace_id": workspace_id,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    LseProject,
                    construct_type(
                        type_=LseProject,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


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

    async def list(
        self, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[typing.List[ProjectTemplate]]

        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/project-templates/",
            method="GET",
            params={
                "ordering": ordering,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[ProjectTemplate],
                    construct_type(
                        type_=typing.List[ProjectTemplate],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[ProjectTemplate]

        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/project-templates/",
            method="POST",
            json={
                "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,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ProjectTemplate,
                    construct_type(
                        type_=ProjectTemplate,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def get(
        self, id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[ProjectTemplate]

        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/project-templates/{jsonable_encoder(id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ProjectTemplate,
                    construct_type(
                        type_=ProjectTemplate,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def delete(
        self, id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[None]
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/project-templates/{jsonable_encoder(id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return AsyncHttpResponse(response=_response, data=None)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[ProjectTemplate]

        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/project-templates/{jsonable_encoder(id)}",
            method="PATCH",
            json={
                "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,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ProjectTemplate,
                    construct_type(
                        type_=ProjectTemplate,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[LseProject]
            Project created successfully
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/project-templates/{jsonable_encoder(id)}/create-project",
            method="POST",
            json={
                "description": description,
                "title": title,
                "workspace_id": workspace_id,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    LseProject,
                    construct_type(
                        type_=LseProject,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
