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


class ViewerService(Protocol):
    async def get_viewer(self, request: chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class ViewerServiceASGIApplication(ConnectASGIApplication[ViewerService]):
    def __init__(self, service: ViewerService | AsyncGenerator[ViewerService], *, 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.ViewerService/GetViewer": Endpoint.unary(
                    method=MethodInfo(
                        name="GetViewer",
                        service_name="chatto.api.v1.ViewerService",
                        input=chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerRequest,
                        output=chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.get_viewer,
                ),
            },
            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.ViewerService"


class ViewerServiceClient(ConnectClient):
    async def get_viewer(
        self,
        request: chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetViewer",
                service_name="chatto.api.v1.ViewerService",
                input=chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerRequest,
                output=chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )


class ViewerServiceSync(Protocol):
    def get_viewer(self, request: chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class ViewerServiceWSGIApplication(ConnectWSGIApplication):
    def __init__(self, service: ViewerServiceSync, interceptors: Iterable[InterceptorSync]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
        super().__init__(
            endpoints={
                "/chatto.api.v1.ViewerService/GetViewer": EndpointSync.unary(
                    method=MethodInfo(
                        name="GetViewer",
                        service_name="chatto.api.v1.ViewerService",
                        input=chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerRequest,
                        output=chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.get_viewer,
                ),
            },
            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.ViewerService"


class ViewerServiceClientSync(ConnectClientSync):
    def get_viewer(
        self,
        request: chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetViewer",
                service_name="chatto.api.v1.ViewerService",
                input=chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerRequest,
                output=chatto_dot_api_dot_v1_dot_viewer__pb2.GetViewerResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
