# -*- coding: utf-8 -*- # Generated by https://github.com/connectrpc/connect-python. DO NOT EDIT! # source: chatto/api/v1/attachments.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.attachments_pb2 as chatto_dot_api_dot_v1_dot_attachments__pb2 class AssetService(Protocol): async def get_asset(self, request: chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse: raise ConnectError(Code.UNIMPLEMENTED, "Not implemented") async def batch_get_assets(self, request: chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse: raise ConnectError(Code.UNIMPLEMENTED, "Not implemented") class AssetServiceASGIApplication(ConnectASGIApplication[AssetService]): def __init__(self, service: AssetService | AsyncGenerator[AssetService], *, 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.AssetService/GetAsset": Endpoint.unary( method=MethodInfo( name="GetAsset", service_name="chatto.api.v1.AssetService", input=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest, output=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse, idempotency_level=IdempotencyLevel.UNKNOWN, ), function=svc.get_asset, ), "/chatto.api.v1.AssetService/BatchGetAssets": Endpoint.unary( method=MethodInfo( name="BatchGetAssets", service_name="chatto.api.v1.AssetService", input=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest, output=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse, idempotency_level=IdempotencyLevel.UNKNOWN, ), function=svc.batch_get_assets, ), }, 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.AssetService" class AssetServiceClient(ConnectClient): async def get_asset( self, request: chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse: return await self.execute_unary( request=request, method=MethodInfo( name="GetAsset", service_name="chatto.api.v1.AssetService", input=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest, output=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse, idempotency_level=IdempotencyLevel.UNKNOWN, ), headers=headers, timeout_ms=timeout_ms, ) async def batch_get_assets( self, request: chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse: return await self.execute_unary( request=request, method=MethodInfo( name="BatchGetAssets", service_name="chatto.api.v1.AssetService", input=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest, output=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse, idempotency_level=IdempotencyLevel.UNKNOWN, ), headers=headers, timeout_ms=timeout_ms, ) class AssetServiceSync(Protocol): def get_asset(self, request: chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse: raise ConnectError(Code.UNIMPLEMENTED, "Not implemented") def batch_get_assets(self, request: chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest, ctx: RequestContext) -> chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse: raise ConnectError(Code.UNIMPLEMENTED, "Not implemented") class AssetServiceWSGIApplication(ConnectWSGIApplication): def __init__(self, service: AssetServiceSync, interceptors: Iterable[InterceptorSync]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None: super().__init__( endpoints={ "/chatto.api.v1.AssetService/GetAsset": EndpointSync.unary( method=MethodInfo( name="GetAsset", service_name="chatto.api.v1.AssetService", input=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest, output=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse, idempotency_level=IdempotencyLevel.UNKNOWN, ), function=service.get_asset, ), "/chatto.api.v1.AssetService/BatchGetAssets": EndpointSync.unary( method=MethodInfo( name="BatchGetAssets", service_name="chatto.api.v1.AssetService", input=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest, output=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse, idempotency_level=IdempotencyLevel.UNKNOWN, ), function=service.batch_get_assets, ), }, 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.AssetService" class AssetServiceClientSync(ConnectClientSync): def get_asset( self, request: chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse: return self.execute_unary( request=request, method=MethodInfo( name="GetAsset", service_name="chatto.api.v1.AssetService", input=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest, output=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse, idempotency_level=IdempotencyLevel.UNKNOWN, ), headers=headers, timeout_ms=timeout_ms, ) def batch_get_assets( self, request: chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse: return self.execute_unary( request=request, method=MethodInfo( name="BatchGetAssets", service_name="chatto.api.v1.AssetService", input=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest, output=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse, idempotency_level=IdempotencyLevel.UNKNOWN, ), headers=headers, timeout_ms=timeout_ms, )