# -*- coding: utf-8 -*-
# Generated by https://github.com/i2y/connecpy/protoc-gen-connecpy.  DO NOT EDIT!
# source: greeter.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 greeter_pb2 as _pb2

from google.protobuf import symbol_database

_sym_db = symbol_database.Default()


class Greeter(Protocol):
    async def SayHello(
        self, req: _pb2.HelloRequest, ctx: ServiceContext
    ) -> _pb2.HelloReply: ...


class GreeterServer(ConnecpyServer):
    def __init__(self, *, service: Greeter, server_path_prefix=""):
        super().__init__()
        self._prefix = f"{server_path_prefix}/greeter.v1.Greeter"
        self._endpoints = {
            "SayHello": Endpoint[_pb2.HelloRequest, _pb2.HelloReply](
                service_name="Greeter",
                name="SayHello",
                function=getattr(service, "SayHello"),
                input=_pb2.HelloRequest,
                output=_pb2.HelloReply,
            ),
        }

    def serviceName(self):
        return "greeter.v1.Greeter"


class GreeterClient(ConnecpyClient):
    def SayHello(
        self,
        *,
        request: _pb2.HelloRequest,
        ctx: ClientContext,
        server_path_prefix: str = "",
        **kwargs,
    ) -> _pb2.HelloReply:
        return self._make_request(
            url=f"{server_path_prefix}/greeter.v1.Greeter/SayHello",
            ctx=ctx,
            request=request,
            response_obj=_pb2.HelloReply,
            **kwargs,
        )


class AsyncGreeterClient(AsyncConnecpyClient):
    async def SayHello(
        self,
        *,
        request: _pb2.HelloRequest,
        ctx: ClientContext,
        server_path_prefix: str = "",
        session: Union[httpx.AsyncClient, None] = None,
        **kwargs,
    ) -> _pb2.HelloReply:
        return await self._make_request(
            url=f"{server_path_prefix}/greeter.v1.Greeter/SayHello",
            ctx=ctx,
            request=request,
            response_obj=_pb2.HelloReply,
            session=session,
            **kwargs,
        )
