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

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

from ... import client as __client__

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


class ScavengeRespScavengeResult(betterproto.Enum):
    Started = 0
    InProgress = 1
    Stopped = 2


@dataclass(eq=False, repr=False)
class StartScavengeReq(betterproto.Message):
    options: "StartScavengeReqOptions" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class StartScavengeReqOptions(betterproto.Message):
    thread_count: int = betterproto.int32_field(1)
    start_from_chunk: int = betterproto.int32_field(2)


@dataclass(eq=False, repr=False)
class StopScavengeReq(betterproto.Message):
    options: "StopScavengeReqOptions" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class StopScavengeReqOptions(betterproto.Message):
    scavenge_id: str = betterproto.string_field(1)


@dataclass(eq=False, repr=False)
class ScavengeResp(betterproto.Message):
    scavenge_id: str = betterproto.string_field(1)
    scavenge_result: "ScavengeRespScavengeResult" = betterproto.enum_field(2)


@dataclass(eq=False, repr=False)
class SetNodePriorityReq(betterproto.Message):
    priority: int = betterproto.int32_field(1)


class OperationsStub(betterproto.ServiceStub):
    async def start_scavenge(
        self,
        start_scavenge_req: "StartScavengeReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "ScavengeResp":
        return await self._unary_unary(
            "/event_store.client.operations.Operations/StartScavenge",
            start_scavenge_req,
            ScavengeResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def stop_scavenge(
        self,
        stop_scavenge_req: "StopScavengeReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "ScavengeResp":
        return await self._unary_unary(
            "/event_store.client.operations.Operations/StopScavenge",
            stop_scavenge_req,
            ScavengeResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def shutdown(
        self,
        client_empty: "__client__.Empty",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "__client__.Empty":
        return await self._unary_unary(
            "/event_store.client.operations.Operations/Shutdown",
            client_empty,
            __client__.Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def merge_indexes(
        self,
        client_empty: "__client__.Empty",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "__client__.Empty":
        return await self._unary_unary(
            "/event_store.client.operations.Operations/MergeIndexes",
            client_empty,
            __client__.Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def resign_node(
        self,
        client_empty: "__client__.Empty",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "__client__.Empty":
        return await self._unary_unary(
            "/event_store.client.operations.Operations/ResignNode",
            client_empty,
            __client__.Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def set_node_priority(
        self,
        set_node_priority_req: "SetNodePriorityReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "__client__.Empty":
        return await self._unary_unary(
            "/event_store.client.operations.Operations/SetNodePriority",
            set_node_priority_req,
            __client__.Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def restart_persistent_subscriptions(
        self,
        client_empty: "__client__.Empty",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "__client__.Empty":
        return await self._unary_unary(
            "/event_store.client.operations.Operations/RestartPersistentSubscriptions",
            client_empty,
            __client__.Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


class OperationsBase(ServiceBase):
    async def start_scavenge(
        self, start_scavenge_req: "StartScavengeReq"
    ) -> "ScavengeResp":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def stop_scavenge(
        self, stop_scavenge_req: "StopScavengeReq"
    ) -> "ScavengeResp":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def shutdown(self, client_empty: "__client__.Empty") -> "__client__.Empty":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def merge_indexes(
        self, client_empty: "__client__.Empty"
    ) -> "__client__.Empty":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def resign_node(self, client_empty: "__client__.Empty") -> "__client__.Empty":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def set_node_priority(
        self, set_node_priority_req: "SetNodePriorityReq"
    ) -> "__client__.Empty":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def restart_persistent_subscriptions(
        self, client_empty: "__client__.Empty"
    ) -> "__client__.Empty":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_start_scavenge(
        self, stream: "grpclib.server.Stream[StartScavengeReq, ScavengeResp]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.start_scavenge(request)
        await stream.send_message(response)

    async def __rpc_stop_scavenge(
        self, stream: "grpclib.server.Stream[StopScavengeReq, ScavengeResp]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.stop_scavenge(request)
        await stream.send_message(response)

    async def __rpc_shutdown(
        self, stream: "grpclib.server.Stream[__client__.Empty, __client__.Empty]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.shutdown(request)
        await stream.send_message(response)

    async def __rpc_merge_indexes(
        self, stream: "grpclib.server.Stream[__client__.Empty, __client__.Empty]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.merge_indexes(request)
        await stream.send_message(response)

    async def __rpc_resign_node(
        self, stream: "grpclib.server.Stream[__client__.Empty, __client__.Empty]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.resign_node(request)
        await stream.send_message(response)

    async def __rpc_set_node_priority(
        self, stream: "grpclib.server.Stream[SetNodePriorityReq, __client__.Empty]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.set_node_priority(request)
        await stream.send_message(response)

    async def __rpc_restart_persistent_subscriptions(
        self, stream: "grpclib.server.Stream[__client__.Empty, __client__.Empty]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.restart_persistent_subscriptions(request)
        await stream.send_message(response)

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/event_store.client.operations.Operations/StartScavenge": grpclib.const.Handler(
                self.__rpc_start_scavenge,
                grpclib.const.Cardinality.UNARY_UNARY,
                StartScavengeReq,
                ScavengeResp,
            ),
            "/event_store.client.operations.Operations/StopScavenge": grpclib.const.Handler(
                self.__rpc_stop_scavenge,
                grpclib.const.Cardinality.UNARY_UNARY,
                StopScavengeReq,
                ScavengeResp,
            ),
            "/event_store.client.operations.Operations/Shutdown": grpclib.const.Handler(
                self.__rpc_shutdown,
                grpclib.const.Cardinality.UNARY_UNARY,
                __client__.Empty,
                __client__.Empty,
            ),
            "/event_store.client.operations.Operations/MergeIndexes": grpclib.const.Handler(
                self.__rpc_merge_indexes,
                grpclib.const.Cardinality.UNARY_UNARY,
                __client__.Empty,
                __client__.Empty,
            ),
            "/event_store.client.operations.Operations/ResignNode": grpclib.const.Handler(
                self.__rpc_resign_node,
                grpclib.const.Cardinality.UNARY_UNARY,
                __client__.Empty,
                __client__.Empty,
            ),
            "/event_store.client.operations.Operations/SetNodePriority": grpclib.const.Handler(
                self.__rpc_set_node_priority,
                grpclib.const.Cardinality.UNARY_UNARY,
                SetNodePriorityReq,
                __client__.Empty,
            ),
            "/event_store.client.operations.Operations/RestartPersistentSubscriptions": grpclib.const.Handler(
                self.__rpc_restart_persistent_subscriptions,
                grpclib.const.Cardinality.UNARY_UNARY,
                __client__.Empty,
                __client__.Empty,
            ),
        }
