# 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.billing_breakdown_v1response import BillingBreakdownV1Response
from .raw_client import AsyncRawBreakdownClient, RawBreakdownClient
from .types.breakdown_list_request_deployment import BreakdownListRequestDeployment
from .types.breakdown_list_request_grouping_item import BreakdownListRequestGroupingItem


class BreakdownClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBreakdownClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawBreakdownClient
        """
        return self._raw_client

    def list(
        self,
        project_id: str,
        *,
        start: typing.Optional[str] = None,
        end: typing.Optional[str] = None,
        accessor: typing.Optional[str] = None,
        deployment: typing.Optional[BreakdownListRequestDeployment] = None,
        tag: typing.Optional[str] = None,
        line_item: typing.Optional[str] = None,
        grouping: typing.Optional[
            typing.Union[BreakdownListRequestGroupingItem, typing.Sequence[BreakdownListRequestGroupingItem]]
        ] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BillingBreakdownV1Response:
        """
        Retrieves the billing summary for a specific project, with various filter options or by grouping options.

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        start : typing.Optional[str]
            Start date of the requested date range. Format accepted is YYYY-MM-DD

        end : typing.Optional[str]
            End date of the requested date range. Format accepted is YYYY-MM-DD

        accessor : typing.Optional[str]
            Filter for requests where a specific accessor was used

        deployment : typing.Optional[BreakdownListRequestDeployment]
            Filter for requests where a specific deployment was used

        tag : typing.Optional[str]
            Filter for requests where a specific tag was used

        line_item : typing.Optional[str]
            Filter requests by line item (e.g. streaming::nova-3)

        grouping : typing.Optional[typing.Union[BreakdownListRequestGroupingItem, typing.Sequence[BreakdownListRequestGroupingItem]]]
            Group billing breakdown by one or more dimensions (accessor, deployment, line_item, tags)

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

        Returns
        -------
        BillingBreakdownV1Response
            Billing breakdown response

        Examples
        --------
        from deepgram import DeepgramClient

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.manage.v1.projects.billing.breakdown.list(
            project_id="123456-7890-1234-5678-901234",
            start="start",
            end="end",
            accessor="12345678-1234-1234-1234-123456789012",
            deployment="hosted",
            tag="tag1",
            line_item="streaming::nova-3",
        )
        """
        _response = self._raw_client.list(
            project_id,
            start=start,
            end=end,
            accessor=accessor,
            deployment=deployment,
            tag=tag,
            line_item=line_item,
            grouping=grouping,
            request_options=request_options,
        )
        return _response.data


class AsyncBreakdownClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBreakdownClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawBreakdownClient
        """
        return self._raw_client

    async def list(
        self,
        project_id: str,
        *,
        start: typing.Optional[str] = None,
        end: typing.Optional[str] = None,
        accessor: typing.Optional[str] = None,
        deployment: typing.Optional[BreakdownListRequestDeployment] = None,
        tag: typing.Optional[str] = None,
        line_item: typing.Optional[str] = None,
        grouping: typing.Optional[
            typing.Union[BreakdownListRequestGroupingItem, typing.Sequence[BreakdownListRequestGroupingItem]]
        ] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BillingBreakdownV1Response:
        """
        Retrieves the billing summary for a specific project, with various filter options or by grouping options.

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        start : typing.Optional[str]
            Start date of the requested date range. Format accepted is YYYY-MM-DD

        end : typing.Optional[str]
            End date of the requested date range. Format accepted is YYYY-MM-DD

        accessor : typing.Optional[str]
            Filter for requests where a specific accessor was used

        deployment : typing.Optional[BreakdownListRequestDeployment]
            Filter for requests where a specific deployment was used

        tag : typing.Optional[str]
            Filter for requests where a specific tag was used

        line_item : typing.Optional[str]
            Filter requests by line item (e.g. streaming::nova-3)

        grouping : typing.Optional[typing.Union[BreakdownListRequestGroupingItem, typing.Sequence[BreakdownListRequestGroupingItem]]]
            Group billing breakdown by one or more dimensions (accessor, deployment, line_item, tags)

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

        Returns
        -------
        BillingBreakdownV1Response
            Billing breakdown response

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.manage.v1.projects.billing.breakdown.list(
                project_id="123456-7890-1234-5678-901234",
                start="start",
                end="end",
                accessor="12345678-1234-1234-1234-123456789012",
                deployment="hosted",
                tag="tag1",
                line_item="streaming::nova-3",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            project_id,
            start=start,
            end=end,
            accessor=accessor,
            deployment=deployment,
            tag=tag,
            line_item=line_item,
            grouping=grouping,
            request_options=request_options,
        )
        return _response.data
