# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: onos/a1t/a1/ei.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import AsyncIterable, AsyncIterator, Dict, Iterable, Union

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


@dataclass(eq=False, repr=False)
class Request(betterproto.Message):
    header: "__a1__.Header" = betterproto.message_field(1)
    message: "__a1__.RequestMessage" = betterproto.message_field(2)


@dataclass(eq=False, repr=False)
class Result(betterproto.Message):
    header: "__a1__.Header" = betterproto.message_field(1)
    message: "__a1__.ResultMessage" = betterproto.message_field(2)


@dataclass(eq=False, repr=False)
class Status(betterproto.Message):
    header: "__a1__.Header" = betterproto.message_field(1)
    message: "__a1__.StatusMessage" = betterproto.message_field(2)


@dataclass(eq=False, repr=False)
class Ack(betterproto.Message):
    header: "__a1__.Header" = betterproto.message_field(1)
    message: "__a1__.AckMessage" = betterproto.message_field(2)


class EiServiceStub(betterproto.ServiceStub):
    async def ei_query(
        self, request_iterator: Union[AsyncIterable["Result"], Iterable["Result"]]
    ) -> AsyncIterator["Request"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.ei.EIService/EIQuery",
            request_iterator,
            Result,
            Request,
        ):
            yield response

    async def ei_job_setup(
        self, request_iterator: Union[AsyncIterable["Result"], Iterable["Result"]]
    ) -> AsyncIterator["Request"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.ei.EIService/EIJobSetup",
            request_iterator,
            Result,
            Request,
        ):
            yield response

    async def ei_job_update(
        self, request_iterator: Union[AsyncIterable["Result"], Iterable["Result"]]
    ) -> AsyncIterator["Request"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.ei.EIService/EIJobUpdate",
            request_iterator,
            Result,
            Request,
        ):
            yield response

    async def ei_job_delete(
        self, request_iterator: Union[AsyncIterable["Result"], Iterable["Result"]]
    ) -> AsyncIterator["Request"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.ei.EIService/EIJobDelete",
            request_iterator,
            Result,
            Request,
        ):
            yield response

    async def ei_job_status_query(
        self, request_iterator: Union[AsyncIterable["Result"], Iterable["Result"]]
    ) -> AsyncIterator["Request"]:

        async for response in self._stream_stream(
            "/onos.a1t.a1.ei.EIService/EIJobStatusQuery",
            request_iterator,
            Result,
            Request,
        ):
            yield response

    async def ei_job_status_notify(
        self, *, header: "__a1__.Header" = None, message: "__a1__.StatusMessage" = None
    ) -> "Ack":

        request = Status()
        if header is not None:
            request.header = header
        if message is not None:
            request.message = message

        return await self._unary_unary(
            "/onos.a1t.a1.ei.EIService/EIJobStatusNotify", request, Ack
        )

    async def ei_job_result_delivery(
        self, *, header: "__a1__.Header" = None, message: "__a1__.ResultMessage" = None
    ) -> "Ack":

        request = Result()
        if header is not None:
            request.header = header
        if message is not None:
            request.message = message

        return await self._unary_unary(
            "/onos.a1t.a1.ei.EIService/EIJobResultDelivery", request, Ack
        )


class EiServiceBase(ServiceBase):
    async def ei_query(
        self, request_iterator: AsyncIterator["Result"]
    ) -> AsyncIterator["Request"]:
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def ei_job_setup(
        self, request_iterator: AsyncIterator["Result"]
    ) -> AsyncIterator["Request"]:
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def ei_job_update(
        self, request_iterator: AsyncIterator["Result"]
    ) -> AsyncIterator["Request"]:
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def ei_job_delete(
        self, request_iterator: AsyncIterator["Result"]
    ) -> AsyncIterator["Request"]:
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def ei_job_status_query(
        self, request_iterator: AsyncIterator["Result"]
    ) -> AsyncIterator["Request"]:
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def ei_job_status_notify(
        self, header: "__a1__.Header", message: "__a1__.StatusMessage"
    ) -> "Ack":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def ei_job_result_delivery(
        self, header: "__a1__.Header", message: "__a1__.ResultMessage"
    ) -> "Ack":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_ei_query(self, stream: grpclib.server.Stream) -> None:
        request_kwargs = {"request_iterator": stream.__aiter__()}

        await self._call_rpc_handler_server_stream(
            self.ei_query,
            stream,
            request_kwargs,
        )

    async def __rpc_ei_job_setup(self, stream: grpclib.server.Stream) -> None:
        request_kwargs = {"request_iterator": stream.__aiter__()}

        await self._call_rpc_handler_server_stream(
            self.ei_job_setup,
            stream,
            request_kwargs,
        )

    async def __rpc_ei_job_update(self, stream: grpclib.server.Stream) -> None:
        request_kwargs = {"request_iterator": stream.__aiter__()}

        await self._call_rpc_handler_server_stream(
            self.ei_job_update,
            stream,
            request_kwargs,
        )

    async def __rpc_ei_job_delete(self, stream: grpclib.server.Stream) -> None:
        request_kwargs = {"request_iterator": stream.__aiter__()}

        await self._call_rpc_handler_server_stream(
            self.ei_job_delete,
            stream,
            request_kwargs,
        )

    async def __rpc_ei_job_status_query(self, stream: grpclib.server.Stream) -> None:
        request_kwargs = {"request_iterator": stream.__aiter__()}

        await self._call_rpc_handler_server_stream(
            self.ei_job_status_query,
            stream,
            request_kwargs,
        )

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

        request_kwargs = {
            "header": request.header,
            "message": request.message,
        }

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

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

        request_kwargs = {
            "header": request.header,
            "message": request.message,
        }

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

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/onos.a1t.a1.ei.EIService/EIQuery": grpclib.const.Handler(
                self.__rpc_ei_query,
                grpclib.const.Cardinality.STREAM_STREAM,
                Result,
                Request,
            ),
            "/onos.a1t.a1.ei.EIService/EIJobSetup": grpclib.const.Handler(
                self.__rpc_ei_job_setup,
                grpclib.const.Cardinality.STREAM_STREAM,
                Result,
                Request,
            ),
            "/onos.a1t.a1.ei.EIService/EIJobUpdate": grpclib.const.Handler(
                self.__rpc_ei_job_update,
                grpclib.const.Cardinality.STREAM_STREAM,
                Result,
                Request,
            ),
            "/onos.a1t.a1.ei.EIService/EIJobDelete": grpclib.const.Handler(
                self.__rpc_ei_job_delete,
                grpclib.const.Cardinality.STREAM_STREAM,
                Result,
                Request,
            ),
            "/onos.a1t.a1.ei.EIService/EIJobStatusQuery": grpclib.const.Handler(
                self.__rpc_ei_job_status_query,
                grpclib.const.Cardinality.STREAM_STREAM,
                Result,
                Request,
            ),
            "/onos.a1t.a1.ei.EIService/EIJobStatusNotify": grpclib.const.Handler(
                self.__rpc_ei_job_status_notify,
                grpclib.const.Cardinality.UNARY_UNARY,
                Status,
                Ack,
            ),
            "/onos.a1t.a1.ei.EIService/EIJobResultDelivery": grpclib.const.Handler(
                self.__rpc_ei_job_result_delivery,
                grpclib.const.Cardinality.UNARY_UNARY,
                Result,
                Ack,
            ),
        }


from ... import a1 as __a1__
