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

__all__ = (
    "AddInboundRequest",
    "AddInboundResponse",
    "AddOutboundRequest",
    "AddOutboundResponse",
    "AddUserOperation",
    "AlterInboundRequest",
    "AlterInboundResponse",
    "AlterOutboundRequest",
    "AlterOutboundResponse",
    "Config",
    "GetInboundUserRequest",
    "GetInboundUserResponse",
    "GetInboundUsersCountResponse",
    "ListInboundsRequest",
    "ListInboundsResponse",
    "ListOutboundsRequest",
    "ListOutboundsResponse",
    "RemoveInboundRequest",
    "RemoveInboundResponse",
    "RemoveOutboundRequest",
    "RemoveOutboundResponse",
    "RemoveUserOperation",
    "HandlerServiceStub",
    "HandlerServiceBase",
)

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 AddInboundRequest(betterproto2.Message):
    inbound: "___core__.InboundHandlerConfig | None" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, optional=True
    )


default_message_pool.register_message(
    "xray.app.proxyman.command", "AddInboundRequest", AddInboundRequest
)


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


default_message_pool.register_message(
    "xray.app.proxyman.command", "AddInboundResponse", AddInboundResponse
)


@dataclass(eq=False, repr=False)
class AddOutboundRequest(betterproto2.Message):
    outbound: "___core__.OutboundHandlerConfig | None" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, optional=True
    )


default_message_pool.register_message(
    "xray.app.proxyman.command", "AddOutboundRequest", AddOutboundRequest
)


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


default_message_pool.register_message(
    "xray.app.proxyman.command", "AddOutboundResponse", AddOutboundResponse
)


@dataclass(eq=False, repr=False)
class AddUserOperation(betterproto2.Message):
    user: "___common__protocol__.User | None" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, optional=True
    )


default_message_pool.register_message(
    "xray.app.proxyman.command", "AddUserOperation", AddUserOperation
)


@dataclass(eq=False, repr=False)
class AlterInboundRequest(betterproto2.Message):
    tag: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)

    operation: "___common__serial__.TypedMessage | None" = betterproto2.field(
        2, betterproto2.TYPE_MESSAGE, optional=True
    )


default_message_pool.register_message(
    "xray.app.proxyman.command", "AlterInboundRequest", AlterInboundRequest
)


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


default_message_pool.register_message(
    "xray.app.proxyman.command", "AlterInboundResponse", AlterInboundResponse
)


@dataclass(eq=False, repr=False)
class AlterOutboundRequest(betterproto2.Message):
    tag: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)

    operation: "___common__serial__.TypedMessage | None" = betterproto2.field(
        2, betterproto2.TYPE_MESSAGE, optional=True
    )


default_message_pool.register_message(
    "xray.app.proxyman.command", "AlterOutboundRequest", AlterOutboundRequest
)


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


default_message_pool.register_message(
    "xray.app.proxyman.command", "AlterOutboundResponse", AlterOutboundResponse
)


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


default_message_pool.register_message("xray.app.proxyman.command", "Config", Config)


@dataclass(eq=False, repr=False)
class GetInboundUserRequest(betterproto2.Message):
    tag: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)

    email: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)


default_message_pool.register_message(
    "xray.app.proxyman.command", "GetInboundUserRequest", GetInboundUserRequest
)


@dataclass(eq=False, repr=False)
class GetInboundUserResponse(betterproto2.Message):
    users: "list[___common__protocol__.User]" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, repeated=True
    )


default_message_pool.register_message(
    "xray.app.proxyman.command", "GetInboundUserResponse", GetInboundUserResponse
)


@dataclass(eq=False, repr=False)
class GetInboundUsersCountResponse(betterproto2.Message):
    count: "int" = betterproto2.field(1, betterproto2.TYPE_INT64)


default_message_pool.register_message(
    "xray.app.proxyman.command",
    "GetInboundUsersCountResponse",
    GetInboundUsersCountResponse,
)


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


default_message_pool.register_message(
    "xray.app.proxyman.command", "ListInboundsRequest", ListInboundsRequest
)


@dataclass(eq=False, repr=False)
class ListInboundsResponse(betterproto2.Message):
    inbounds: "list[___core__.InboundHandlerConfig]" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, repeated=True
    )


default_message_pool.register_message(
    "xray.app.proxyman.command", "ListInboundsResponse", ListInboundsResponse
)


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


default_message_pool.register_message(
    "xray.app.proxyman.command", "ListOutboundsRequest", ListOutboundsRequest
)


@dataclass(eq=False, repr=False)
class ListOutboundsResponse(betterproto2.Message):
    outbounds: "list[___core__.OutboundHandlerConfig]" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, repeated=True
    )


default_message_pool.register_message(
    "xray.app.proxyman.command", "ListOutboundsResponse", ListOutboundsResponse
)


@dataclass(eq=False, repr=False)
class RemoveInboundRequest(betterproto2.Message):
    tag: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)


default_message_pool.register_message(
    "xray.app.proxyman.command", "RemoveInboundRequest", RemoveInboundRequest
)


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


default_message_pool.register_message(
    "xray.app.proxyman.command", "RemoveInboundResponse", RemoveInboundResponse
)


@dataclass(eq=False, repr=False)
class RemoveOutboundRequest(betterproto2.Message):
    tag: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)


default_message_pool.register_message(
    "xray.app.proxyman.command", "RemoveOutboundRequest", RemoveOutboundRequest
)


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


default_message_pool.register_message(
    "xray.app.proxyman.command", "RemoveOutboundResponse", RemoveOutboundResponse
)


@dataclass(eq=False, repr=False)
class RemoveUserOperation(betterproto2.Message):
    email: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)


default_message_pool.register_message(
    "xray.app.proxyman.command", "RemoveUserOperation", RemoveUserOperation
)


class HandlerServiceStub(betterproto2.ServiceStub):
    async def add_inbound(
        self,
        message: "AddInboundRequest",
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "AddInboundResponse":
        return await self._unary_unary(
            "/xray.app.proxyman.command.HandlerService/AddInbound",
            message,
            AddInboundResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def remove_inbound(
        self,
        message: "RemoveInboundRequest",
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "RemoveInboundResponse":
        return await self._unary_unary(
            "/xray.app.proxyman.command.HandlerService/RemoveInbound",
            message,
            RemoveInboundResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def alter_inbound(
        self,
        message: "AlterInboundRequest",
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "AlterInboundResponse":
        return await self._unary_unary(
            "/xray.app.proxyman.command.HandlerService/AlterInbound",
            message,
            AlterInboundResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def list_inbounds(
        self,
        message: "ListInboundsRequest | None" = None,
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "ListInboundsResponse":
        if message is None:
            message = ListInboundsRequest()

        return await self._unary_unary(
            "/xray.app.proxyman.command.HandlerService/ListInbounds",
            message,
            ListInboundsResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def get_inbound_users(
        self,
        message: "GetInboundUserRequest",
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "GetInboundUserResponse":
        return await self._unary_unary(
            "/xray.app.proxyman.command.HandlerService/GetInboundUsers",
            message,
            GetInboundUserResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def get_inbound_users_count(
        self,
        message: "GetInboundUserRequest",
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "GetInboundUsersCountResponse":
        return await self._unary_unary(
            "/xray.app.proxyman.command.HandlerService/GetInboundUsersCount",
            message,
            GetInboundUsersCountResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def add_outbound(
        self,
        message: "AddOutboundRequest",
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "AddOutboundResponse":
        return await self._unary_unary(
            "/xray.app.proxyman.command.HandlerService/AddOutbound",
            message,
            AddOutboundResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def remove_outbound(
        self,
        message: "RemoveOutboundRequest",
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "RemoveOutboundResponse":
        return await self._unary_unary(
            "/xray.app.proxyman.command.HandlerService/RemoveOutbound",
            message,
            RemoveOutboundResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def alter_outbound(
        self,
        message: "AlterOutboundRequest",
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "AlterOutboundResponse":
        return await self._unary_unary(
            "/xray.app.proxyman.command.HandlerService/AlterOutbound",
            message,
            AlterOutboundResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def list_outbounds(
        self,
        message: "ListOutboundsRequest | None" = None,
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "ListOutboundsResponse":
        if message is None:
            message = ListOutboundsRequest()

        return await self._unary_unary(
            "/xray.app.proxyman.command.HandlerService/ListOutbounds",
            message,
            ListOutboundsResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


from .... import core as ___core__
from ....common import protocol as ___common__protocol__
from ....common import serial as ___common__serial__


class HandlerServiceBase(ServiceBase):
    async def add_inbound(self, message: "AddInboundRequest") -> "AddInboundResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def remove_inbound(
        self, message: "RemoveInboundRequest"
    ) -> "RemoveInboundResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def alter_inbound(
        self, message: "AlterInboundRequest"
    ) -> "AlterInboundResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def list_inbounds(
        self, message: "ListInboundsRequest"
    ) -> "ListInboundsResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def get_inbound_users(
        self, message: "GetInboundUserRequest"
    ) -> "GetInboundUserResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def get_inbound_users_count(
        self, message: "GetInboundUserRequest"
    ) -> "GetInboundUsersCountResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def add_outbound(
        self, message: "AddOutboundRequest"
    ) -> "AddOutboundResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def remove_outbound(
        self, message: "RemoveOutboundRequest"
    ) -> "RemoveOutboundResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def alter_outbound(
        self, message: "AlterOutboundRequest"
    ) -> "AlterOutboundResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def list_outbounds(
        self, message: "ListOutboundsRequest"
    ) -> "ListOutboundsResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_add_inbound(
        self, stream: "grpclib.server.Stream[AddInboundRequest, AddInboundResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.add_inbound(request)
        await stream.send_message(response)

    async def __rpc_remove_inbound(
        self,
        stream: "grpclib.server.Stream[RemoveInboundRequest, RemoveInboundResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.remove_inbound(request)
        await stream.send_message(response)

    async def __rpc_alter_inbound(
        self, stream: "grpclib.server.Stream[AlterInboundRequest, AlterInboundResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.alter_inbound(request)
        await stream.send_message(response)

    async def __rpc_list_inbounds(
        self, stream: "grpclib.server.Stream[ListInboundsRequest, ListInboundsResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.list_inbounds(request)
        await stream.send_message(response)

    async def __rpc_get_inbound_users(
        self,
        stream: "grpclib.server.Stream[GetInboundUserRequest, GetInboundUserResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.get_inbound_users(request)
        await stream.send_message(response)

    async def __rpc_get_inbound_users_count(
        self,
        stream: "grpclib.server.Stream[GetInboundUserRequest, GetInboundUsersCountResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.get_inbound_users_count(request)
        await stream.send_message(response)

    async def __rpc_add_outbound(
        self, stream: "grpclib.server.Stream[AddOutboundRequest, AddOutboundResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.add_outbound(request)
        await stream.send_message(response)

    async def __rpc_remove_outbound(
        self,
        stream: "grpclib.server.Stream[RemoveOutboundRequest, RemoveOutboundResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.remove_outbound(request)
        await stream.send_message(response)

    async def __rpc_alter_outbound(
        self,
        stream: "grpclib.server.Stream[AlterOutboundRequest, AlterOutboundResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.alter_outbound(request)
        await stream.send_message(response)

    async def __rpc_list_outbounds(
        self,
        stream: "grpclib.server.Stream[ListOutboundsRequest, ListOutboundsResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.list_outbounds(request)
        await stream.send_message(response)

    def __mapping__(self) -> "dict[str, grpclib.const.Handler]":
        return {
            "/xray.app.proxyman.command.HandlerService/AddInbound": grpclib.const.Handler(
                self.__rpc_add_inbound,
                grpclib.const.Cardinality.UNARY_UNARY,
                AddInboundRequest,
                AddInboundResponse,
            ),
            "/xray.app.proxyman.command.HandlerService/RemoveInbound": grpclib.const.Handler(
                self.__rpc_remove_inbound,
                grpclib.const.Cardinality.UNARY_UNARY,
                RemoveInboundRequest,
                RemoveInboundResponse,
            ),
            "/xray.app.proxyman.command.HandlerService/AlterInbound": grpclib.const.Handler(
                self.__rpc_alter_inbound,
                grpclib.const.Cardinality.UNARY_UNARY,
                AlterInboundRequest,
                AlterInboundResponse,
            ),
            "/xray.app.proxyman.command.HandlerService/ListInbounds": grpclib.const.Handler(
                self.__rpc_list_inbounds,
                grpclib.const.Cardinality.UNARY_UNARY,
                ListInboundsRequest,
                ListInboundsResponse,
            ),
            "/xray.app.proxyman.command.HandlerService/GetInboundUsers": grpclib.const.Handler(
                self.__rpc_get_inbound_users,
                grpclib.const.Cardinality.UNARY_UNARY,
                GetInboundUserRequest,
                GetInboundUserResponse,
            ),
            "/xray.app.proxyman.command.HandlerService/GetInboundUsersCount": grpclib.const.Handler(
                self.__rpc_get_inbound_users_count,
                grpclib.const.Cardinality.UNARY_UNARY,
                GetInboundUserRequest,
                GetInboundUsersCountResponse,
            ),
            "/xray.app.proxyman.command.HandlerService/AddOutbound": grpclib.const.Handler(
                self.__rpc_add_outbound,
                grpclib.const.Cardinality.UNARY_UNARY,
                AddOutboundRequest,
                AddOutboundResponse,
            ),
            "/xray.app.proxyman.command.HandlerService/RemoveOutbound": grpclib.const.Handler(
                self.__rpc_remove_outbound,
                grpclib.const.Cardinality.UNARY_UNARY,
                RemoveOutboundRequest,
                RemoveOutboundResponse,
            ),
            "/xray.app.proxyman.command.HandlerService/AlterOutbound": grpclib.const.Handler(
                self.__rpc_alter_outbound,
                grpclib.const.Cardinality.UNARY_UNARY,
                AlterOutboundRequest,
                AlterOutboundResponse,
            ),
            "/xray.app.proxyman.command.HandlerService/ListOutbounds": grpclib.const.Handler(
                self.__rpc_list_outbounds,
                grpclib.const.Cardinality.UNARY_UNARY,
                ListOutboundsRequest,
                ListOutboundsResponse,
            ),
        }
