# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: deprecated.proto
# plugin: python-betterproto
# This file has been @generated

__all__ = (
    "Test",
    "Message",
    "Empty",
    "TestServiceStub",
    "TestServiceBase",
)

import warnings
from dataclasses import dataclass
from typing import (
    TYPE_CHECKING,
    Dict,
    Optional,
)

import grpclib

import betterproto
from betterproto.grpc.grpclib_server import ServiceBase


if TYPE_CHECKING:
    import grpclib.server
    from grpclib.metadata import Deadline

    from betterproto.grpc.grpclib_client import MetadataLike


@dataclass(eq=False, repr=False)
class Test(betterproto.Message):
    """Some documentation about the Test message."""

    message: "Message" = betterproto.message_field(1)
    """
    
    """

    value: int = betterproto.int32_field(2)
    """
    
    """

    def __post_init__(self) -> None:
        super().__post_init__()
        if self.is_set("message"):
            warnings.warn("Test.message is deprecated", DeprecationWarning)


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

    value: str = betterproto.string_field(1)
    """
    
    """

    def __post_init__(self) -> None:
        warnings.warn("Message is deprecated", DeprecationWarning)
        super().__post_init__()


@dataclass(eq=False, repr=False)
class Empty(betterproto.Message):
    """ """

    pass


class TestServiceStub(betterproto.ServiceStub):
    """ """

    async def func(
        self,
        empty: "Empty",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "Empty":
        """ """

        return await self._unary_unary(
            "/deprecated.TestService/func",
            empty,
            Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def deprecated_func(
        self,
        empty: "Empty",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "Empty":
        """ """

        warnings.warn("TestService.deprecated_func is deprecated", DeprecationWarning)

        return await self._unary_unary(
            "/deprecated.TestService/deprecated_func",
            empty,
            Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


class TestServiceBase(ServiceBase):
    """ """

    async def func(self, empty: "Empty") -> "Empty":
        """ """

        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def deprecated_func(self, empty: "Empty") -> "Empty":
        """ """

        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

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

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

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/deprecated.TestService/func": grpclib.const.Handler(
                self.__rpc_func,
                grpclib.const.Cardinality.UNARY_UNARY,
                Empty,
                Empty,
            ),
            "/deprecated.TestService/deprecated_func": grpclib.const.Handler(
                self.__rpc_deprecated_func,
                grpclib.const.Cardinality.UNARY_UNARY,
                Empty,
                Empty,
            ),
        }
