# 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.attachment_list_response import AttachmentListResponse
from .raw_client import AsyncRawEntityRulesClient, RawEntityRulesClient


class EntityRulesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawEntityRulesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawEntityRulesClient
        """
        return self._raw_client

    def list_entity_rules(
        self,
        entity_type: str,
        entity_id: str,
        *,
        include_rule_details: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AttachmentListResponse:
        """
        List all rules attached to a specific entity, ordered by priority (descending).

        Parameters
        ----------
        entity_type : str

        entity_id : str

        include_rule_details : typing.Optional[bool]
            Include rule summary in response

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

        Returns
        -------
        AttachmentListResponse
            Entity rules retrieved successfully

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.entity_rules.list_entity_rules(
            entity_type="entity_type",
            entity_id="entity_id",
        )
        """
        _response = self._raw_client.list_entity_rules(
            entity_type, entity_id, include_rule_details=include_rule_details, request_options=request_options
        )
        return _response.data


class AsyncEntityRulesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawEntityRulesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawEntityRulesClient
        """
        return self._raw_client

    async def list_entity_rules(
        self,
        entity_type: str,
        entity_id: str,
        *,
        include_rule_details: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AttachmentListResponse:
        """
        List all rules attached to a specific entity, ordered by priority (descending).

        Parameters
        ----------
        entity_type : str

        entity_id : str

        include_rule_details : typing.Optional[bool]
            Include rule summary in response

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

        Returns
        -------
        AttachmentListResponse
            Entity rules retrieved successfully

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

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


        async def main() -> None:
            await client.entity_rules.list_entity_rules(
                entity_type="entity_type",
                entity_id="entity_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_entity_rules(
            entity_type, entity_id, include_rule_details=include_rule_details, request_options=request_options
        )
        return _response.data
