# 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.backend import Backend
from ..types.backend_state_info import BackendStateInfo
from ..types.calibration_response import CalibrationResponse
from .raw_client import AsyncRawBackendsClient, RawBackendsClient


class BackendsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBackendsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawBackendsClient
        """
        return self._raw_client

    def get_backends(
        self,
        *,
        provider: typing.Optional[str] = None,
        only_planqk_sdk: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Backend]:
        """
        Get the list of backends based on the provided filters.

        Parameters
        ----------
        provider : typing.Optional[str]

        only_planqk_sdk : typing.Optional[bool]

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

        Returns
        -------
        typing.List[Backend]
            The list of backends based on the provided filters.

        Examples
        --------
        from planqk import GeneratedPlanqkQuantumClient

        client = GeneratedPlanqkQuantumClient(
            organizationid="YOUR_ORGANIZATIONID",
            api_key="YOUR_API_KEY",
        )
        client.backends.get_backends(
            provider="provider",
            only_planqk_sdk=True,
        )
        """
        _response = self._raw_client.get_backends(
            provider=provider, only_planqk_sdk=only_planqk_sdk, request_options=request_options
        )
        return _response.data

    def get_backend(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Backend:
        """
        Get the details of a specific backend.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        Backend
            The backend with the specified ID.

        Examples
        --------
        from planqk import GeneratedPlanqkQuantumClient

        client = GeneratedPlanqkQuantumClient(
            organizationid="YOUR_ORGANIZATIONID",
            api_key="YOUR_API_KEY",
        )
        client.backends.get_backend(
            id="id",
        )
        """
        _response = self._raw_client.get_backend(id, request_options=request_options)
        return _response.data

    def get_backend_status(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> BackendStateInfo:
        """
        Get the status of a specific backend.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        BackendStateInfo
            The status of the backend.

        Examples
        --------
        from planqk import GeneratedPlanqkQuantumClient

        client = GeneratedPlanqkQuantumClient(
            organizationid="YOUR_ORGANIZATIONID",
            api_key="YOUR_API_KEY",
        )
        client.backends.get_backend_status(
            id="id",
        )
        """
        _response = self._raw_client.get_backend_status(id, request_options=request_options)
        return _response.data

    def get_backend_config(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Get the configuration of a specific backend.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        typing.Dict[str, typing.Any]
            The configuration of the backend.

        Examples
        --------
        from planqk import GeneratedPlanqkQuantumClient

        client = GeneratedPlanqkQuantumClient(
            organizationid="YOUR_ORGANIZATIONID",
            api_key="YOUR_API_KEY",
        )
        client.backends.get_backend_config(
            id="id",
        )
        """
        _response = self._raw_client.get_backend_config(id, request_options=request_options)
        return _response.data

    def get_backend_calibration(
        self,
        id: str,
        *,
        effective_at: typing.Optional[dt.datetime] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CalibrationResponse:
        """
        Get the calibration of a specific backend.

        Parameters
        ----------
        id : str

        effective_at : typing.Optional[dt.datetime]

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

        Returns
        -------
        CalibrationResponse
            The backend's calibration.

        Examples
        --------
        import datetime

        from planqk import GeneratedPlanqkQuantumClient

        client = GeneratedPlanqkQuantumClient(
            organizationid="YOUR_ORGANIZATIONID",
            api_key="YOUR_API_KEY",
        )
        client.backends.get_backend_calibration(
            id="id",
            effective_at=datetime.datetime.fromisoformat(
                "2024-01-15 09:30:00+00:00",
            ),
        )
        """
        _response = self._raw_client.get_backend_calibration(
            id, effective_at=effective_at, request_options=request_options
        )
        return _response.data


class AsyncBackendsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBackendsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawBackendsClient
        """
        return self._raw_client

    async def get_backends(
        self,
        *,
        provider: typing.Optional[str] = None,
        only_planqk_sdk: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Backend]:
        """
        Get the list of backends based on the provided filters.

        Parameters
        ----------
        provider : typing.Optional[str]

        only_planqk_sdk : typing.Optional[bool]

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

        Returns
        -------
        typing.List[Backend]
            The list of backends based on the provided filters.

        Examples
        --------
        import asyncio

        from planqk import AsyncGeneratedPlanqkQuantumClient

        client = AsyncGeneratedPlanqkQuantumClient(
            organizationid="YOUR_ORGANIZATIONID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.backends.get_backends(
                provider="provider",
                only_planqk_sdk=True,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_backends(
            provider=provider, only_planqk_sdk=only_planqk_sdk, request_options=request_options
        )
        return _response.data

    async def get_backend(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Backend:
        """
        Get the details of a specific backend.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        Backend
            The backend with the specified ID.

        Examples
        --------
        import asyncio

        from planqk import AsyncGeneratedPlanqkQuantumClient

        client = AsyncGeneratedPlanqkQuantumClient(
            organizationid="YOUR_ORGANIZATIONID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.backends.get_backend(
                id="id",
            )


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

    async def get_backend_status(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> BackendStateInfo:
        """
        Get the status of a specific backend.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        BackendStateInfo
            The status of the backend.

        Examples
        --------
        import asyncio

        from planqk import AsyncGeneratedPlanqkQuantumClient

        client = AsyncGeneratedPlanqkQuantumClient(
            organizationid="YOUR_ORGANIZATIONID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.backends.get_backend_status(
                id="id",
            )


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

    async def get_backend_config(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Get the configuration of a specific backend.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        typing.Dict[str, typing.Any]
            The configuration of the backend.

        Examples
        --------
        import asyncio

        from planqk import AsyncGeneratedPlanqkQuantumClient

        client = AsyncGeneratedPlanqkQuantumClient(
            organizationid="YOUR_ORGANIZATIONID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.backends.get_backend_config(
                id="id",
            )


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

    async def get_backend_calibration(
        self,
        id: str,
        *,
        effective_at: typing.Optional[dt.datetime] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CalibrationResponse:
        """
        Get the calibration of a specific backend.

        Parameters
        ----------
        id : str

        effective_at : typing.Optional[dt.datetime]

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

        Returns
        -------
        CalibrationResponse
            The backend's calibration.

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

        from planqk import AsyncGeneratedPlanqkQuantumClient

        client = AsyncGeneratedPlanqkQuantumClient(
            organizationid="YOUR_ORGANIZATIONID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.backends.get_backend_calibration(
                id="id",
                effective_at=datetime.datetime.fromisoformat(
                    "2024-01-15 09:30:00+00:00",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_backend_calibration(
            id, effective_at=effective_at, request_options=request_options
        )
        return _response.data
