# Generated from soulfire/task.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 .task_pb2 import BotTask, BotTaskEvent, CancelBotTaskRequest, GetBotTaskRequest, ListBotTasksRequest, ListBotTasksResponse, StartBotTaskRequest, WatchBotTaskRequest, WatchBotTasksRequest

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 BotTaskService(Protocol):
    async def start_bot_task(self, request: StartBotTaskRequest, ctx: RequestContext[StartBotTaskRequest, BotTask]) -> BotTask:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def run_bot_task(self, request: StartBotTaskRequest, ctx: RequestContext[StartBotTaskRequest, BotTaskEvent]) -> AsyncIterator[BotTaskEvent]:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    async def get_bot_task(self, request: GetBotTaskRequest, ctx: RequestContext[GetBotTaskRequest, BotTask]) -> BotTask:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    async def list_bot_tasks(self, request: ListBotTasksRequest, ctx: RequestContext[ListBotTasksRequest, ListBotTasksResponse]) -> ListBotTasksResponse:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def watch_bot_task(self, request: WatchBotTaskRequest, ctx: RequestContext[WatchBotTaskRequest, BotTaskEvent]) -> AsyncIterator[BotTaskEvent]:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def watch_bot_tasks(self, request: WatchBotTasksRequest, ctx: RequestContext[WatchBotTasksRequest, BotTaskEvent]) -> AsyncIterator[BotTaskEvent]:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    async def cancel_bot_task(self, request: CancelBotTaskRequest, ctx: RequestContext[CancelBotTaskRequest, BotTask]) -> BotTask:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')


class BotTaskServiceASGIApplication(ConnectASGIApplication[BotTaskService]):
    def __init__(
        self,
        service: BotTaskService | AsyncGenerator[BotTaskService],
        *,
        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.BotTaskService/StartBotTask": Endpoint.unary(
                    method=MethodInfo(
                        name="StartBotTask",
                        service_name="soulfire.v1.BotTaskService",
                        input=StartBotTaskRequest,
                        output=BotTask,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.start_bot_task,
                ),
                "/soulfire.v1.BotTaskService/RunBotTask": Endpoint.server_stream(
                    method=MethodInfo(
                        name="RunBotTask",
                        service_name="soulfire.v1.BotTaskService",
                        input=StartBotTaskRequest,
                        output=BotTaskEvent,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.run_bot_task,
                ),
                "/soulfire.v1.BotTaskService/GetBotTask": Endpoint.unary(
                    method=MethodInfo(
                        name="GetBotTask",
                        service_name="soulfire.v1.BotTaskService",
                        input=GetBotTaskRequest,
                        output=BotTask,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.get_bot_task,
                ),
                "/soulfire.v1.BotTaskService/ListBotTasks": Endpoint.unary(
                    method=MethodInfo(
                        name="ListBotTasks",
                        service_name="soulfire.v1.BotTaskService",
                        input=ListBotTasksRequest,
                        output=ListBotTasksResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.list_bot_tasks,
                ),
                "/soulfire.v1.BotTaskService/WatchBotTask": Endpoint.server_stream(
                    method=MethodInfo(
                        name="WatchBotTask",
                        service_name="soulfire.v1.BotTaskService",
                        input=WatchBotTaskRequest,
                        output=BotTaskEvent,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.watch_bot_task,
                ),
                "/soulfire.v1.BotTaskService/WatchBotTasks": Endpoint.server_stream(
                    method=MethodInfo(
                        name="WatchBotTasks",
                        service_name="soulfire.v1.BotTaskService",
                        input=WatchBotTasksRequest,
                        output=BotTaskEvent,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.watch_bot_tasks,
                ),
                "/soulfire.v1.BotTaskService/CancelBotTask": Endpoint.unary(
                    method=MethodInfo(
                        name="CancelBotTask",
                        service_name="soulfire.v1.BotTaskService",
                        input=CancelBotTaskRequest,
                        output=BotTask,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.cancel_bot_task,
                ),
            },
            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.BotTaskService"


class BotTaskServiceClient(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 start_bot_task(
        self,
        request: StartBotTaskRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> BotTask:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="StartBotTask",
                service_name="soulfire.v1.BotTaskService",
                input=StartBotTaskRequest,
                output=BotTask,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def run_bot_task(
        self,
        request: StartBotTaskRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> AsyncIterator[BotTaskEvent]:
        return self.execute_server_stream(
            request=request,
            method=MethodInfo(
                name="RunBotTask",
                service_name="soulfire.v1.BotTaskService",
                input=StartBotTaskRequest,
                output=BotTaskEvent,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def get_bot_task(
        self,
        request: GetBotTaskRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> BotTask:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetBotTask",
                service_name="soulfire.v1.BotTaskService",
                input=GetBotTaskRequest,
                output=BotTask,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def list_bot_tasks(
        self,
        request: ListBotTasksRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> ListBotTasksResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="ListBotTasks",
                service_name="soulfire.v1.BotTaskService",
                input=ListBotTasksRequest,
                output=ListBotTasksResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def watch_bot_task(
        self,
        request: WatchBotTaskRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> AsyncIterator[BotTaskEvent]:
        return self.execute_server_stream(
            request=request,
            method=MethodInfo(
                name="WatchBotTask",
                service_name="soulfire.v1.BotTaskService",
                input=WatchBotTaskRequest,
                output=BotTaskEvent,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def watch_bot_tasks(
        self,
        request: WatchBotTasksRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> AsyncIterator[BotTaskEvent]:
        return self.execute_server_stream(
            request=request,
            method=MethodInfo(
                name="WatchBotTasks",
                service_name="soulfire.v1.BotTaskService",
                input=WatchBotTasksRequest,
                output=BotTaskEvent,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def cancel_bot_task(
        self,
        request: CancelBotTaskRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> BotTask:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="CancelBotTask",
                service_name="soulfire.v1.BotTaskService",
                input=CancelBotTaskRequest,
                output=BotTask,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

class BotTaskServiceSync(Protocol):
    def start_bot_task(self, request: StartBotTaskRequest, ctx: RequestContext[StartBotTaskRequest, BotTask]) -> BotTask:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def run_bot_task(self, request: StartBotTaskRequest, ctx: RequestContext[StartBotTaskRequest, BotTaskEvent]) -> Iterator[BotTaskEvent]:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def get_bot_task(self, request: GetBotTaskRequest, ctx: RequestContext[GetBotTaskRequest, BotTask]) -> BotTask:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def list_bot_tasks(self, request: ListBotTasksRequest, ctx: RequestContext[ListBotTasksRequest, ListBotTasksResponse]) -> ListBotTasksResponse:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def watch_bot_task(self, request: WatchBotTaskRequest, ctx: RequestContext[WatchBotTaskRequest, BotTaskEvent]) -> Iterator[BotTaskEvent]:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def watch_bot_tasks(self, request: WatchBotTasksRequest, ctx: RequestContext[WatchBotTasksRequest, BotTaskEvent]) -> Iterator[BotTaskEvent]:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')

    def cancel_bot_task(self, request: CancelBotTaskRequest, ctx: RequestContext[CancelBotTaskRequest, BotTask]) -> BotTask:
        raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')


class BotTaskServiceWSGIApplication(ConnectWSGIApplication):
    def __init__(
        self,
        service: BotTaskServiceSync,
        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.BotTaskService/StartBotTask": EndpointSync.unary(
                    method=MethodInfo(
                        name="StartBotTask",
                        service_name="soulfire.v1.BotTaskService",
                        input=StartBotTaskRequest,
                        output=BotTask,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.start_bot_task,
                ),
                "/soulfire.v1.BotTaskService/RunBotTask": EndpointSync.server_stream(
                    method=MethodInfo(
                        name="RunBotTask",
                        service_name="soulfire.v1.BotTaskService",
                        input=StartBotTaskRequest,
                        output=BotTaskEvent,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.run_bot_task,
                ),
                "/soulfire.v1.BotTaskService/GetBotTask": EndpointSync.unary(
                    method=MethodInfo(
                        name="GetBotTask",
                        service_name="soulfire.v1.BotTaskService",
                        input=GetBotTaskRequest,
                        output=BotTask,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.get_bot_task,
                ),
                "/soulfire.v1.BotTaskService/ListBotTasks": EndpointSync.unary(
                    method=MethodInfo(
                        name="ListBotTasks",
                        service_name="soulfire.v1.BotTaskService",
                        input=ListBotTasksRequest,
                        output=ListBotTasksResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.list_bot_tasks,
                ),
                "/soulfire.v1.BotTaskService/WatchBotTask": EndpointSync.server_stream(
                    method=MethodInfo(
                        name="WatchBotTask",
                        service_name="soulfire.v1.BotTaskService",
                        input=WatchBotTaskRequest,
                        output=BotTaskEvent,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.watch_bot_task,
                ),
                "/soulfire.v1.BotTaskService/WatchBotTasks": EndpointSync.server_stream(
                    method=MethodInfo(
                        name="WatchBotTasks",
                        service_name="soulfire.v1.BotTaskService",
                        input=WatchBotTasksRequest,
                        output=BotTaskEvent,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.watch_bot_tasks,
                ),
                "/soulfire.v1.BotTaskService/CancelBotTask": EndpointSync.unary(
                    method=MethodInfo(
                        name="CancelBotTask",
                        service_name="soulfire.v1.BotTaskService",
                        input=CancelBotTaskRequest,
                        output=BotTask,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.cancel_bot_task,
                ),
            },
            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.BotTaskService"


class BotTaskServiceClientSync(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 start_bot_task(
        self,
        request: StartBotTaskRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> BotTask:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="StartBotTask",
                service_name="soulfire.v1.BotTaskService",
                input=StartBotTaskRequest,
                output=BotTask,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
    def run_bot_task(
        self,
        request: StartBotTaskRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> Iterator[BotTaskEvent]:
        return self.execute_server_stream(
            request=request,
            method=MethodInfo(
                name="RunBotTask",
                service_name="soulfire.v1.BotTaskService",
                input=StartBotTaskRequest,
                output=BotTaskEvent,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
    def get_bot_task(
        self,
        request: GetBotTaskRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> BotTask:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetBotTask",
                service_name="soulfire.v1.BotTaskService",
                input=GetBotTaskRequest,
                output=BotTask,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
    def list_bot_tasks(
        self,
        request: ListBotTasksRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> ListBotTasksResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="ListBotTasks",
                service_name="soulfire.v1.BotTaskService",
                input=ListBotTasksRequest,
                output=ListBotTasksResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
    def watch_bot_task(
        self,
        request: WatchBotTaskRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> Iterator[BotTaskEvent]:
        return self.execute_server_stream(
            request=request,
            method=MethodInfo(
                name="WatchBotTask",
                service_name="soulfire.v1.BotTaskService",
                input=WatchBotTaskRequest,
                output=BotTaskEvent,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
    def watch_bot_tasks(
        self,
        request: WatchBotTasksRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> Iterator[BotTaskEvent]:
        return self.execute_server_stream(
            request=request,
            method=MethodInfo(
                name="WatchBotTasks",
                service_name="soulfire.v1.BotTaskService",
                input=WatchBotTasksRequest,
                output=BotTaskEvent,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
    def cancel_bot_task(
        self,
        request: CancelBotTaskRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> BotTask:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="CancelBotTask",
                service_name="soulfire.v1.BotTaskService",
                input=CancelBotTaskRequest,
                output=BotTask,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
