# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: app/observatory/command/command.proto
# plugin: python-betterproto2
# This file has been @generated

__all__ = (
    "Config",
    "GetOutboundStatusRequest",
    "GetOutboundStatusResponse",
    "ObservatoryServiceStub",
    "ObservatoryServiceBase",
)

from dataclasses import dataclass
from typing import TYPE_CHECKING

import betterproto2
import grpclib
from betterproto2.grpc.grpclib_server import ServiceBase

from ......message_pool import default_message_pool

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

betterproto2.check_compiler_version("0.5.1")


@dataclass(eq=False, repr=False)
class Config(betterproto2.Message):
    pass


default_message_pool.register_message(
    "xray.core.app.observatory.command", "Config", Config
)


@dataclass(eq=False, repr=False)
class GetOutboundStatusRequest(betterproto2.Message):
    pass


default_message_pool.register_message(
    "xray.core.app.observatory.command",
    "GetOutboundStatusRequest",
    GetOutboundStatusRequest,
)


@dataclass(eq=False, repr=False)
class GetOutboundStatusResponse(betterproto2.Message):
    status: "__observatory__.ObservationResult | None" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, optional=True
    )


default_message_pool.register_message(
    "xray.core.app.observatory.command",
    "GetOutboundStatusResponse",
    GetOutboundStatusResponse,
)


class ObservatoryServiceStub(betterproto2.ServiceStub):
    async def get_outbound_status(
        self,
        message: "GetOutboundStatusRequest | None" = None,
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "GetOutboundStatusResponse":
        if message is None:
            message = GetOutboundStatusRequest()

        return await self._unary_unary(
            "/xray.core.app.observatory.command.ObservatoryService/GetOutboundStatus",
            message,
            GetOutboundStatusResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


from ... import observatory as __observatory__


class ObservatoryServiceBase(ServiceBase):
    async def get_outbound_status(
        self, message: "GetOutboundStatusRequest"
    ) -> "GetOutboundStatusResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_get_outbound_status(
        self,
        stream: "grpclib.server.Stream[GetOutboundStatusRequest, GetOutboundStatusResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.get_outbound_status(request)
        await stream.send_message(response)

    def __mapping__(self) -> "dict[str, grpclib.const.Handler]":
        return {
            "/xray.core.app.observatory.command.ObservatoryService/GetOutboundStatus": grpclib.const.Handler(
                self.__rpc_get_outbound_status,
                grpclib.const.Cardinality.UNARY_UNARY,
                GetOutboundStatusRequest,
                GetOutboundStatusResponse,
            ),
        }
