# -*- coding: utf-8 -*-
# Generated by https://github.com/connectrpc/connect-python.  DO NOT EDIT!
# source: chatto/api/v1/asset_uploads.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.asset_uploads_pb2 as chatto_dot_api_dot_v1_dot_asset__uploads__pb2


class AssetUploadService(Protocol):
    async def create_upload(self, request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def upload_chunk(self, request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def get_upload(self, request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def complete_upload(self, request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")

    async def cancel_upload(self, request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class AssetUploadServiceASGIApplication(ConnectASGIApplication[AssetUploadService]):
    def __init__(self, service: AssetUploadService | AsyncGenerator[AssetUploadService], *, 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.AssetUploadService/CreateUpload": Endpoint.unary(
                    method=MethodInfo(
                        name="CreateUpload",
                        service_name="chatto.api.v1.AssetUploadService",
                        input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadRequest,
                        output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.create_upload,
                ),
                "/chatto.api.v1.AssetUploadService/UploadChunk": Endpoint.unary(
                    method=MethodInfo(
                        name="UploadChunk",
                        service_name="chatto.api.v1.AssetUploadService",
                        input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkRequest,
                        output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.upload_chunk,
                ),
                "/chatto.api.v1.AssetUploadService/GetUpload": Endpoint.unary(
                    method=MethodInfo(
                        name="GetUpload",
                        service_name="chatto.api.v1.AssetUploadService",
                        input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadRequest,
                        output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.get_upload,
                ),
                "/chatto.api.v1.AssetUploadService/CompleteUpload": Endpoint.unary(
                    method=MethodInfo(
                        name="CompleteUpload",
                        service_name="chatto.api.v1.AssetUploadService",
                        input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadRequest,
                        output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.complete_upload,
                ),
                "/chatto.api.v1.AssetUploadService/CancelUpload": Endpoint.unary(
                    method=MethodInfo(
                        name="CancelUpload",
                        service_name="chatto.api.v1.AssetUploadService",
                        input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadRequest,
                        output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=svc.cancel_upload,
                ),
            },
            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.AssetUploadService"


class AssetUploadServiceClient(ConnectClient):
    async def create_upload(
        self,
        request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="CreateUpload",
                service_name="chatto.api.v1.AssetUploadService",
                input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadRequest,
                output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def upload_chunk(
        self,
        request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="UploadChunk",
                service_name="chatto.api.v1.AssetUploadService",
                input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkRequest,
                output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def get_upload(
        self,
        request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetUpload",
                service_name="chatto.api.v1.AssetUploadService",
                input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadRequest,
                output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def complete_upload(
        self,
        request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="CompleteUpload",
                service_name="chatto.api.v1.AssetUploadService",
                input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadRequest,
                output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    async def cancel_upload(
        self,
        request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadResponse:
        return await self.execute_unary(
            request=request,
            method=MethodInfo(
                name="CancelUpload",
                service_name="chatto.api.v1.AssetUploadService",
                input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadRequest,
                output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )


class AssetUploadServiceSync(Protocol):
    def create_upload(self, request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def upload_chunk(self, request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def get_upload(self, request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def complete_upload(self, request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
    def cancel_upload(self, request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadResponse:
        raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")


class AssetUploadServiceWSGIApplication(ConnectWSGIApplication):
    def __init__(self, service: AssetUploadServiceSync, interceptors: Iterable[InterceptorSync]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
        super().__init__(
            endpoints={
                "/chatto.api.v1.AssetUploadService/CreateUpload": EndpointSync.unary(
                    method=MethodInfo(
                        name="CreateUpload",
                        service_name="chatto.api.v1.AssetUploadService",
                        input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadRequest,
                        output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.create_upload,
                ),
                "/chatto.api.v1.AssetUploadService/UploadChunk": EndpointSync.unary(
                    method=MethodInfo(
                        name="UploadChunk",
                        service_name="chatto.api.v1.AssetUploadService",
                        input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkRequest,
                        output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.upload_chunk,
                ),
                "/chatto.api.v1.AssetUploadService/GetUpload": EndpointSync.unary(
                    method=MethodInfo(
                        name="GetUpload",
                        service_name="chatto.api.v1.AssetUploadService",
                        input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadRequest,
                        output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.get_upload,
                ),
                "/chatto.api.v1.AssetUploadService/CompleteUpload": EndpointSync.unary(
                    method=MethodInfo(
                        name="CompleteUpload",
                        service_name="chatto.api.v1.AssetUploadService",
                        input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadRequest,
                        output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.complete_upload,
                ),
                "/chatto.api.v1.AssetUploadService/CancelUpload": EndpointSync.unary(
                    method=MethodInfo(
                        name="CancelUpload",
                        service_name="chatto.api.v1.AssetUploadService",
                        input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadRequest,
                        output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadResponse,
                        idempotency_level=IdempotencyLevel.UNKNOWN,
                    ),
                    function=service.cancel_upload,
                ),
            },
            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.AssetUploadService"


class AssetUploadServiceClientSync(ConnectClientSync):
    def create_upload(
        self,
        request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="CreateUpload",
                service_name="chatto.api.v1.AssetUploadService",
                input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadRequest,
                output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CreateUploadResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def upload_chunk(
        self,
        request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="UploadChunk",
                service_name="chatto.api.v1.AssetUploadService",
                input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkRequest,
                output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.UploadChunkResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def get_upload(
        self,
        request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="GetUpload",
                service_name="chatto.api.v1.AssetUploadService",
                input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadRequest,
                output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.GetUploadResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def complete_upload(
        self,
        request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="CompleteUpload",
                service_name="chatto.api.v1.AssetUploadService",
                input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadRequest,
                output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CompleteUploadResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )

    def cancel_upload(
        self,
        request: chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadRequest,
        *,
        headers: Headers | Mapping[str, str] | None = None,
        timeout_ms: int | None = None,
    ) -> chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadResponse:
        return self.execute_unary(
            request=request,
            method=MethodInfo(
                name="CancelUpload",
                service_name="chatto.api.v1.AssetUploadService",
                input=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadRequest,
                output=chatto_dot_api_dot_v1_dot_asset__uploads__pb2.CancelUploadResponse,
                idempotency_level=IdempotencyLevel.UNKNOWN,
            ),
            headers=headers,
            timeout_ms=timeout_ms,
        )
