# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: serverfeatures.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import TYPE_CHECKING, Dict, List, Optional

import betterproto
import grpclib
from betterproto.grpc.grpclib_server import ServiceBase

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


@dataclass(eq=False, repr=False)
class SupportedMethods(betterproto.Message):
    methods: List["SupportedMethod"] = betterproto.message_field(1)
    event_store_server_version: str = betterproto.string_field(2)


@dataclass(eq=False, repr=False)
class SupportedMethod(betterproto.Message):
    method_name: str = betterproto.string_field(1)
    service_name: str = betterproto.string_field(2)
    features: List[str] = betterproto.string_field(3)


class ServerFeaturesStub(betterproto.ServiceStub):
    async def get_supported_methods(
        self,
        client_empty: "__client__.Empty",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "SupportedMethods":
        return await self._unary_unary(
            "/event_store.client.server_features.ServerFeatures/GetSupportedMethods",
            client_empty,
            SupportedMethods,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


class ServerFeaturesBase(ServiceBase):
    async def get_supported_methods(
        self, client_empty: "__client__.Empty"
    ) -> "SupportedMethods":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_get_supported_methods(
        self, stream: "grpclib.server.Stream[__client__.Empty, SupportedMethods]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.get_supported_methods(request)
        await stream.send_message(response)

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/event_store.client.server_features.ServerFeatures/GetSupportedMethods": grpclib.const.Handler(
                self.__rpc_get_supported_methods,
                grpclib.const.Cardinality.UNARY_UNARY,
                __client__.Empty,
                SupportedMethods,
            ),
        }
