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

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

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


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


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


@dataclass(eq=False, repr=False)
class Output(betterproto.Message):
    double_value: Optional[float] = betterproto.message_field(
        1, wraps=betterproto.TYPE_DOUBLE
    )
    float_value: Optional[float] = betterproto.message_field(
        2, wraps=betterproto.TYPE_FLOAT
    )
    int64_value: Optional[int] = betterproto.message_field(
        3, wraps=betterproto.TYPE_INT64
    )
    uint64_value: Optional[int] = betterproto.message_field(
        4, wraps=betterproto.TYPE_UINT64
    )
    int32_value: Optional[int] = betterproto.message_field(
        5, wraps=betterproto.TYPE_INT32
    )
    uint32_value: Optional[int] = betterproto.message_field(
        6, wraps=betterproto.TYPE_UINT32
    )
    bool_value: Optional[bool] = betterproto.message_field(
        7, wraps=betterproto.TYPE_BOOL
    )
    string_value: Optional[str] = betterproto.message_field(
        8, wraps=betterproto.TYPE_STRING
    )
    bytes_value: Optional[bytes] = betterproto.message_field(
        9, wraps=betterproto.TYPE_BYTES
    )


class TestStub(betterproto.ServiceStub):
    async def get_output(
        self,
        input: "Input",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "Output":
        return await self._unary_unary(
            "/googletypes_response_embedded.Test/getOutput",
            input,
            Output,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


class TestBase(ServiceBase):
    async def get_output(self, input: "Input") -> "Output":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_get_output(
        self, stream: "grpclib.server.Stream[Input, Output]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.get_output(request)
        await stream.send_message(response)

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/googletypes_response_embedded.Test/getOutput": grpclib.const.Handler(
                self.__rpc_get_output,
                grpclib.const.Cardinality.UNARY_UNARY,
                Input,
                Output,
            ),
        }
