# -*- coding: utf-8 -*-
# Generated by https://github.com/connectrpc/connect-python.  DO NOT EDIT!
# source: proto/decide/v1alpha1/decide.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.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 arcjet.proto.decide.v1alpha1.decide_pb2 as proto_dot_decide_dot_v1alpha1_dot_decide__pb2


class DecideService(Protocol):
    async def decide(self, request: proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideRequest, ctx: RequestContext) -> proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def report(self, request: proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportRequest, ctx: RequestContext) -> proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class DecideServiceASGIApplication(ConnectASGIApplication[DecideService]):
    def __init__(self, service: DecideService | AsyncGenerator[DecideService], *, interceptors: Iterable[Interceptor]=(), read_max_bytes: int | None = None) -> None:
        super().__init__(
            service=service,
            endpoints=lambda svc: {
                "/proto.decide.v1alpha1.DecideService/Decide": Endpoint.unary(
                    method=MethodInfo(
                        name="Decide",
                        service_name="proto.decide.v1alpha1.DecideService",
                        input=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideRequest,
                        output=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.decide,
                ),
                "/proto.decide.v1alpha1.DecideService/Report": Endpoint.unary(
                    method=MethodInfo(
                        name="Report",
                        service_name="proto.decide.v1alpha1.DecideService",
                        input=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportRequest,
                        output=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.report,
                ),
            },
            interceptors=interceptors,
            read_max_bytes=read_max_bytes,
        )

    @property
    def path(self) -> str:
        """Returns the URL path to mount the application to when serving multiple applications."""
        return "/proto.decide.v1alpha1.DecideService"


class DecideServiceClient(ConnectClient):
    async def decide(
        self,
        request: proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Decide",
                service_name="proto.decide.v1alpha1.DecideService",
                input=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideRequest,
                output=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def report(
        self,
        request: proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Report",
                service_name="proto.decide.v1alpha1.DecideService",
                input=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportRequest,
                output=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )


class DecideServiceSync(Protocol):
    def decide(self, request: proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideRequest, ctx: RequestContext) -> proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def report(self, request: proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportRequest, ctx: RequestContext) -> proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class DecideServiceWSGIApplication(ConnectWSGIApplication):
    def __init__(self, service: DecideServiceSync, interceptors: Iterable[InterceptorSync]=(), read_max_bytes: int | None = None) -> None:
        super().__init__(
            endpoints={
                "/proto.decide.v1alpha1.DecideService/Decide": EndpointSync.unary(
                    method=MethodInfo(
                        name="Decide",
                        service_name="proto.decide.v1alpha1.DecideService",
                        input=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideRequest,
                        output=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.decide,
                ),
                "/proto.decide.v1alpha1.DecideService/Report": EndpointSync.unary(
                    method=MethodInfo(
                        name="Report",
                        service_name="proto.decide.v1alpha1.DecideService",
                        input=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportRequest,
                        output=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.report,
                ),
            },
            interceptors=interceptors,
            read_max_bytes=read_max_bytes,
        )

    @property
    def path(self) -> str:
        """Returns the URL path to mount the application to when serving multiple applications."""
        return "/proto.decide.v1alpha1.DecideService"


class DecideServiceClientSync(ConnectClientSync):
    def decide(
        self,
        request: proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Decide",
                service_name="proto.decide.v1alpha1.DecideService",
                input=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideRequest,
                output=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.DecideResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def report(
        self,
        request: proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Report",
                service_name="proto.decide.v1alpha1.DecideService",
                input=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportRequest,
                output=proto_dot_decide_dot_v1alpha1_dot_decide__pb2.ReportResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
