# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: blickfeld/hardware/services/compute_module.proto, blickfeld/hardware/services/identification.proto
# plugin: python-betterproto
import asyncio
from dataclasses import dataclass
from typing import (
    TYPE_CHECKING,
    Dict,
    Optional,
)

import blickfeld_qb2.betterproto as betterproto
import blickfeld_qb2.betterproto.lib.google.protobuf as betterproto_lib_google_protobuf
import grpclib
from blickfeld_qb2.betterproto.grpc.grpclib_server import ServiceBase

from .. import config as _config__


if TYPE_CHECKING:
    import grpclib.server
    from blickfeld_qb2.betterproto.grpc.grpclib_client import MetadataLike
    from grpclib.metadata import Deadline


@dataclass(eq=False, repr=False)
class IdentificationGetResponse(betterproto.Message):
    """Response message for the identification get command"""

    identification: "_config__.Identification" = betterproto.message_field(1)
    """The current identification"""


class ComputeModule(betterproto.ServiceStub):
    """
    This service is used to control & observe the state of the compute module.
    """

    async def async_reboot(
        self,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "betterproto_lib_google_protobuf.Empty":
        """Reboots the CM4"""

        request = betterproto_lib_google_protobuf.Empty()

        return await self._unary_unary(
            "/blickfeld.hardware.services.ComputeModule/Reboot",
            request,
            betterproto_lib_google_protobuf.Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    def reboot(
        self,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "betterproto_lib_google_protobuf.Empty":
        """Reboots the CM4"""

        loop = asyncio.get_event_loop()
        return loop.run_until_complete(
            self.async_reboot(
                timeout=timeout,
                deadline=deadline,
                metadata=metadata,
            )
        )


class Identification(betterproto.ServiceStub):
    """
    The identification service provides methods to set and read out
    identification data of the Qb2 device.
    """

    async def async_get(
        self,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "IdentificationGetResponse":
        """Gets identification configuration"""

        request = betterproto_lib_google_protobuf.Empty()

        return await self._unary_unary(
            "/blickfeld.hardware.services.Identification/Get",
            request,
            IdentificationGetResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    def get(
        self,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "IdentificationGetResponse":
        """Gets identification configuration"""

        loop = asyncio.get_event_loop()
        return loop.run_until_complete(
            self.async_get(
                timeout=timeout,
                deadline=deadline,
                metadata=metadata,
            )
        )
