# Generated from soulfire/chat.proto. DO NOT EDIT.
# Generated by protoc-gen-connectrpc-py v0.11.1 with parameter "protobuf=google".
# ruff: noqa: PGH004
# ruff: noqa
# fmt: off
from __future__ import annotations
from typing import Protocol, TYPE_CHECKING
from connectrpc.client import ConnectClient, ConnectClientSync
from connectrpc.code import Code
from connectrpc.compat import google_protobuf_binary_codec, google_protobuf_codecs
from connectrpc.compression.gzip import GzipCompression
from connectrpc.errors import ConnectError
from connectrpc.method import IdempotencyLevel, MethodInfo
from connectrpc.protocol import ProtocolType
from connectrpc.server import ConnectASGIApplication, ConnectWSGIApplication, Endpoint, EndpointSync
from pyqwest import Client, SyncClient
from .chat_pb2 import ChatActionResponse, SendCommandRequest, SendPublicChatRequest, SendWhisperRequest, TabCompleteRequest, TabCompleteResponse
if TYPE_CHECKING:
from collections.abc import AsyncGenerator, Iterable, Mapping
from connectrpc.codec import Codec
from connectrpc.compression import Compression
from connectrpc.interceptor import Interceptor, InterceptorSync
from connectrpc.request import Headers, RequestContext
_DEFAULT_CODECS = google_protobuf_codecs()
_PROTO_BINARY_CODEC = google_protobuf_binary_codec()
_GZIP_COMPRESSION = GzipCompression()
[docs]
class ChatService(Protocol):
[docs]
async def send_public_chat(self, request: SendPublicChatRequest, ctx: RequestContext[SendPublicChatRequest, ChatActionResponse]) -> ChatActionResponse:
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def send_command(self, request: SendCommandRequest, ctx: RequestContext[SendCommandRequest, ChatActionResponse]) -> ChatActionResponse:
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def send_whisper(self, request: SendWhisperRequest, ctx: RequestContext[SendWhisperRequest, ChatActionResponse]) -> ChatActionResponse:
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def tab_complete(self, request: TabCompleteRequest, ctx: RequestContext[TabCompleteRequest, TabCompleteResponse]) -> TabCompleteResponse:
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
class ChatServiceASGIApplication(ConnectASGIApplication[ChatService]):
def __init__(
self,
service: ChatService | AsyncGenerator[ChatService],
*,
interceptors: Iterable[Interceptor] = (),
read_max_bytes: int | None = None,
compressions: Iterable[Compression] | None = None,
codecs: Iterable[Codec] | None = _DEFAULT_CODECS,
) -> None:
super().__init__(
service=service,
endpoints=lambda svc: {
"/soulfire.v1.ChatService/SendPublicChat": Endpoint.unary(
method=MethodInfo(
name="SendPublicChat",
service_name="soulfire.v1.ChatService",
input=SendPublicChatRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
function=svc.send_public_chat,
),
"/soulfire.v1.ChatService/SendCommand": Endpoint.unary(
method=MethodInfo(
name="SendCommand",
service_name="soulfire.v1.ChatService",
input=SendCommandRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
function=svc.send_command,
),
"/soulfire.v1.ChatService/SendWhisper": Endpoint.unary(
method=MethodInfo(
name="SendWhisper",
service_name="soulfire.v1.ChatService",
input=SendWhisperRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
function=svc.send_whisper,
),
"/soulfire.v1.ChatService/TabComplete": Endpoint.unary(
method=MethodInfo(
name="TabComplete",
service_name="soulfire.v1.ChatService",
input=TabCompleteRequest,
output=TabCompleteResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
function=svc.tab_complete,
),
},
interceptors=interceptors,
read_max_bytes=read_max_bytes,
compressions=compressions,
codecs=codecs,
)
@property
def path(self) -> str:
"""Returns the URL path to mount the application to when serving multiple applications."""
return "/soulfire.v1.ChatService"
[docs]
class ChatServiceClient(ConnectClient):
def __init__(
self,
address: str,
*,
codec: Codec | None = _PROTO_BINARY_CODEC,
protocol: ProtocolType = ProtocolType.CONNECT,
accept_compression: Iterable[Compression] | None = None,
send_compression: Compression | None = _GZIP_COMPRESSION,
timeout_ms: int | None = None,
read_max_bytes: int | None = None,
interceptors: Iterable[Interceptor] = (),
http_client: Client | None = None,
) -> None:
super().__init__(
address=address,
codec=codec,
protocol=protocol,
accept_compression=accept_compression,
send_compression=send_compression,
timeout_ms=timeout_ms,
read_max_bytes=read_max_bytes,
interceptors=interceptors,
http_client=http_client,
)
[docs]
async def send_public_chat(
self,
request: SendPublicChatRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> ChatActionResponse:
return await self.execute_unary(
request=request,
method=MethodInfo(
name="SendPublicChat",
service_name="soulfire.v1.ChatService",
input=SendPublicChatRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def send_command(
self,
request: SendCommandRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> ChatActionResponse:
return await self.execute_unary(
request=request,
method=MethodInfo(
name="SendCommand",
service_name="soulfire.v1.ChatService",
input=SendCommandRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def send_whisper(
self,
request: SendWhisperRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> ChatActionResponse:
return await self.execute_unary(
request=request,
method=MethodInfo(
name="SendWhisper",
service_name="soulfire.v1.ChatService",
input=SendWhisperRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def tab_complete(
self,
request: TabCompleteRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> TabCompleteResponse:
return await self.execute_unary(
request=request,
method=MethodInfo(
name="TabComplete",
service_name="soulfire.v1.ChatService",
input=TabCompleteRequest,
output=TabCompleteResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
class ChatServiceSync(Protocol):
[docs]
def send_public_chat(self, request: SendPublicChatRequest, ctx: RequestContext[SendPublicChatRequest, ChatActionResponse]) -> ChatActionResponse:
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def send_command(self, request: SendCommandRequest, ctx: RequestContext[SendCommandRequest, ChatActionResponse]) -> ChatActionResponse:
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def send_whisper(self, request: SendWhisperRequest, ctx: RequestContext[SendWhisperRequest, ChatActionResponse]) -> ChatActionResponse:
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def tab_complete(self, request: TabCompleteRequest, ctx: RequestContext[TabCompleteRequest, TabCompleteResponse]) -> TabCompleteResponse:
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
class ChatServiceWSGIApplication(ConnectWSGIApplication):
def __init__(
self,
service: ChatServiceSync,
interceptors: Iterable[InterceptorSync] = (),
read_max_bytes: int | None = None,
compressions: Iterable[Compression] | None = None,
codecs: Iterable[Codec] | None = _DEFAULT_CODECS,
) -> None:
super().__init__(
endpoints={
"/soulfire.v1.ChatService/SendPublicChat": EndpointSync.unary(
method=MethodInfo(
name="SendPublicChat",
service_name="soulfire.v1.ChatService",
input=SendPublicChatRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
function=service.send_public_chat,
),
"/soulfire.v1.ChatService/SendCommand": EndpointSync.unary(
method=MethodInfo(
name="SendCommand",
service_name="soulfire.v1.ChatService",
input=SendCommandRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
function=service.send_command,
),
"/soulfire.v1.ChatService/SendWhisper": EndpointSync.unary(
method=MethodInfo(
name="SendWhisper",
service_name="soulfire.v1.ChatService",
input=SendWhisperRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
function=service.send_whisper,
),
"/soulfire.v1.ChatService/TabComplete": EndpointSync.unary(
method=MethodInfo(
name="TabComplete",
service_name="soulfire.v1.ChatService",
input=TabCompleteRequest,
output=TabCompleteResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
function=service.tab_complete,
),
},
interceptors=interceptors,
read_max_bytes=read_max_bytes,
compressions=compressions,
codecs=codecs,
)
@property
def path(self) -> str:
"""Returns the URL path to mount the application to when serving multiple applications."""
return "/soulfire.v1.ChatService"
[docs]
class ChatServiceClientSync(ConnectClientSync):
def __init__(
self,
address: str,
*,
codec: Codec | None = _PROTO_BINARY_CODEC,
protocol: ProtocolType = ProtocolType.CONNECT,
accept_compression: Iterable[Compression] | None = None,
send_compression: Compression | None = _GZIP_COMPRESSION,
timeout_ms: int | None = None,
read_max_bytes: int | None = None,
interceptors: Iterable[InterceptorSync] = (),
http_client: SyncClient | None = None,
) -> None:
super().__init__(
address=address,
codec=codec,
protocol=protocol,
accept_compression=accept_compression,
send_compression=send_compression,
timeout_ms=timeout_ms,
read_max_bytes=read_max_bytes,
interceptors=interceptors,
http_client=http_client,
)
[docs]
def send_public_chat(
self,
request: SendPublicChatRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> ChatActionResponse:
return self.execute_unary(
request=request,
method=MethodInfo(
name="SendPublicChat",
service_name="soulfire.v1.ChatService",
input=SendPublicChatRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def send_command(
self,
request: SendCommandRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> ChatActionResponse:
return self.execute_unary(
request=request,
method=MethodInfo(
name="SendCommand",
service_name="soulfire.v1.ChatService",
input=SendCommandRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def send_whisper(
self,
request: SendWhisperRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> ChatActionResponse:
return self.execute_unary(
request=request,
method=MethodInfo(
name="SendWhisper",
service_name="soulfire.v1.ChatService",
input=SendWhisperRequest,
output=ChatActionResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def tab_complete(
self,
request: TabCompleteRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> TabCompleteResponse:
return self.execute_unary(
request=request,
method=MethodInfo(
name="TabComplete",
service_name="soulfire.v1.ChatService",
input=TabCompleteRequest,
output=TabCompleteResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
),
headers=headers,
timeout_ms=timeout_ms,
)