# 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 .raw_client import AsyncRawProjectsClient, RawProjectsClient
from .types.projects_create_eval_prompt_response import ProjectsCreateEvalPromptResponse
from .types.projects_create_response import ProjectsCreateResponse
from .types.projects_delete_response import ProjectsDeleteResponse
from .types.projects_get_response import ProjectsGetResponse
from .types.projects_list_eval_prompts_response import ProjectsListEvalPromptsResponse
from .types.projects_list_response import ProjectsListResponse
from .types.projects_update_response import ProjectsUpdateResponse

# 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(self, *, request_options: typing.Optional[RequestOptions] = None) -> ProjectsListResponse:
        """
        Returns all projects in a workspace.

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

        Returns
        -------
        ProjectsListResponse
            Success response

        Examples
        --------
        from phonic import Phonic

        client = Phonic(
            token="YOUR_TOKEN",
        )
        client.projects.list()
        """
        _response = self._raw_client.list(request_options=request_options)
        return _response.data

    def create(self, *, name: str, request_options: typing.Optional[RequestOptions] = None) -> ProjectsCreateResponse:
        """
        Creates a new project in a workspace.

        Parameters
        ----------
        name : str
            The name of the project. Can only contain lowercase letters, numbers and hyphens. Must be unique within the workspace.

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

        Returns
        -------
        ProjectsCreateResponse
            Success response

        Examples
        --------
        from phonic import Phonic

        client = Phonic(
            token="YOUR_TOKEN",
        )
        client.projects.create(
            name="customer-support",
        )
        """
        _response = self._raw_client.create(name=name, request_options=request_options)
        return _response.data

    def get(self, name_or_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ProjectsGetResponse:
        """
        Returns a project by name or ID.

        Parameters
        ----------
        name_or_id : str
            The name or the ID of the project to get.

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

        Returns
        -------
        ProjectsGetResponse
            Success response

        Examples
        --------
        from phonic import Phonic

        client = Phonic(
            token="YOUR_TOKEN",
        )
        client.projects.get(
            name_or_id="nameOrId",
        )
        """
        _response = self._raw_client.get(name_or_id, request_options=request_options)
        return _response.data

    def delete(
        self, name_or_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ProjectsDeleteResponse:
        """
        Deletes a project by name or ID.

        Parameters
        ----------
        name_or_id : str
            The name or the ID of the project to delete.

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

        Returns
        -------
        ProjectsDeleteResponse
            Success response

        Examples
        --------
        from phonic import Phonic

        client = Phonic(
            token="YOUR_TOKEN",
        )
        client.projects.delete(
            name_or_id="nameOrId",
        )
        """
        _response = self._raw_client.delete(name_or_id, request_options=request_options)
        return _response.data

    def update(
        self,
        name_or_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        default_agent: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ProjectsUpdateResponse:
        """
        Updates a project by name or ID.

        Parameters
        ----------
        name_or_id : str
            The name or the ID of the project to update.

        name : typing.Optional[str]
            The name of the project. Can only contain lowercase letters, numbers and hyphens. Must be unique within the workspace.

        default_agent : typing.Optional[str]

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

        Returns
        -------
        ProjectsUpdateResponse
            Success response

        Examples
        --------
        from phonic import Phonic

        client = Phonic(
            token="YOUR_TOKEN",
        )
        client.projects.update(
            name_or_id="nameOrId",
            name="updated-customer-support",
            default_agent="another-agent",
        )
        """
        _response = self._raw_client.update(
            name_or_id, name=name, default_agent=default_agent, request_options=request_options
        )
        return _response.data

    def list_eval_prompts(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ProjectsListEvalPromptsResponse:
        """
        Returns all conversation evaluation prompts for a project.

        Parameters
        ----------
        id : str
            The ID of the project.

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

        Returns
        -------
        ProjectsListEvalPromptsResponse
            Success response

        Examples
        --------
        from phonic import Phonic

        client = Phonic(
            token="YOUR_TOKEN",
        )
        client.projects.list_eval_prompts(
            id="id",
        )
        """
        _response = self._raw_client.list_eval_prompts(id, request_options=request_options)
        return _response.data

    def create_eval_prompt(
        self, id: str, *, name: str, prompt: str, request_options: typing.Optional[RequestOptions] = None
    ) -> ProjectsCreateEvalPromptResponse:
        """
        Creates a new conversation evaluation prompt for a project.

        Parameters
        ----------
        id : str
            The ID of the project.

        name : str
            A useful name for referring to this prompt.

        prompt : str
            Actual evaluation prompt text to evaluate conversations with.

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

        Returns
        -------
        ProjectsCreateEvalPromptResponse
            Success response

        Examples
        --------
        from phonic import Phonic

        client = Phonic(
            token="YOUR_TOKEN",
        )
        client.projects.create_eval_prompt(
            id="id",
            name="test_prompt",
            prompt="The assistant used the word chocolate in the conversation",
        )
        """
        _response = self._raw_client.create_eval_prompt(id, name=name, prompt=prompt, 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(self, *, request_options: typing.Optional[RequestOptions] = None) -> ProjectsListResponse:
        """
        Returns all projects in a workspace.

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

        Returns
        -------
        ProjectsListResponse
            Success response

        Examples
        --------
        import asyncio

        from phonic import AsyncPhonic

        client = AsyncPhonic(
            token="YOUR_TOKEN",
        )


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


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

    async def create(
        self, *, name: str, request_options: typing.Optional[RequestOptions] = None
    ) -> ProjectsCreateResponse:
        """
        Creates a new project in a workspace.

        Parameters
        ----------
        name : str
            The name of the project. Can only contain lowercase letters, numbers and hyphens. Must be unique within the workspace.

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

        Returns
        -------
        ProjectsCreateResponse
            Success response

        Examples
        --------
        import asyncio

        from phonic import AsyncPhonic

        client = AsyncPhonic(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.projects.create(
                name="customer-support",
            )


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

    async def get(
        self, name_or_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ProjectsGetResponse:
        """
        Returns a project by name or ID.

        Parameters
        ----------
        name_or_id : str
            The name or the ID of the project to get.

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

        Returns
        -------
        ProjectsGetResponse
            Success response

        Examples
        --------
        import asyncio

        from phonic import AsyncPhonic

        client = AsyncPhonic(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.projects.get(
                name_or_id="nameOrId",
            )


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

    async def delete(
        self, name_or_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ProjectsDeleteResponse:
        """
        Deletes a project by name or ID.

        Parameters
        ----------
        name_or_id : str
            The name or the ID of the project to delete.

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

        Returns
        -------
        ProjectsDeleteResponse
            Success response

        Examples
        --------
        import asyncio

        from phonic import AsyncPhonic

        client = AsyncPhonic(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.projects.delete(
                name_or_id="nameOrId",
            )


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

    async def update(
        self,
        name_or_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        default_agent: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ProjectsUpdateResponse:
        """
        Updates a project by name or ID.

        Parameters
        ----------
        name_or_id : str
            The name or the ID of the project to update.

        name : typing.Optional[str]
            The name of the project. Can only contain lowercase letters, numbers and hyphens. Must be unique within the workspace.

        default_agent : typing.Optional[str]

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

        Returns
        -------
        ProjectsUpdateResponse
            Success response

        Examples
        --------
        import asyncio

        from phonic import AsyncPhonic

        client = AsyncPhonic(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.projects.update(
                name_or_id="nameOrId",
                name="updated-customer-support",
                default_agent="another-agent",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            name_or_id, name=name, default_agent=default_agent, request_options=request_options
        )
        return _response.data

    async def list_eval_prompts(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ProjectsListEvalPromptsResponse:
        """
        Returns all conversation evaluation prompts for a project.

        Parameters
        ----------
        id : str
            The ID of the project.

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

        Returns
        -------
        ProjectsListEvalPromptsResponse
            Success response

        Examples
        --------
        import asyncio

        from phonic import AsyncPhonic

        client = AsyncPhonic(
            token="YOUR_TOKEN",
        )


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


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

    async def create_eval_prompt(
        self, id: str, *, name: str, prompt: str, request_options: typing.Optional[RequestOptions] = None
    ) -> ProjectsCreateEvalPromptResponse:
        """
        Creates a new conversation evaluation prompt for a project.

        Parameters
        ----------
        id : str
            The ID of the project.

        name : str
            A useful name for referring to this prompt.

        prompt : str
            Actual evaluation prompt text to evaluate conversations with.

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

        Returns
        -------
        ProjectsCreateEvalPromptResponse
            Success response

        Examples
        --------
        import asyncio

        from phonic import AsyncPhonic

        client = AsyncPhonic(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.projects.create_eval_prompt(
                id="id",
                name="test_prompt",
                prompt="The assistant used the word chocolate in the conversation",
            )


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