

# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: blickfeld/toolkit/services/preset.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 PresetSetRequest(betterproto.Message):
    """Request for setting the preset"""

    preset: "_config__.Preset" = betterproto.message_field(1)
    """Preset data"""


@dataclass(eq=False, repr=False)
class PresetGetResponse(betterproto.Message):
    """Response when getting the preset"""

    preset: "_config__.Preset" = betterproto.message_field(1)
    """Preset data"""


class Preset(betterproto.ServiceStub):
    """This service provided basic information about the configured preset"""

    async def async_get(
        self,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "PresetGetResponse":
        """Get the configured preset"""

        request = betterproto_lib_google_protobuf.Empty()

        return await self._unary_unary(
            "/blickfeld.toolkit.services.Preset/Get",
            request,
            PresetGetResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    def get(
        self,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "PresetGetResponse":
        """Get the configured preset"""

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

    async def async_set(
        self,
        *,
        preset: "_config__.Preset" = None,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "betterproto_lib_google_protobuf.Empty":
        """Set the selected preset"""

        request = PresetSetRequest()
        if preset is not None:
            request.preset = preset

        return await self._unary_unary(
            "/blickfeld.toolkit.services.Preset/Set",
            request,
            betterproto_lib_google_protobuf.Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    def set(
        self,
        *,
        preset: "_config__.Preset" = None,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "betterproto_lib_google_protobuf.Empty":
        """Set the selected preset"""

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