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


class UserService(Protocol):
    async def list_users(self, request: chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def get_user(self, request: chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def batch_get_users(self, request: chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class UserServiceASGIApplication(ConnectASGIApplication[UserService]):
    def __init__(self, service: UserService | AsyncGenerator[UserService], *, 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.UserService/ListUsers": Endpoint.unary(
                    method=MethodInfo(
                        name="ListUsers",
                        service_name="chatto.api.v1.UserService",
                        input=chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersRequest,
                        output=chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.list_users,
                ),
                "/chatto.api.v1.UserService/GetUser": Endpoint.unary(
                    method=MethodInfo(
                        name="GetUser",
                        service_name="chatto.api.v1.UserService",
                        input=chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserRequest,
                        output=chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.get_user,
                ),
                "/chatto.api.v1.UserService/BatchGetUsers": Endpoint.unary(
                    method=MethodInfo(
                        name="BatchGetUsers",
                        service_name="chatto.api.v1.UserService",
                        input=chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersRequest,
                        output=chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.batch_get_users,
                ),
            },
            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.UserService"


class UserServiceClient(ConnectClient):
    async def list_users(
        self,
        request: chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="ListUsers",
                service_name="chatto.api.v1.UserService",
                input=chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersRequest,
                output=chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def get_user(
        self,
        request: chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetUser",
                service_name="chatto.api.v1.UserService",
                input=chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserRequest,
                output=chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def batch_get_users(
        self,
        request: chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="BatchGetUsers",
                service_name="chatto.api.v1.UserService",
                input=chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersRequest,
                output=chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )


class UserServiceSync(Protocol):
    def list_users(self, request: chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def get_user(self, request: chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def batch_get_users(self, request: chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class UserServiceWSGIApplication(ConnectWSGIApplication):
    def __init__(self, service: UserServiceSync, interceptors: Iterable[InterceptorSync]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
        super().__init__(
            endpoints={
                "/chatto.api.v1.UserService/ListUsers": EndpointSync.unary(
                    method=MethodInfo(
                        name="ListUsers",
                        service_name="chatto.api.v1.UserService",
                        input=chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersRequest,
                        output=chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.list_users,
                ),
                "/chatto.api.v1.UserService/GetUser": EndpointSync.unary(
                    method=MethodInfo(
                        name="GetUser",
                        service_name="chatto.api.v1.UserService",
                        input=chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserRequest,
                        output=chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.get_user,
                ),
                "/chatto.api.v1.UserService/BatchGetUsers": EndpointSync.unary(
                    method=MethodInfo(
                        name="BatchGetUsers",
                        service_name="chatto.api.v1.UserService",
                        input=chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersRequest,
                        output=chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.batch_get_users,
                ),
            },
            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.UserService"


class UserServiceClientSync(ConnectClientSync):
    def list_users(
        self,
        request: chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="ListUsers",
                service_name="chatto.api.v1.UserService",
                input=chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersRequest,
                output=chatto_dot_api_dot_v1_dot_member__directory__pb2.ListUsersResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def get_user(
        self,
        request: chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetUser",
                service_name="chatto.api.v1.UserService",
                input=chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserRequest,
                output=chatto_dot_api_dot_v1_dot_member__directory__pb2.GetUserResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def batch_get_users(
        self,
        request: chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="BatchGetUsers",
                service_name="chatto.api.v1.UserService",
                input=chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersRequest,
                output=chatto_dot_api_dot_v1_dot_member__directory__pb2.BatchGetUsersResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
