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

from __future__ import annotations

import typing

from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ....core.request_options import RequestOptions
from ....types.delete_project_v1response import DeleteProjectV1Response
from ....types.get_project_v1response import GetProjectV1Response
from ....types.leave_project_v1response import LeaveProjectV1Response
from ....types.list_projects_v1response import ListProjectsV1Response
from ....types.update_project_v1response import UpdateProjectV1Response
from .raw_client import AsyncRawProjectsClient, RawProjectsClient

if typing.TYPE_CHECKING:
    from .billing.client import AsyncBillingClient, BillingClient
    from .keys.client import AsyncKeysClient, KeysClient
    from .members.client import AsyncMembersClient, MembersClient
    from .models.client import AsyncModelsClient, ModelsClient
    from .requests.client import AsyncRequestsClient, RequestsClient
    from .usage.client import AsyncUsageClient, UsageClient
# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class ProjectsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawProjectsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._keys: typing.Optional[KeysClient] = None
        self._members: typing.Optional[MembersClient] = None
        self._models: typing.Optional[ModelsClient] = None
        self._requests: typing.Optional[RequestsClient] = None
        self._usage: typing.Optional[UsageClient] = None
        self._billing: typing.Optional[BillingClient] = None

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

        Returns
        -------
        RawProjectsClient
        """
        return self._raw_client

    def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ListProjectsV1Response:
        """
        Retrieves basic information about the projects associated with the API key

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

        Returns
        -------
        ListProjectsV1Response
            A list of projects

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

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.manage.v1.projects.list()
        """
        _response = self._raw_client.list(request_options=request_options)
        return _response.data

    def get(
        self,
        project_id: str,
        *,
        limit: typing.Optional[float] = None,
        page: typing.Optional[float] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetProjectV1Response:
        """
        Retrieves information about the specified project

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

        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

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

        Returns
        -------
        GetProjectV1Response
            A project

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

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

    def delete(
        self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteProjectV1Response:
        """
        Deletes the specified project

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

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

        Returns
        -------
        DeleteProjectV1Response
            A project

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

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

    def update(
        self,
        project_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateProjectV1Response:
        """
        Updates the name or other properties of an existing project

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

        name : typing.Optional[str]
            The name of the project

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

        Returns
        -------
        UpdateProjectV1Response
            A project

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

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

    def leave(
        self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> LeaveProjectV1Response:
        """
        Removes the authenticated account from the specific project

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

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

        Returns
        -------
        LeaveProjectV1Response
            Successfully removed account from project

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

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

    @property
    def keys(self):
        if self._keys is None:
            from .keys.client import KeysClient  # noqa: E402

            self._keys = KeysClient(client_wrapper=self._client_wrapper)
        return self._keys

    @property
    def members(self):
        if self._members is None:
            from .members.client import MembersClient  # noqa: E402

            self._members = MembersClient(client_wrapper=self._client_wrapper)
        return self._members

    @property
    def models(self):
        if self._models is None:
            from .models.client import ModelsClient  # noqa: E402

            self._models = ModelsClient(client_wrapper=self._client_wrapper)
        return self._models

    @property
    def requests(self):
        if self._requests is None:
            from .requests.client import RequestsClient  # noqa: E402

            self._requests = RequestsClient(client_wrapper=self._client_wrapper)
        return self._requests

    @property
    def usage(self):
        if self._usage is None:
            from .usage.client import UsageClient  # noqa: E402

            self._usage = UsageClient(client_wrapper=self._client_wrapper)
        return self._usage

    @property
    def billing(self):
        if self._billing is None:
            from .billing.client import BillingClient  # noqa: E402

            self._billing = BillingClient(client_wrapper=self._client_wrapper)
        return self._billing


class AsyncProjectsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawProjectsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._keys: typing.Optional[AsyncKeysClient] = None
        self._members: typing.Optional[AsyncMembersClient] = None
        self._models: typing.Optional[AsyncModelsClient] = None
        self._requests: typing.Optional[AsyncRequestsClient] = None
        self._usage: typing.Optional[AsyncUsageClient] = None
        self._billing: typing.Optional[AsyncBillingClient] = None

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

        Returns
        -------
        AsyncRawProjectsClient
        """
        return self._raw_client

    async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ListProjectsV1Response:
        """
        Retrieves basic information about the projects associated with the API key

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

        Returns
        -------
        ListProjectsV1Response
            A list of projects

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.manage.v1.projects.list()


        asyncio.run(main())
        """
        _response = await self._raw_client.list(request_options=request_options)
        return _response.data

    async def get(
        self,
        project_id: str,
        *,
        limit: typing.Optional[float] = None,
        page: typing.Optional[float] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetProjectV1Response:
        """
        Retrieves information about the specified project

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

        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

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

        Returns
        -------
        GetProjectV1Response
            A project

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


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


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

    async def delete(
        self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteProjectV1Response:
        """
        Deletes the specified project

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

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

        Returns
        -------
        DeleteProjectV1Response
            A project

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


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


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

    async def update(
        self,
        project_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateProjectV1Response:
        """
        Updates the name or other properties of an existing project

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

        name : typing.Optional[str]
            The name of the project

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

        Returns
        -------
        UpdateProjectV1Response
            A project

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


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


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

    async def leave(
        self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> LeaveProjectV1Response:
        """
        Removes the authenticated account from the specific project

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

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

        Returns
        -------
        LeaveProjectV1Response
            Successfully removed account from project

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


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


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

    @property
    def keys(self):
        if self._keys is None:
            from .keys.client import AsyncKeysClient  # noqa: E402

            self._keys = AsyncKeysClient(client_wrapper=self._client_wrapper)
        return self._keys

    @property
    def members(self):
        if self._members is None:
            from .members.client import AsyncMembersClient  # noqa: E402

            self._members = AsyncMembersClient(client_wrapper=self._client_wrapper)
        return self._members

    @property
    def models(self):
        if self._models is None:
            from .models.client import AsyncModelsClient  # noqa: E402

            self._models = AsyncModelsClient(client_wrapper=self._client_wrapper)
        return self._models

    @property
    def requests(self):
        if self._requests is None:
            from .requests.client import AsyncRequestsClient  # noqa: E402

            self._requests = AsyncRequestsClient(client_wrapper=self._client_wrapper)
        return self._requests

    @property
    def usage(self):
        if self._usage is None:
            from .usage.client import AsyncUsageClient  # noqa: E402

            self._usage = AsyncUsageClient(client_wrapper=self._client_wrapper)
        return self._usage

    @property
    def billing(self):
        if self._billing is None:
            from .billing.client import AsyncBillingClient  # noqa: E402

            self._billing = AsyncBillingClient(client_wrapper=self._client_wrapper)
        return self._billing
