# -*- coding: utf-8 -*-
# Generated by https://github.com/connectrpc/connect-python.  DO NOT EDIT!
# source: chatto/discovery/v1/server.proto

from collections.abc import AsyncGenerator, AsyncIterator, Iterable, Iterator, Mapping
from typing import Protocol

from connectrpc.client import ConnectClient, ConnectClientSync
from connectrpc.code import Code
from connectrpc.compression import Compression
from connectrpc.errors import ConnectError
from connectrpc.interceptor import Interceptor, InterceptorSync
from connectrpc.method import IdempotencyLevel, MethodInfo
from connectrpc.request import Headers, RequestContext
from connectrpc.server import ConnectASGIApplication, ConnectWSGIApplication, Endpoint, EndpointSync
import chatto.discovery.v1.server_pb2 as chatto_dot_discovery_dot_v1_dot_server__pb2


class ServerDiscoveryService(Protocol):
    async def get_server(self, request: chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerRequest, ctx: RequestContext) -> chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class ServerDiscoveryServiceASGIApplication(ConnectASGIApplication[ServerDiscoveryService]):
    def __init__(self, service: ServerDiscoveryService | AsyncGenerator[ServerDiscoveryService], *, interceptors: Iterable[Interceptor]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
        super().__init__(
            service=service,
            endpoints=lambda svc: {
                "/chatto.discovery.v1.ServerDiscoveryService/GetServer": Endpoint.unary(
                    method=MethodInfo(
                        name="GetServer",
                        service_name="chatto.discovery.v1.ServerDiscoveryService",
                        input=chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerRequest,
                        output=chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.get_server,
                ),
            },
            interceptors=interceptors,
            read_max_bytes=read_max_bytes,
            compressions=compressions,
        )

    @property
    def path(self) -> str:
        """Returns the URL path to mount the application to when serving multiple applications."""
        return "/chatto.discovery.v1.ServerDiscoveryService"


class ServerDiscoveryServiceClient(ConnectClient):
    async def get_server(
        self,
        request: chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetServer",
                service_name="chatto.discovery.v1.ServerDiscoveryService",
                input=chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerRequest,
                output=chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )


class ServerDiscoveryServiceSync(Protocol):
    def get_server(self, request: chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerRequest, ctx: RequestContext) -> chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class ServerDiscoveryServiceWSGIApplication(ConnectWSGIApplication):
    def __init__(self, service: ServerDiscoveryServiceSync, interceptors: Iterable[InterceptorSync]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
        super().__init__(
            endpoints={
                "/chatto.discovery.v1.ServerDiscoveryService/GetServer": EndpointSync.unary(
                    method=MethodInfo(
                        name="GetServer",
                        service_name="chatto.discovery.v1.ServerDiscoveryService",
                        input=chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerRequest,
                        output=chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.get_server,
                ),
            },
            interceptors=interceptors,
            read_max_bytes=read_max_bytes,
            compressions=compressions,
        )

    @property
    def path(self) -> str:
        """Returns the URL path to mount the application to when serving multiple applications."""
        return "/chatto.discovery.v1.ServerDiscoveryService"


class ServerDiscoveryServiceClientSync(ConnectClientSync):
    def get_server(
        self,
        request: chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetServer",
                service_name="chatto.discovery.v1.ServerDiscoveryService",
                input=chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerRequest,
                output=chatto_dot_discovery_dot_v1_dot_server__pb2.GetServerResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
