# 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.icon_list_response import IconListResponse
from ..types.icon_response import IconResponse
from .raw_client import AsyncRawIconsClient, RawIconsClient

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


class IconsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawIconsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawIconsClient
        """
        return self._raw_client

    def list_icons(
        self,
        org_id: str,
        *,
        search: typing.Optional[str] = None,
        category: typing.Optional[str] = None,
        include_inactive: typing.Optional[bool] = None,
        recommended_for: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> IconListResponse:
        """
        List icons available to an organization.

        Returns system icons + organization's custom icons.
        Supports search, category filtering, and pagination.

        Use `recommended_for=assistants` to show icons best suited for assistants first.
        Future contexts: projects, teams, etc.

        Parameters
        ----------
        org_id : str

        search : typing.Optional[str]
            Search by name, description, or tags

        category : typing.Optional[str]
            Filter by category

        include_inactive : typing.Optional[bool]
            Include inactive icons

        recommended_for : typing.Optional[str]
            Show icons recommended for context (e.g., 'assistants') first

        limit : typing.Optional[int]
            Items per page

        offset : typing.Optional[int]
            Number of items to skip

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

        Returns
        -------
        IconListResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.icons.list_icons(
            org_id="org_id",
        )
        """
        _response = self._raw_client.list_icons(
            org_id,
            search=search,
            category=category,
            include_inactive=include_inactive,
            recommended_for=recommended_for,
            limit=limit,
            offset=offset,
            request_options=request_options,
        )
        return _response.data

    def upload_icon(self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> IconResponse:
        """
        Upload a custom icon for an organization.

        Accepts **multipart/form-data** (fields: `file`, `name`, optional `description`,
        `tags`, `category`) or **application/json** with a base64-encoded image:
        ```json
        {"image": "<raw-base64>", "name": "optional-name"}
        ```
        File must be SVG, PNG, or JPG, max 5 MB.

        Parameters
        ----------
        org_id : str

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

        Returns
        -------
        IconResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.icons.upload_icon(
            org_id="org_id",
        )
        """
        _response = self._raw_client.upload_icon(org_id, request_options=request_options)
        return _response.data

    def delete_org_logo(self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Remove the logo from an organization.

        Clears logo_image and image_url on the organization.
        If the logo references a custom icon owned by this org, that icon is also soft-deleted.
        No-op (204) if the org has no logo set.

        Parameters
        ----------
        org_id : str

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

        Returns
        -------
        None

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.icons.delete_org_logo(
            org_id="org_id",
        )
        """
        _response = self._raw_client.delete_org_logo(org_id, request_options=request_options)
        return _response.data

    def serve_icon(
        self,
        icon_id: str,
        *,
        quality: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Serve icon file with optional quality transformation.

        Icons are publicly accessible since they're stored in a public GCS bucket.
        This endpoint acts as a proxy to GCS with quality transformation support.
        Quality parameter controls image size for raster formats.
        SVG icons always return original regardless of quality.

        Parameters
        ----------
        icon_id : str

        quality : typing.Optional[str]
            Quality: thumbnail, small, medium, large, original

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.icons.serve_icon(
            icon_id="icon_id",
        )
        """
        _response = self._raw_client.serve_icon(icon_id, quality=quality, request_options=request_options)
        return _response.data

    def delete_icon(
        self, org_id: str, icon_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Soft delete a custom icon.

        Marks icon as inactive and marks file for cleanup.
        Cannot delete system icons.

        Parameters
        ----------
        org_id : str

        icon_id : str

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

        Returns
        -------
        None

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.icons.delete_icon(
            org_id="org_id",
            icon_id="icon_id",
        )
        """
        _response = self._raw_client.delete_icon(org_id, icon_id, request_options=request_options)
        return _response.data

    def update_icon_metadata(
        self,
        org_id: str,
        icon_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        tags: typing.Optional[typing.Sequence[str]] = OMIT,
        is_active: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> IconResponse:
        """
        Update icon metadata (custom icons only).

        Can update name, description, tags, and is_active status.
        Cannot update system icons.

        Parameters
        ----------
        org_id : str

        icon_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        tags : typing.Optional[typing.Sequence[str]]

        is_active : typing.Optional[bool]

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

        Returns
        -------
        IconResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.icons.update_icon_metadata(
            org_id="org_id",
            icon_id="icon_id",
        )
        """
        _response = self._raw_client.update_icon_metadata(
            org_id,
            icon_id,
            name=name,
            description=description,
            tags=tags,
            is_active=is_active,
            request_options=request_options,
        )
        return _response.data


class AsyncIconsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawIconsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawIconsClient
        """
        return self._raw_client

    async def list_icons(
        self,
        org_id: str,
        *,
        search: typing.Optional[str] = None,
        category: typing.Optional[str] = None,
        include_inactive: typing.Optional[bool] = None,
        recommended_for: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> IconListResponse:
        """
        List icons available to an organization.

        Returns system icons + organization's custom icons.
        Supports search, category filtering, and pagination.

        Use `recommended_for=assistants` to show icons best suited for assistants first.
        Future contexts: projects, teams, etc.

        Parameters
        ----------
        org_id : str

        search : typing.Optional[str]
            Search by name, description, or tags

        category : typing.Optional[str]
            Filter by category

        include_inactive : typing.Optional[bool]
            Include inactive icons

        recommended_for : typing.Optional[str]
            Show icons recommended for context (e.g., 'assistants') first

        limit : typing.Optional[int]
            Items per page

        offset : typing.Optional[int]
            Number of items to skip

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

        Returns
        -------
        IconListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.icons.list_icons(
                org_id="org_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_icons(
            org_id,
            search=search,
            category=category,
            include_inactive=include_inactive,
            recommended_for=recommended_for,
            limit=limit,
            offset=offset,
            request_options=request_options,
        )
        return _response.data

    async def upload_icon(
        self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> IconResponse:
        """
        Upload a custom icon for an organization.

        Accepts **multipart/form-data** (fields: `file`, `name`, optional `description`,
        `tags`, `category`) or **application/json** with a base64-encoded image:
        ```json
        {"image": "<raw-base64>", "name": "optional-name"}
        ```
        File must be SVG, PNG, or JPG, max 5 MB.

        Parameters
        ----------
        org_id : str

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

        Returns
        -------
        IconResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.icons.upload_icon(
                org_id="org_id",
            )


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

    async def delete_org_logo(self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Remove the logo from an organization.

        Clears logo_image and image_url on the organization.
        If the logo references a custom icon owned by this org, that icon is also soft-deleted.
        No-op (204) if the org has no logo set.

        Parameters
        ----------
        org_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.icons.delete_org_logo(
                org_id="org_id",
            )


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

    async def serve_icon(
        self,
        icon_id: str,
        *,
        quality: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Serve icon file with optional quality transformation.

        Icons are publicly accessible since they're stored in a public GCS bucket.
        This endpoint acts as a proxy to GCS with quality transformation support.
        Quality parameter controls image size for raster formats.
        SVG icons always return original regardless of quality.

        Parameters
        ----------
        icon_id : str

        quality : typing.Optional[str]
            Quality: thumbnail, small, medium, large, original

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.icons.serve_icon(
                icon_id="icon_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.serve_icon(icon_id, quality=quality, request_options=request_options)
        return _response.data

    async def delete_icon(
        self, org_id: str, icon_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Soft delete a custom icon.

        Marks icon as inactive and marks file for cleanup.
        Cannot delete system icons.

        Parameters
        ----------
        org_id : str

        icon_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.icons.delete_icon(
                org_id="org_id",
                icon_id="icon_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_icon(org_id, icon_id, request_options=request_options)
        return _response.data

    async def update_icon_metadata(
        self,
        org_id: str,
        icon_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        tags: typing.Optional[typing.Sequence[str]] = OMIT,
        is_active: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> IconResponse:
        """
        Update icon metadata (custom icons only).

        Can update name, description, tags, and is_active status.
        Cannot update system icons.

        Parameters
        ----------
        org_id : str

        icon_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        tags : typing.Optional[typing.Sequence[str]]

        is_active : typing.Optional[bool]

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

        Returns
        -------
        IconResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.icons.update_icon_metadata(
                org_id="org_id",
                icon_id="icon_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_icon_metadata(
            org_id,
            icon_id,
            name=name,
            description=description,
            tags=tags,
            is_active=is_active,
            request_options=request_options,
        )
        return _response.data
