# -*- coding: utf-8 -*-
# Generated by https://github.com/connectrpc/connect-python.  DO NOT EDIT!
# source: chatto/api/v1/server_state.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.api.v1.server_state_pb2 as chatto_dot_api_dot_v1_dot_server__state__pb2


class ServerService(Protocol):
    async def get_motd(self, request: chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def get_runtime_config(self, request: chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class ServerServiceASGIApplication(ConnectASGIApplication[ServerService]):
    def __init__(self, service: ServerService | AsyncGenerator[ServerService], *, interceptors: Iterable[Interceptor]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
        super().__init__(
            service=service,
            endpoints=lambda svc: {
                "/chatto.api.v1.ServerService/GetMotd": Endpoint.unary(
                    method=MethodInfo(
                        name="GetMotd",
                        service_name="chatto.api.v1.ServerService",
                        input=chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdRequest,
                        output=chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.get_motd,
                ),
                "/chatto.api.v1.ServerService/GetRuntimeConfig": Endpoint.unary(
                    method=MethodInfo(
                        name="GetRuntimeConfig",
                        service_name="chatto.api.v1.ServerService",
                        input=chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigRequest,
                        output=chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.get_runtime_config,
                ),
            },
            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.api.v1.ServerService"


class ServerServiceClient(ConnectClient):
    async def get_motd(
        self,
        request: chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetMotd",
                service_name="chatto.api.v1.ServerService",
                input=chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdRequest,
                output=chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def get_runtime_config(
        self,
        request: chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetRuntimeConfig",
                service_name="chatto.api.v1.ServerService",
                input=chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigRequest,
                output=chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )


class ServerServiceSync(Protocol):
    def get_motd(self, request: chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def get_runtime_config(self, request: chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class ServerServiceWSGIApplication(ConnectWSGIApplication):
    def __init__(self, service: ServerServiceSync, interceptors: Iterable[InterceptorSync]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
        super().__init__(
            endpoints={
                "/chatto.api.v1.ServerService/GetMotd": EndpointSync.unary(
                    method=MethodInfo(
                        name="GetMotd",
                        service_name="chatto.api.v1.ServerService",
                        input=chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdRequest,
                        output=chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.get_motd,
                ),
                "/chatto.api.v1.ServerService/GetRuntimeConfig": EndpointSync.unary(
                    method=MethodInfo(
                        name="GetRuntimeConfig",
                        service_name="chatto.api.v1.ServerService",
                        input=chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigRequest,
                        output=chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.get_runtime_config,
                ),
            },
            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.api.v1.ServerService"


class ServerServiceClientSync(ConnectClientSync):
    def get_motd(
        self,
        request: chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetMotd",
                service_name="chatto.api.v1.ServerService",
                input=chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdRequest,
                output=chatto_dot_api_dot_v1_dot_server__state__pb2.GetMotdResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def get_runtime_config(
        self,
        request: chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetRuntimeConfig",
                service_name="chatto.api.v1.ServerService",
                input=chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigRequest,
                output=chatto_dot_api_dot_v1_dot_server__state__pb2.GetRuntimeConfigResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
