# -*- coding: utf-8 -*-
# Generated by https://github.com/i2y/connecpy/protoc-gen-connecpy.  DO NOT EDIT!
# source: echoservice.proto

from typing import Any, Protocol, Union

import httpx

from connecpy.async_client import AsyncConnecpyClient
from connecpy.base import Endpoint
from connecpy.server import ConnecpyServer
from connecpy.client import ConnecpyClient
from connecpy.context import ClientContext, ServiceContext

import echoservice_pb2 as _pb2

from google.protobuf import symbol_database

_sym_db = symbol_database.Default()


class EchoService(Protocol):
    async def Echo(self, req: _pb2.EchoRequest, ctx: ServiceContext) -> _pb2.EchoResponse: ...


class EchoServiceServer(ConnecpyServer):
    def __init__(self, *, service: EchoService, server_path_prefix=""):
        super().__init__()
        self._prefix = f"{server_path_prefix}/echo.v1.EchoService"
        self._endpoints = {
            "Echo": Endpoint[_pb2.EchoRequest, _pb2.EchoResponse](
                service_name="EchoService",
                name="Echo",
                function=getattr(service, "Echo"),
                input=_pb2.EchoRequest,
                output=_pb2.EchoResponse,
            ),
        }

    def serviceName(self):
        return "echo.v1.EchoService"


class EchoServiceSync(Protocol):
    def Echo(self, req: _pb2.EchoRequest, ctx: ServiceContext) -> _pb2.EchoResponse: ...


class EchoServiceServerSync(ConnecpyServer):
    def __init__(self, *, service: EchoServiceSync, server_path_prefix=""):
        super().__init__()
        self._prefix = f"{server_path_prefix}/echo.v1.EchoService"
        self._endpoints = {
            "Echo": Endpoint[_pb2.EchoRequest, _pb2.EchoResponse](
                service_name="EchoService",
                name="Echo",
                function=getattr(service, "Echo"),
                input=_pb2.EchoRequest,
                output=_pb2.EchoResponse,
            ),
        }

    def serviceName(self):
        return "echo.v1.EchoService"


class EchoServiceClient(ConnecpyClient):
    def Echo(
        self,
        *,
        request: _pb2.EchoRequest,
        ctx: ClientContext,
        server_path_prefix: str = "",
        **kwargs,
    ) -> _pb2.EchoResponse:
        return self._make_request(
            url=f"{server_path_prefix}/echo.v1.EchoService/Echo",
            ctx=ctx,
            request=request,
            response_obj=_pb2.EchoResponse,
            **kwargs,
        )


class AsyncEchoServiceClient(AsyncConnecpyClient):
    async def Echo(
        self,
        *,
        request: _pb2.EchoRequest,
        ctx: ClientContext,
        server_path_prefix: str = "",
        session: Union[httpx.AsyncClient, None] = None,
        **kwargs,
    ) -> _pb2.EchoResponse:
        return await self._make_request(
            url=f"{server_path_prefix}/echo.v1.EchoService/Echo",
            ctx=ctx,
            request=request,
            response_obj=_pb2.EchoResponse,
            session=session,
            **kwargs,
        )
