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


class DecideService(Protocol):
    async def guard(self, request: proto_dot_decide_dot_v2_dot_decide__pb2.GuardRequest, ctx: RequestContext) -> proto_dot_decide_dot_v2_dot_decide__pb2.GuardResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def capture(self, request: proto_dot_decide_dot_v2_dot_decide__pb2.CaptureRequest, ctx: RequestContext) -> proto_dot_decide_dot_v2_dot_decide__pb2.CaptureResponse:
        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.v2.DecideService/Guard": Endpoint.unary(
                    method=MethodInfo(
                        name="Guard",
                        service_name="proto.decide.v2.DecideService",
                        input=proto_dot_decide_dot_v2_dot_decide__pb2.GuardRequest,
                        output=proto_dot_decide_dot_v2_dot_decide__pb2.GuardResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.guard,
                ),
                "/proto.decide.v2.DecideService/Capture": Endpoint.unary(
                    method=MethodInfo(
                        name="Capture",
                        service_name="proto.decide.v2.DecideService",
                        input=proto_dot_decide_dot_v2_dot_decide__pb2.CaptureRequest,
                        output=proto_dot_decide_dot_v2_dot_decide__pb2.CaptureResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.capture,
                ),
            },
            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.v2.DecideService"


class DecideServiceClient(ConnectClient):
    async def guard(
        self,
        request: proto_dot_decide_dot_v2_dot_decide__pb2.GuardRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> proto_dot_decide_dot_v2_dot_decide__pb2.GuardResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Guard",
                service_name="proto.decide.v2.DecideService",
                input=proto_dot_decide_dot_v2_dot_decide__pb2.GuardRequest,
                output=proto_dot_decide_dot_v2_dot_decide__pb2.GuardResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def capture(
        self,
        request: proto_dot_decide_dot_v2_dot_decide__pb2.CaptureRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> proto_dot_decide_dot_v2_dot_decide__pb2.CaptureResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Capture",
                service_name="proto.decide.v2.DecideService",
                input=proto_dot_decide_dot_v2_dot_decide__pb2.CaptureRequest,
                output=proto_dot_decide_dot_v2_dot_decide__pb2.CaptureResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )


class DecideServiceSync(Protocol):
    def guard(self, request: proto_dot_decide_dot_v2_dot_decide__pb2.GuardRequest, ctx: RequestContext) -> proto_dot_decide_dot_v2_dot_decide__pb2.GuardResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def capture(self, request: proto_dot_decide_dot_v2_dot_decide__pb2.CaptureRequest, ctx: RequestContext) -> proto_dot_decide_dot_v2_dot_decide__pb2.CaptureResponse:
        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.v2.DecideService/Guard": EndpointSync.unary(
                    method=MethodInfo(
                        name="Guard",
                        service_name="proto.decide.v2.DecideService",
                        input=proto_dot_decide_dot_v2_dot_decide__pb2.GuardRequest,
                        output=proto_dot_decide_dot_v2_dot_decide__pb2.GuardResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.guard,
                ),
                "/proto.decide.v2.DecideService/Capture": EndpointSync.unary(
                    method=MethodInfo(
                        name="Capture",
                        service_name="proto.decide.v2.DecideService",
                        input=proto_dot_decide_dot_v2_dot_decide__pb2.CaptureRequest,
                        output=proto_dot_decide_dot_v2_dot_decide__pb2.CaptureResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.capture,
                ),
            },
            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.v2.DecideService"


class DecideServiceClientSync(ConnectClientSync):
    def guard(
        self,
        request: proto_dot_decide_dot_v2_dot_decide__pb2.GuardRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> proto_dot_decide_dot_v2_dot_decide__pb2.GuardResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Guard",
                service_name="proto.decide.v2.DecideService",
                input=proto_dot_decide_dot_v2_dot_decide__pb2.GuardRequest,
                output=proto_dot_decide_dot_v2_dot_decide__pb2.GuardResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def capture(
        self,
        request: proto_dot_decide_dot_v2_dot_decide__pb2.CaptureRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> proto_dot_decide_dot_v2_dot_decide__pb2.CaptureResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Capture",
                service_name="proto.decide.v2.DecideService",
                input=proto_dot_decide_dot_v2_dot_decide__pb2.CaptureRequest,
                output=proto_dot_decide_dot_v2_dot_decide__pb2.CaptureResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
