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

import datetime as dt
import typing

from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .....core.request_options import RequestOptions
from .....types.get_project_request_v1response import GetProjectRequestV1Response
from .....types.list_project_requests_v1response import ListProjectRequestsV1Response
from .raw_client import AsyncRawRequestsClient, RawRequestsClient
from .types.requests_list_request_deployment import RequestsListRequestDeployment
from .types.requests_list_request_endpoint import RequestsListRequestEndpoint
from .types.requests_list_request_method import RequestsListRequestMethod
from .types.requests_list_request_status import RequestsListRequestStatus


class RequestsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawRequestsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawRequestsClient
        """
        return self._raw_client

    def list(
        self,
        project_id: str,
        *,
        start: typing.Optional[dt.datetime] = None,
        end: typing.Optional[dt.datetime] = None,
        limit: typing.Optional[float] = None,
        page: typing.Optional[float] = None,
        accessor: typing.Optional[str] = None,
        request_id: typing.Optional[str] = None,
        deployment: typing.Optional[RequestsListRequestDeployment] = None,
        endpoint: typing.Optional[RequestsListRequestEndpoint] = None,
        method: typing.Optional[RequestsListRequestMethod] = None,
        status: typing.Optional[RequestsListRequestStatus] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListProjectRequestsV1Response:
        """
        Generates a list of requests for a specific project

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

        start : typing.Optional[dt.datetime]
            Start date of the requested date range. Formats accepted are YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+HH:MM

        end : typing.Optional[dt.datetime]
            End date of the requested date range. Formats accepted are YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+HH:MM

        limit : typing.Optional[float]
            Number of results to return per page. Default 10. Range [1,1000]

        page : typing.Optional[float]
            Navigate and return the results to retrieve specific portions of information of the response

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

        request_id : typing.Optional[str]
            Filter for a specific request id

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

        endpoint : typing.Optional[RequestsListRequestEndpoint]
            Filter for requests where a specific endpoint was used

        method : typing.Optional[RequestsListRequestMethod]
            Filter for requests where a specific method was used

        status : typing.Optional[RequestsListRequestStatus]
            Filter for requests that succeeded (status code < 300) or failed (status code >=400)

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

        Returns
        -------
        ListProjectRequestsV1Response
            A list of requests for a specific project

        Examples
        --------
        import datetime

        from deepgram import DeepgramClient

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.manage.v1.projects.requests.list(
            project_id="123456-7890-1234-5678-901234",
            start=datetime.datetime.fromisoformat(
                "2024-01-15 09:30:00+00:00",
            ),
            end=datetime.datetime.fromisoformat(
                "2024-01-15 09:30:00+00:00",
            ),
            limit=1.1,
            page=1.1,
            accessor="12345678-1234-1234-1234-123456789012",
            request_id="12345678-1234-1234-1234-123456789012",
            deployment="hosted",
            endpoint="listen",
            method="sync",
            status="succeeded",
        )
        """
        _response = self._raw_client.list(
            project_id,
            start=start,
            end=end,
            limit=limit,
            page=page,
            accessor=accessor,
            request_id=request_id,
            deployment=deployment,
            endpoint=endpoint,
            method=method,
            status=status,
            request_options=request_options,
        )
        return _response.data

    def get(
        self, project_id: str, request_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetProjectRequestV1Response:
        """
        Retrieves a specific request for a specific project

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

        request_id : str
            The unique identifier of the request

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

        Returns
        -------
        GetProjectRequestV1Response
            A specific request for a specific project

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

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.manage.v1.projects.requests.get(
            project_id="123456-7890-1234-5678-901234",
            request_id="123456-7890-1234-5678-901234",
        )
        """
        _response = self._raw_client.get(project_id, request_id, request_options=request_options)
        return _response.data


class AsyncRequestsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawRequestsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawRequestsClient
        """
        return self._raw_client

    async def list(
        self,
        project_id: str,
        *,
        start: typing.Optional[dt.datetime] = None,
        end: typing.Optional[dt.datetime] = None,
        limit: typing.Optional[float] = None,
        page: typing.Optional[float] = None,
        accessor: typing.Optional[str] = None,
        request_id: typing.Optional[str] = None,
        deployment: typing.Optional[RequestsListRequestDeployment] = None,
        endpoint: typing.Optional[RequestsListRequestEndpoint] = None,
        method: typing.Optional[RequestsListRequestMethod] = None,
        status: typing.Optional[RequestsListRequestStatus] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListProjectRequestsV1Response:
        """
        Generates a list of requests for a specific project

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

        start : typing.Optional[dt.datetime]
            Start date of the requested date range. Formats accepted are YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+HH:MM

        end : typing.Optional[dt.datetime]
            End date of the requested date range. Formats accepted are YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+HH:MM

        limit : typing.Optional[float]
            Number of results to return per page. Default 10. Range [1,1000]

        page : typing.Optional[float]
            Navigate and return the results to retrieve specific portions of information of the response

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

        request_id : typing.Optional[str]
            Filter for a specific request id

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

        endpoint : typing.Optional[RequestsListRequestEndpoint]
            Filter for requests where a specific endpoint was used

        method : typing.Optional[RequestsListRequestMethod]
            Filter for requests where a specific method was used

        status : typing.Optional[RequestsListRequestStatus]
            Filter for requests that succeeded (status code < 300) or failed (status code >=400)

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

        Returns
        -------
        ListProjectRequestsV1Response
            A list of requests for a specific project

        Examples
        --------
        import asyncio
        import datetime

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.manage.v1.projects.requests.list(
                project_id="123456-7890-1234-5678-901234",
                start=datetime.datetime.fromisoformat(
                    "2024-01-15 09:30:00+00:00",
                ),
                end=datetime.datetime.fromisoformat(
                    "2024-01-15 09:30:00+00:00",
                ),
                limit=1.1,
                page=1.1,
                accessor="12345678-1234-1234-1234-123456789012",
                request_id="12345678-1234-1234-1234-123456789012",
                deployment="hosted",
                endpoint="listen",
                method="sync",
                status="succeeded",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            project_id,
            start=start,
            end=end,
            limit=limit,
            page=page,
            accessor=accessor,
            request_id=request_id,
            deployment=deployment,
            endpoint=endpoint,
            method=method,
            status=status,
            request_options=request_options,
        )
        return _response.data

    async def get(
        self, project_id: str, request_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetProjectRequestV1Response:
        """
        Retrieves a specific request for a specific project

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

        request_id : str
            The unique identifier of the request

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

        Returns
        -------
        GetProjectRequestV1Response
            A specific request for a specific project

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.manage.v1.projects.requests.get(
                project_id="123456-7890-1234-5678-901234",
                request_id="123456-7890-1234-5678-901234",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get(project_id, request_id, request_options=request_options)
        return _response.data
