# Generated from soulfire/protocol.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 .protocol_pb2 import BotProtocolInfo, BotProtocolRequest, ListPacketSchemasRequest, ListPacketSchemasResponse, RawPacketEvent, SendRawPacketRequest, SendRawPacketResponse, WatchPacketsRequest

if TYPE_CHECKING:
    from collections.abc import AsyncGenerator, AsyncIterator, Iterable, Iterator, 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()

class BotProtocolService(Protocol):
    async def get_protocol_info(self, request: BotProtocolRequest, ctx: RequestContext[BotProtocolRequest, BotProtocolInfo]) -> BotProtocolInfo:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    async def list_packet_schemas(self, request: ListPacketSchemasRequest, ctx: RequestContext[ListPacketSchemasRequest, ListPacketSchemasResponse]) -> ListPacketSchemasResponse:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def watch_packets(self, request: WatchPacketsRequest, ctx: RequestContext[WatchPacketsRequest, RawPacketEvent]) -> AsyncIterator[RawPacketEvent]:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    async def send_raw_packet(self, request: SendRawPacketRequest, ctx: RequestContext[SendRawPacketRequest, SendRawPacketResponse]) -> SendRawPacketResponse:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')


class BotProtocolServiceASGIApplication(ConnectASGIApplication[BotProtocolService]):
    def __init__(
        self,
        service: BotProtocolService | AsyncGenerator[BotProtocolService],
        *,
        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.BotProtocolService/GetProtocolInfo": Endpoint.unary(
                    method=MethodInfo(
                        name="GetProtocolInfo",
                        service_name="soulfire.v1.BotProtocolService",
                        input=BotProtocolRequest,
                        output=BotProtocolInfo,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.get_protocol_info,
                ),
                "/soulfire.v1.BotProtocolService/ListPacketSchemas": Endpoint.unary(
                    method=MethodInfo(
                        name="ListPacketSchemas",
                        service_name="soulfire.v1.BotProtocolService",
                        input=ListPacketSchemasRequest,
                        output=ListPacketSchemasResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.list_packet_schemas,
                ),
                "/soulfire.v1.BotProtocolService/WatchPackets": Endpoint.server_stream(
                    method=MethodInfo(
                        name="WatchPackets",
                        service_name="soulfire.v1.BotProtocolService",
                        input=WatchPacketsRequest,
                        output=RawPacketEvent,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.watch_packets,
                ),
                "/soulfire.v1.BotProtocolService/SendRawPacket": Endpoint.unary(
                    method=MethodInfo(
                        name="SendRawPacket",
                        service_name="soulfire.v1.BotProtocolService",
                        input=SendRawPacketRequest,
                        output=SendRawPacketResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.send_raw_packet,
                ),
            },
            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.BotProtocolService"


class BotProtocolServiceClient(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,
        )
    async def get_protocol_info(
        self,
        request: BotProtocolRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> BotProtocolInfo:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetProtocolInfo",
                service_name="soulfire.v1.BotProtocolService",
                input=BotProtocolRequest,
                output=BotProtocolInfo,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def list_packet_schemas(
        self,
        request: ListPacketSchemasRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> ListPacketSchemasResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="ListPacketSchemas",
                service_name="soulfire.v1.BotProtocolService",
                input=ListPacketSchemasRequest,
                output=ListPacketSchemasResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def watch_packets(
        self,
        request: WatchPacketsRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> AsyncIterator[RawPacketEvent]:
        return self.execute_server_stream(
            request=request,
            method=MethodInfo(
                name="WatchPackets",
                service_name="soulfire.v1.BotProtocolService",
                input=WatchPacketsRequest,
                output=RawPacketEvent,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def send_raw_packet(
        self,
        request: SendRawPacketRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> SendRawPacketResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="SendRawPacket",
                service_name="soulfire.v1.BotProtocolService",
                input=SendRawPacketRequest,
                output=SendRawPacketResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

class BotProtocolServiceSync(Protocol):
    def get_protocol_info(self, request: BotProtocolRequest, ctx: RequestContext[BotProtocolRequest, BotProtocolInfo]) -> BotProtocolInfo:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def list_packet_schemas(self, request: ListPacketSchemasRequest, ctx: RequestContext[ListPacketSchemasRequest, ListPacketSchemasResponse]) -> ListPacketSchemasResponse:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def watch_packets(self, request: WatchPacketsRequest, ctx: RequestContext[WatchPacketsRequest, RawPacketEvent]) -> Iterator[RawPacketEvent]:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def send_raw_packet(self, request: SendRawPacketRequest, ctx: RequestContext[SendRawPacketRequest, SendRawPacketResponse]) -> SendRawPacketResponse:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')


class BotProtocolServiceWSGIApplication(ConnectWSGIApplication):
    def __init__(
        self,
        service: BotProtocolServiceSync,
        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.BotProtocolService/GetProtocolInfo": EndpointSync.unary(
                    method=MethodInfo(
                        name="GetProtocolInfo",
                        service_name="soulfire.v1.BotProtocolService",
                        input=BotProtocolRequest,
                        output=BotProtocolInfo,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.get_protocol_info,
                ),
                "/soulfire.v1.BotProtocolService/ListPacketSchemas": EndpointSync.unary(
                    method=MethodInfo(
                        name="ListPacketSchemas",
                        service_name="soulfire.v1.BotProtocolService",
                        input=ListPacketSchemasRequest,
                        output=ListPacketSchemasResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.list_packet_schemas,
                ),
                "/soulfire.v1.BotProtocolService/WatchPackets": EndpointSync.server_stream(
                    method=MethodInfo(
                        name="WatchPackets",
                        service_name="soulfire.v1.BotProtocolService",
                        input=WatchPacketsRequest,
                        output=RawPacketEvent,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.watch_packets,
                ),
                "/soulfire.v1.BotProtocolService/SendRawPacket": EndpointSync.unary(
                    method=MethodInfo(
                        name="SendRawPacket",
                        service_name="soulfire.v1.BotProtocolService",
                        input=SendRawPacketRequest,
                        output=SendRawPacketResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.send_raw_packet,
                ),
            },
            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.BotProtocolService"


class BotProtocolServiceClientSync(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,
        )
    def get_protocol_info(
        self,
        request: BotProtocolRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> BotProtocolInfo:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetProtocolInfo",
                service_name="soulfire.v1.BotProtocolService",
                input=BotProtocolRequest,
                output=BotProtocolInfo,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
    def list_packet_schemas(
        self,
        request: ListPacketSchemasRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> ListPacketSchemasResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="ListPacketSchemas",
                service_name="soulfire.v1.BotProtocolService",
                input=ListPacketSchemasRequest,
                output=ListPacketSchemasResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
    def watch_packets(
        self,
        request: WatchPacketsRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> Iterator[RawPacketEvent]:
        return self.execute_server_stream(
            request=request,
            method=MethodInfo(
                name="WatchPackets",
                service_name="soulfire.v1.BotProtocolService",
                input=WatchPacketsRequest,
                output=RawPacketEvent,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
    def send_raw_packet(
        self,
        request: SendRawPacketRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> SendRawPacketResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="SendRawPacket",
                service_name="soulfire.v1.BotProtocolService",
                input=SendRawPacketRequest,
                output=SendRawPacketResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
