# 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.project import Project
from ..types.project_delete_response import ProjectDeleteResponse
from .raw_client import AsyncRawProjectsClient, RawProjectsClient

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


class ProjectsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawProjectsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawProjectsClient
        """
        return self._raw_client

    def list_projects(
        self,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Project]:
        """
        Returns all projects for the authenticated user

        Parameters
        ----------
        skip : typing.Optional[int]
            Number of projects to skip

        limit : typing.Optional[int]
            Maximum number of projects to return

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

        Returns
        -------
        typing.List[Project]
            List of projects

        Examples
        --------
        from tropicalia import tropicalia

        client = tropicalia(
            token="YOUR_TOKEN",
        )
        client.projects.list_projects()
        """
        _response = self._raw_client.list_projects(skip=skip, limit=limit, request_options=request_options)
        return _response.data

    def create_project(
        self,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Project:
        """
        Create a new project

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

        description : typing.Optional[str]

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

        Returns
        -------
        Project
            Project created

        Examples
        --------
        from tropicalia import tropicalia

        client = tropicalia(
            token="YOUR_TOKEN",
        )
        client.projects.create_project(
            name="Tropical Rainforest Conservation",
            description="A project focused on preserving tropical rainforest biodiversity.",
        )
        """
        _response = self._raw_client.create_project(name=name, description=description, request_options=request_options)
        return _response.data

    def get_project(self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Project:
        """
        Returns a specific project by ID

        Parameters
        ----------
        project_id : str

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

        Returns
        -------
        Project
            Project details

        Examples
        --------
        from tropicalia import tropicalia

        client = tropicalia(
            token="YOUR_TOKEN",
        )
        client.projects.get_project(
            project_id="proj_9f8b7c6d",
        )
        """
        _response = self._raw_client.get_project(project_id, request_options=request_options)
        return _response.data

    def update_project(
        self,
        project_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Project:
        """
        Update a project by ID

        Parameters
        ----------
        project_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

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

        Returns
        -------
        Project
            Project updated

        Examples
        --------
        from tropicalia import tropicalia

        client = tropicalia(
            token="YOUR_TOKEN",
        )
        client.projects.update_project(
            project_id="proj_9f8b7c6d",
            name="Tropical Rainforest Conservation",
            description="A project focused on preserving the biodiversity of tropical rainforests.",
        )
        """
        _response = self._raw_client.update_project(
            project_id, name=name, description=description, request_options=request_options
        )
        return _response.data

    def delete_project(
        self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ProjectDeleteResponse:
        """
        Delete a project and all its documents

        Parameters
        ----------
        project_id : str

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

        Returns
        -------
        ProjectDeleteResponse
            Project deleted

        Examples
        --------
        from tropicalia import tropicalia

        client = tropicalia(
            token="YOUR_TOKEN",
        )
        client.projects.delete_project(
            project_id="proj_9f8d7c2a",
        )
        """
        _response = self._raw_client.delete_project(project_id, request_options=request_options)
        return _response.data


class AsyncProjectsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawProjectsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawProjectsClient
        """
        return self._raw_client

    async def list_projects(
        self,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Project]:
        """
        Returns all projects for the authenticated user

        Parameters
        ----------
        skip : typing.Optional[int]
            Number of projects to skip

        limit : typing.Optional[int]
            Maximum number of projects to return

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

        Returns
        -------
        typing.List[Project]
            List of projects

        Examples
        --------
        import asyncio

        from tropicalia import Asynctropicalia

        client = Asynctropicalia(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.projects.list_projects()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_projects(skip=skip, limit=limit, request_options=request_options)
        return _response.data

    async def create_project(
        self,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Project:
        """
        Create a new project

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

        description : typing.Optional[str]

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

        Returns
        -------
        Project
            Project created

        Examples
        --------
        import asyncio

        from tropicalia import Asynctropicalia

        client = Asynctropicalia(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.projects.create_project(
                name="Tropical Rainforest Conservation",
                description="A project focused on preserving tropical rainforest biodiversity.",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_project(
            name=name, description=description, request_options=request_options
        )
        return _response.data

    async def get_project(self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Project:
        """
        Returns a specific project by ID

        Parameters
        ----------
        project_id : str

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

        Returns
        -------
        Project
            Project details

        Examples
        --------
        import asyncio

        from tropicalia import Asynctropicalia

        client = Asynctropicalia(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.projects.get_project(
                project_id="proj_9f8b7c6d",
            )


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

    async def update_project(
        self,
        project_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Project:
        """
        Update a project by ID

        Parameters
        ----------
        project_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

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

        Returns
        -------
        Project
            Project updated

        Examples
        --------
        import asyncio

        from tropicalia import Asynctropicalia

        client = Asynctropicalia(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.projects.update_project(
                project_id="proj_9f8b7c6d",
                name="Tropical Rainforest Conservation",
                description="A project focused on preserving the biodiversity of tropical rainforests.",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_project(
            project_id, name=name, description=description, request_options=request_options
        )
        return _response.data

    async def delete_project(
        self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ProjectDeleteResponse:
        """
        Delete a project and all its documents

        Parameters
        ----------
        project_id : str

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

        Returns
        -------
        ProjectDeleteResponse
            Project deleted

        Examples
        --------
        import asyncio

        from tropicalia import Asynctropicalia

        client = Asynctropicalia(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.projects.delete_project(
                project_id="proj_9f8d7c2a",
            )


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