# 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.conversation_tag_response_model import ConversationTagResponseModel
from ....types.get_conversation_tags_page_response_model import GetConversationTagsPageResponseModel
from .raw_client import AsyncRawTagsClient, RawTagsClient

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


class TagsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTagsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawTagsClient
        """
        return self._raw_client

    def assign(
        self,
        conversation_id: str,
        *,
        tag_ids: typing.Sequence[str],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Assign one or more conversation tags to a conversation. Tags that are already assigned are ignored. Tags must belong to the same workspace.

        Parameters
        ----------
        conversation_id : str

        tag_ids : typing.Sequence[str]
            Tag IDs to add to the conversation. Re-assigning an existing tag is a no-op.

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

        Returns
        -------
        None

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.tags.assign(
            conversation_id="conversation_id",
            tag_ids=["tag_ids"],
        )
        """
        _response = self._raw_client.assign(conversation_id, tag_ids=tag_ids, request_options=request_options)
        return _response.data

    def unassign(
        self, conversation_id: str, tag_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Remove a single conversation tag from a conversation.

        Parameters
        ----------
        conversation_id : str

        tag_id : str

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

        Returns
        -------
        None

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.tags.unassign(
            conversation_id="conversation_id",
            tag_id="tag_id",
        )
        """
        _response = self._raw_client.unassign(conversation_id, tag_id, request_options=request_options)
        return _response.data

    def list(
        self,
        *,
        page_size: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetConversationTagsPageResponseModel:
        """
        List conversation tags for the workspace, ordered by most recently created first.

        Parameters
        ----------
        page_size : typing.Optional[int]
            How many conversation tags to return. Can not exceed 100.

        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

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

        Returns
        -------
        GetConversationTagsPageResponseModel
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.tags.list(
            page_size=1,
            cursor="cursor",
        )
        """
        _response = self._raw_client.list(page_size=page_size, cursor=cursor, request_options=request_options)
        return _response.data

    def create(
        self,
        *,
        title: str,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConversationTagResponseModel:
        """
        Create a new conversation tag for the workspace.

        Parameters
        ----------
        title : str
            Display title of the tag.

        description : typing.Optional[str]
            Optional free-text description.

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

        Returns
        -------
        ConversationTagResponseModel
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.tags.create(
            title="title",
        )
        """
        _response = self._raw_client.create(title=title, description=description, request_options=request_options)
        return _response.data

    def get(
        self, tag_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ConversationTagResponseModel:
        """
        Get a conversation tag by ID.

        Parameters
        ----------
        tag_id : str

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

        Returns
        -------
        ConversationTagResponseModel
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.tags.get(
            tag_id="tag_id",
        )
        """
        _response = self._raw_client.get(tag_id, request_options=request_options)
        return _response.data

    def delete(self, tag_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a conversation tag. Restricted to the tag owner or a workspace admin.

        Parameters
        ----------
        tag_id : str

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

        Returns
        -------
        None

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.tags.delete(
            tag_id="tag_id",
        )
        """
        _response = self._raw_client.delete(tag_id, request_options=request_options)
        return _response.data

    def update(
        self,
        tag_id: str,
        *,
        title: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConversationTagResponseModel:
        """
        Update a conversation tag's title and/or description. Restricted to the tag owner or a workspace admin.

        Parameters
        ----------
        tag_id : str

        title : typing.Optional[str]
            If provided, replaces the tag title. Omit to leave unchanged.

        description : typing.Optional[str]
            If provided, replaces the tag description. Omit to leave unchanged.

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

        Returns
        -------
        ConversationTagResponseModel
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.tags.update(
            tag_id="tag_id",
        )
        """
        _response = self._raw_client.update(
            tag_id, title=title, description=description, request_options=request_options
        )
        return _response.data


class AsyncTagsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTagsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawTagsClient
        """
        return self._raw_client

    async def assign(
        self,
        conversation_id: str,
        *,
        tag_ids: typing.Sequence[str],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Assign one or more conversation tags to a conversation. Tags that are already assigned are ignored. Tags must belong to the same workspace.

        Parameters
        ----------
        conversation_id : str

        tag_ids : typing.Sequence[str]
            Tag IDs to add to the conversation. Re-assigning an existing tag is a no-op.

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.tags.assign(
                conversation_id="conversation_id",
                tag_ids=["tag_ids"],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.assign(conversation_id, tag_ids=tag_ids, request_options=request_options)
        return _response.data

    async def unassign(
        self, conversation_id: str, tag_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Remove a single conversation tag from a conversation.

        Parameters
        ----------
        conversation_id : str

        tag_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.tags.unassign(
                conversation_id="conversation_id",
                tag_id="tag_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.unassign(conversation_id, tag_id, request_options=request_options)
        return _response.data

    async def list(
        self,
        *,
        page_size: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetConversationTagsPageResponseModel:
        """
        List conversation tags for the workspace, ordered by most recently created first.

        Parameters
        ----------
        page_size : typing.Optional[int]
            How many conversation tags to return. Can not exceed 100.

        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

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

        Returns
        -------
        GetConversationTagsPageResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.tags.list(
                page_size=1,
                cursor="cursor",
            )


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

    async def create(
        self,
        *,
        title: str,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConversationTagResponseModel:
        """
        Create a new conversation tag for the workspace.

        Parameters
        ----------
        title : str
            Display title of the tag.

        description : typing.Optional[str]
            Optional free-text description.

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

        Returns
        -------
        ConversationTagResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.tags.create(
                title="title",
            )


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

    async def get(
        self, tag_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ConversationTagResponseModel:
        """
        Get a conversation tag by ID.

        Parameters
        ----------
        tag_id : str

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

        Returns
        -------
        ConversationTagResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.tags.get(
                tag_id="tag_id",
            )


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

    async def delete(self, tag_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a conversation tag. Restricted to the tag owner or a workspace admin.

        Parameters
        ----------
        tag_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.tags.delete(
                tag_id="tag_id",
            )


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

    async def update(
        self,
        tag_id: str,
        *,
        title: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConversationTagResponseModel:
        """
        Update a conversation tag's title and/or description. Restricted to the tag owner or a workspace admin.

        Parameters
        ----------
        tag_id : str

        title : typing.Optional[str]
            If provided, replaces the tag title. Omit to leave unchanged.

        description : typing.Optional[str]
            If provided, replaces the tag description. Omit to leave unchanged.

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

        Returns
        -------
        ConversationTagResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.tags.update(
                tag_id="tag_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            tag_id, title=title, description=description, request_options=request_options
        )
        return _response.data
