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


class RoleService(Protocol):
    async def list_roles(self, request: chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def get_role(self, request: chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def batch_get_roles(self, request: chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class RoleServiceASGIApplication(ConnectASGIApplication[RoleService]):
    def __init__(self, service: RoleService | AsyncGenerator[RoleService], *, 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.RoleService/ListRoles": Endpoint.unary(
                    method=MethodInfo(
                        name="ListRoles",
                        service_name="chatto.api.v1.RoleService",
                        input=chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesRequest,
                        output=chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.list_roles,
                ),
                "/chatto.api.v1.RoleService/GetRole": Endpoint.unary(
                    method=MethodInfo(
                        name="GetRole",
                        service_name="chatto.api.v1.RoleService",
                        input=chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleRequest,
                        output=chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.get_role,
                ),
                "/chatto.api.v1.RoleService/BatchGetRoles": Endpoint.unary(
                    method=MethodInfo(
                        name="BatchGetRoles",
                        service_name="chatto.api.v1.RoleService",
                        input=chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesRequest,
                        output=chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.batch_get_roles,
                ),
            },
            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.RoleService"


class RoleServiceClient(ConnectClient):
    async def list_roles(
        self,
        request: chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="ListRoles",
                service_name="chatto.api.v1.RoleService",
                input=chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesRequest,
                output=chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def get_role(
        self,
        request: chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetRole",
                service_name="chatto.api.v1.RoleService",
                input=chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleRequest,
                output=chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def batch_get_roles(
        self,
        request: chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="BatchGetRoles",
                service_name="chatto.api.v1.RoleService",
                input=chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesRequest,
                output=chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )


class RoleServiceSync(Protocol):
    def list_roles(self, request: chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def get_role(self, request: chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def batch_get_roles(self, request: chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class RoleServiceWSGIApplication(ConnectWSGIApplication):
    def __init__(self, service: RoleServiceSync, interceptors: Iterable[InterceptorSync]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
        super().__init__(
            endpoints={
                "/chatto.api.v1.RoleService/ListRoles": EndpointSync.unary(
                    method=MethodInfo(
                        name="ListRoles",
                        service_name="chatto.api.v1.RoleService",
                        input=chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesRequest,
                        output=chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.list_roles,
                ),
                "/chatto.api.v1.RoleService/GetRole": EndpointSync.unary(
                    method=MethodInfo(
                        name="GetRole",
                        service_name="chatto.api.v1.RoleService",
                        input=chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleRequest,
                        output=chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.get_role,
                ),
                "/chatto.api.v1.RoleService/BatchGetRoles": EndpointSync.unary(
                    method=MethodInfo(
                        name="BatchGetRoles",
                        service_name="chatto.api.v1.RoleService",
                        input=chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesRequest,
                        output=chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.batch_get_roles,
                ),
            },
            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.RoleService"


class RoleServiceClientSync(ConnectClientSync):
    def list_roles(
        self,
        request: chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="ListRoles",
                service_name="chatto.api.v1.RoleService",
                input=chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesRequest,
                output=chatto_dot_api_dot_v1_dot_roles__pb2.ListRolesResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def get_role(
        self,
        request: chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetRole",
                service_name="chatto.api.v1.RoleService",
                input=chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleRequest,
                output=chatto_dot_api_dot_v1_dot_roles__pb2.GetRoleResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def batch_get_roles(
        self,
        request: chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="BatchGetRoles",
                service_name="chatto.api.v1.RoleService",
                input=chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesRequest,
                output=chatto_dot_api_dot_v1_dot_roles__pb2.BatchGetRolesResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
