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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.pagination import AsyncPager, SyncPager
from ..core.request_options import RequestOptions
from ..types.entity_collection import EntityCollection
from .entities.client import AsyncEntitiesClient, EntitiesClient
from .raw_client import AsyncRawEntityCollectionsClient, RawEntityCollectionsClient
from .types.entity_collections_list_request_sort_by import EntityCollectionsListRequestSortBy

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


class EntityCollectionsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawEntityCollectionsClient(client_wrapper=client_wrapper)
        self.entities = EntitiesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawEntityCollectionsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        page: typing.Optional[int] = None,
        page_limit: typing.Optional[int] = None,
        name: typing.Optional[str] = None,
        sort_by: typing.Optional[EntityCollectionsListRequestSortBy] = None,
        sort_option: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SyncPager[EntityCollection]:
        """
        This method returns a list of the entity collections in your account.

        Parameters
        ----------
        page : typing.Optional[int]
            A number that identifies the page to retrieve.

            **Default**: `1`.

        page_limit : typing.Optional[int]
            The number of items to return on each page.

            **Default**: `10`.
            **Max**: `50`.

        name : typing.Optional[str]
            Filter entity collections by name.

        sort_by : typing.Optional[EntityCollectionsListRequestSortBy]
            The field to sort on. The following options are available:
            - `created_at`: Sorts by the time, in the RFC 3339 format ("YYYY-MM-DDTHH:mm:ssZ"), when the entity collection was updated.
            - `updated_at`: Sorts by the time, in the RFC 3339 format ("YYYY-MM-DDTHH:mm:ssZ"), when the entity collection was created.
            - `name`: Sorts by the name.

        sort_option : typing.Optional[str]
            The sorting direction. The following options are available:
            - `asc`
            - `desc`

            **Default**: `desc`.

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

        Returns
        -------
        SyncPager[EntityCollection]
            The entity collections have been successfully retrieved.

        Examples
        --------
        from twelvelabs import TwelveLabs

        client = TwelveLabs(
            api_key="YOUR_API_KEY",
        )
        response = client.entity_collections.list(
            page=1,
            page_limit=10,
            name="My entity collection",
            sort_by="created_at",
            sort_option="desc",
        )
        for item in response:
            yield item
        # alternatively, you can paginate page-by-page
        for page in response.iter_pages():
            yield page
        """
        return self._raw_client.list(
            page=page,
            page_limit=page_limit,
            name=name,
            sort_by=sort_by,
            sort_option=sort_option,
            request_options=request_options,
        )

    def create(
        self,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EntityCollection:
        """
        This method creates an entity collection.

        Parameters
        ----------
        name : str
            The name of the entity collection. Make sure you use a succinct and descriptive name.

        description : typing.Optional[str]
            Optional description of the entity collection.

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

        Returns
        -------
        EntityCollection
            The entity collection has been successfully created.

        Examples
        --------
        from twelvelabs import TwelveLabs

        client = TwelveLabs(
            api_key="YOUR_API_KEY",
        )
        client.entity_collections.create(
            name="My entity collection",
        )
        """
        _response = self._raw_client.create(name=name, description=description, request_options=request_options)
        return _response.data

    def retrieve(
        self, entity_collection_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> EntityCollection:
        """
        This method retrieves details about the specified entity collection.

        Parameters
        ----------
        entity_collection_id : str
            The unique identifier of the entity collection to retrieve.

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

        Returns
        -------
        EntityCollection
            The entity collection has been successfully retrieved.

        Examples
        --------
        from twelvelabs import TwelveLabs

        client = TwelveLabs(
            api_key="YOUR_API_KEY",
        )
        client.entity_collections.retrieve(
            entity_collection_id="6298d673f1090f1100476d4c",
        )
        """
        _response = self._raw_client.retrieve(entity_collection_id, request_options=request_options)
        return _response.data

    def delete(self, entity_collection_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        This method deletes the specified entity collection. This action cannot be undone.

        Parameters
        ----------
        entity_collection_id : str
            The unique identifier of the entity collection to delete.

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

        Returns
        -------
        None

        Examples
        --------
        from twelvelabs import TwelveLabs

        client = TwelveLabs(
            api_key="YOUR_API_KEY",
        )
        client.entity_collections.delete(
            entity_collection_id="6298d673f1090f1100476d4c",
        )
        """
        _response = self._raw_client.delete(entity_collection_id, request_options=request_options)
        return _response.data

    def update(
        self,
        entity_collection_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EntityCollection:
        """
        This method updates the specified entity collection.

        Parameters
        ----------
        entity_collection_id : str
            The unique identifier of the entity collection to update.

        name : typing.Optional[str]
            The updated name of the entity collection.

        description : typing.Optional[str]
            The updated description of the entity collection.

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

        Returns
        -------
        EntityCollection
            The entity collection has been successfully updated.

        Examples
        --------
        from twelvelabs import TwelveLabs

        client = TwelveLabs(
            api_key="YOUR_API_KEY",
        )
        client.entity_collections.update(
            entity_collection_id="6298d673f1090f1100476d4c",
        )
        """
        _response = self._raw_client.update(
            entity_collection_id, name=name, description=description, request_options=request_options
        )
        return _response.data


class AsyncEntityCollectionsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawEntityCollectionsClient(client_wrapper=client_wrapper)
        self.entities = AsyncEntitiesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawEntityCollectionsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        page: typing.Optional[int] = None,
        page_limit: typing.Optional[int] = None,
        name: typing.Optional[str] = None,
        sort_by: typing.Optional[EntityCollectionsListRequestSortBy] = None,
        sort_option: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncPager[EntityCollection]:
        """
        This method returns a list of the entity collections in your account.

        Parameters
        ----------
        page : typing.Optional[int]
            A number that identifies the page to retrieve.

            **Default**: `1`.

        page_limit : typing.Optional[int]
            The number of items to return on each page.

            **Default**: `10`.
            **Max**: `50`.

        name : typing.Optional[str]
            Filter entity collections by name.

        sort_by : typing.Optional[EntityCollectionsListRequestSortBy]
            The field to sort on. The following options are available:
            - `created_at`: Sorts by the time, in the RFC 3339 format ("YYYY-MM-DDTHH:mm:ssZ"), when the entity collection was updated.
            - `updated_at`: Sorts by the time, in the RFC 3339 format ("YYYY-MM-DDTHH:mm:ssZ"), when the entity collection was created.
            - `name`: Sorts by the name.

        sort_option : typing.Optional[str]
            The sorting direction. The following options are available:
            - `asc`
            - `desc`

            **Default**: `desc`.

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

        Returns
        -------
        AsyncPager[EntityCollection]
            The entity collections have been successfully retrieved.

        Examples
        --------
        import asyncio

        from twelvelabs import AsyncTwelveLabs

        client = AsyncTwelveLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            response = await client.entity_collections.list(
                page=1,
                page_limit=10,
                name="My entity collection",
                sort_by="created_at",
                sort_option="desc",
            )
            async for item in response:
                yield item

            # alternatively, you can paginate page-by-page
            async for page in response.iter_pages():
                yield page


        asyncio.run(main())
        """
        return await self._raw_client.list(
            page=page,
            page_limit=page_limit,
            name=name,
            sort_by=sort_by,
            sort_option=sort_option,
            request_options=request_options,
        )

    async def create(
        self,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EntityCollection:
        """
        This method creates an entity collection.

        Parameters
        ----------
        name : str
            The name of the entity collection. Make sure you use a succinct and descriptive name.

        description : typing.Optional[str]
            Optional description of the entity collection.

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

        Returns
        -------
        EntityCollection
            The entity collection has been successfully created.

        Examples
        --------
        import asyncio

        from twelvelabs import AsyncTwelveLabs

        client = AsyncTwelveLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.entity_collections.create(
                name="My entity collection",
            )


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

    async def retrieve(
        self, entity_collection_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> EntityCollection:
        """
        This method retrieves details about the specified entity collection.

        Parameters
        ----------
        entity_collection_id : str
            The unique identifier of the entity collection to retrieve.

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

        Returns
        -------
        EntityCollection
            The entity collection has been successfully retrieved.

        Examples
        --------
        import asyncio

        from twelvelabs import AsyncTwelveLabs

        client = AsyncTwelveLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.entity_collections.retrieve(
                entity_collection_id="6298d673f1090f1100476d4c",
            )


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

    async def delete(
        self, entity_collection_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        This method deletes the specified entity collection. This action cannot be undone.

        Parameters
        ----------
        entity_collection_id : str
            The unique identifier of the entity collection to delete.

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from twelvelabs import AsyncTwelveLabs

        client = AsyncTwelveLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.entity_collections.delete(
                entity_collection_id="6298d673f1090f1100476d4c",
            )


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

    async def update(
        self,
        entity_collection_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EntityCollection:
        """
        This method updates the specified entity collection.

        Parameters
        ----------
        entity_collection_id : str
            The unique identifier of the entity collection to update.

        name : typing.Optional[str]
            The updated name of the entity collection.

        description : typing.Optional[str]
            The updated description of the entity collection.

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

        Returns
        -------
        EntityCollection
            The entity collection has been successfully updated.

        Examples
        --------
        import asyncio

        from twelvelabs import AsyncTwelveLabs

        client = AsyncTwelveLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.entity_collections.update(
                entity_collection_id="6298d673f1090f1100476d4c",
            )


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