# -*- coding: utf-8 -*-
# Generated by https://github.com/connectrpc/connect-python.  DO NOT EDIT!
# source: chatto/api/v1/push_notifications.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.compression import Compression
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 chatto.api.v1.push_notifications_pb2 as chatto_dot_api_dot_v1_dot_push__notifications__pb2


class PushNotificationService(Protocol):
    async def subscribe(self, request: chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def unsubscribe(self, request: chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class PushNotificationServiceASGIApplication(ConnectASGIApplication[PushNotificationService]):
    def __init__(self, service: PushNotificationService | AsyncGenerator[PushNotificationService], *, interceptors: Iterable[Interceptor]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
        super().__init__(
            service=service,
            endpoints=lambda svc: {
                "/chatto.api.v1.PushNotificationService/Subscribe": Endpoint.unary(
                    method=MethodInfo(
                        name="Subscribe",
                        service_name="chatto.api.v1.PushNotificationService",
                        input=chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushRequest,
                        output=chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.subscribe,
                ),
                "/chatto.api.v1.PushNotificationService/Unsubscribe": Endpoint.unary(
                    method=MethodInfo(
                        name="Unsubscribe",
                        service_name="chatto.api.v1.PushNotificationService",
                        input=chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushRequest,
                        output=chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.unsubscribe,
                ),
            },
            interceptors=interceptors,
            read_max_bytes=read_max_bytes,
            compressions=compressions,
        )

    @property
    def path(self) -> str:
        """Returns the URL path to mount the application to when serving multiple applications."""
        return "/chatto.api.v1.PushNotificationService"


class PushNotificationServiceClient(ConnectClient):
    async def subscribe(
        self,
        request: chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Subscribe",
                service_name="chatto.api.v1.PushNotificationService",
                input=chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushRequest,
                output=chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def unsubscribe(
        self,
        request: chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Unsubscribe",
                service_name="chatto.api.v1.PushNotificationService",
                input=chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushRequest,
                output=chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )


class PushNotificationServiceSync(Protocol):
    def subscribe(self, request: chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def unsubscribe(self, request: chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class PushNotificationServiceWSGIApplication(ConnectWSGIApplication):
    def __init__(self, service: PushNotificationServiceSync, interceptors: Iterable[InterceptorSync]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
        super().__init__(
            endpoints={
                "/chatto.api.v1.PushNotificationService/Subscribe": EndpointSync.unary(
                    method=MethodInfo(
                        name="Subscribe",
                        service_name="chatto.api.v1.PushNotificationService",
                        input=chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushRequest,
                        output=chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.subscribe,
                ),
                "/chatto.api.v1.PushNotificationService/Unsubscribe": EndpointSync.unary(
                    method=MethodInfo(
                        name="Unsubscribe",
                        service_name="chatto.api.v1.PushNotificationService",
                        input=chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushRequest,
                        output=chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.unsubscribe,
                ),
            },
            interceptors=interceptors,
            read_max_bytes=read_max_bytes,
            compressions=compressions,
        )

    @property
    def path(self) -> str:
        """Returns the URL path to mount the application to when serving multiple applications."""
        return "/chatto.api.v1.PushNotificationService"


class PushNotificationServiceClientSync(ConnectClientSync):
    def subscribe(
        self,
        request: chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Subscribe",
                service_name="chatto.api.v1.PushNotificationService",
                input=chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushRequest,
                output=chatto_dot_api_dot_v1_dot_push__notifications__pb2.SubscribePushResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def unsubscribe(
        self,
        request: chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="Unsubscribe",
                service_name="chatto.api.v1.PushNotificationService",
                input=chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushRequest,
                output=chatto_dot_api_dot_v1_dot_push__notifications__pb2.UnsubscribePushResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
