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

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


@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) -> "SupportedMethods":

        request = __client__.Empty()

        return await self._unary_unary(
            "/event_store.client.server_features.ServerFeatures/GetSupportedMethods",
            request,
            SupportedMethods,
        )


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

    async def __rpc_get_supported_methods(self, stream: grpclib.server.Stream) -> None:
        request = await stream.recv_message()

        request_kwargs = {}

        response = await self.get_supported_methods(**request_kwargs)
        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,
            ),
        }


from ... import client as __client__
