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

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


@dataclass(eq=False, repr=False)
class GetMlbParamRequest(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class GetMlbParamResponse(betterproto.Message):
    interval: int = betterproto.int32_field(1)
    overload_threshold: int = betterproto.int32_field(2)
    target_threshold: int = betterproto.int32_field(3)
    delta_ocn: int = betterproto.int32_field(4)


@dataclass(eq=False, repr=False)
class SetMlbParamRequest(betterproto.Message):
    interval: int = betterproto.int32_field(1)
    overload_threshold: int = betterproto.int32_field(2)
    target_threshold: int = betterproto.int32_field(3)
    delta_ocn: int = betterproto.int32_field(4)


@dataclass(eq=False, repr=False)
class SetMlbParamResponse(betterproto.Message):
    success: bool = betterproto.bool_field(1)


@dataclass(eq=False, repr=False)
class GetOcnRequest(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class GetOcnResponse(betterproto.Message):
    ocn_map: Dict[str, "OcnRecord"] = betterproto.map_field(
        1, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
    )


@dataclass(eq=False, repr=False)
class OcnRecord(betterproto.Message):
    ocn_record: Dict[str, int] = betterproto.map_field(
        1, betterproto.TYPE_STRING, betterproto.TYPE_INT32
    )


@dataclass(eq=False, repr=False)
class OcnIDs(betterproto.Message):
    pass


class MlbStub(betterproto.ServiceStub):
    async def get_mlb_params(self) -> "GetMlbParamResponse":

        request = GetMlbParamRequest()

        return await self._unary_unary(
            "/onos.mlb.Mlb/GetMlbParams", request, GetMlbParamResponse
        )

    async def set_mlb_params(
        self,
        *,
        interval: int = 0,
        overload_threshold: int = 0,
        target_threshold: int = 0,
        delta_ocn: int = 0,
    ) -> "SetMlbParamResponse":

        request = SetMlbParamRequest()
        request.interval = interval
        request.overload_threshold = overload_threshold
        request.target_threshold = target_threshold
        request.delta_ocn = delta_ocn

        return await self._unary_unary(
            "/onos.mlb.Mlb/SetMlbParams", request, SetMlbParamResponse
        )

    async def get_ocn(self) -> "GetOcnResponse":

        request = GetOcnRequest()

        return await self._unary_unary("/onos.mlb.Mlb/GetOcn", request, GetOcnResponse)


class MlbBase(ServiceBase):
    async def get_mlb_params(self) -> "GetMlbParamResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def set_mlb_params(
        self,
        interval: int,
        overload_threshold: int,
        target_threshold: int,
        delta_ocn: int,
    ) -> "SetMlbParamResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def get_ocn(self) -> "GetOcnResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

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

        request_kwargs = {}

        response = await self.get_mlb_params(**request_kwargs)
        await stream.send_message(response)

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

        request_kwargs = {
            "interval": request.interval,
            "overload_threshold": request.overload_threshold,
            "target_threshold": request.target_threshold,
            "delta_ocn": request.delta_ocn,
        }

        response = await self.set_mlb_params(**request_kwargs)
        await stream.send_message(response)

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

        request_kwargs = {}

        response = await self.get_ocn(**request_kwargs)
        await stream.send_message(response)

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/onos.mlb.Mlb/GetMlbParams": grpclib.const.Handler(
                self.__rpc_get_mlb_params,
                grpclib.const.Cardinality.UNARY_UNARY,
                GetMlbParamRequest,
                GetMlbParamResponse,
            ),
            "/onos.mlb.Mlb/SetMlbParams": grpclib.const.Handler(
                self.__rpc_set_mlb_params,
                grpclib.const.Cardinality.UNARY_UNARY,
                SetMlbParamRequest,
                SetMlbParamResponse,
            ),
            "/onos.mlb.Mlb/GetOcn": grpclib.const.Handler(
                self.__rpc_get_ocn,
                grpclib.const.Cardinality.UNARY_UNARY,
                GetOcnRequest,
                GetOcnResponse,
            ),
        }
