# 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.category_statistics_response import CategoryStatisticsResponse
from ..types.usage_statistics_response import UsageStatisticsResponse
from .raw_client import AsyncRawRuleStatisticsClient, RawRuleStatisticsClient


class RuleStatisticsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawRuleStatisticsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawRuleStatisticsClient
        """
        return self._raw_client

    def get_category_statistics(
        self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> CategoryStatisticsResponse:
        """
        Get rule count statistics by category for an organization.

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

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

        Returns
        -------
        CategoryStatisticsResponse
            Successful Response

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

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

    def get_usage_statistics(
        self, org_id: str, rule_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> UsageStatisticsResponse:
        """
        Get usage statistics for a specific rule showing attachments by entity type.

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

        rule_id : str

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

        Returns
        -------
        UsageStatisticsResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.rule_statistics.get_usage_statistics(
            org_id="org_id",
            rule_id="rule_id",
        )
        """
        _response = self._raw_client.get_usage_statistics(org_id, rule_id, request_options=request_options)
        return _response.data


class AsyncRuleStatisticsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawRuleStatisticsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawRuleStatisticsClient
        """
        return self._raw_client

    async def get_category_statistics(
        self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> CategoryStatisticsResponse:
        """
        Get rule count statistics by category for an organization.

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

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

        Returns
        -------
        CategoryStatisticsResponse
            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.rule_statistics.get_category_statistics(
                org_id="org_id",
            )


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

    async def get_usage_statistics(
        self, org_id: str, rule_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> UsageStatisticsResponse:
        """
        Get usage statistics for a specific rule showing attachments by entity type.

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

        rule_id : str

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

        Returns
        -------
        UsageStatisticsResponse
            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.rule_statistics.get_usage_statistics(
                org_id="org_id",
                rule_id="rule_id",
            )


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