attachments_connect.py 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. # -*- coding: utf-8 -*-
  2. # Generated by https://github.com/connectrpc/connect-python. DO NOT EDIT!
  3. # source: chatto/api/v1/attachments.proto
  4. from collections.abc import AsyncGenerator, AsyncIterator, Iterable, Iterator, Mapping
  5. from typing import Protocol
  6. from connectrpc.client import ConnectClient, ConnectClientSync
  7. from connectrpc.code import Code
  8. from connectrpc.compression import Compression
  9. from connectrpc.errors import ConnectError
  10. from connectrpc.interceptor import Interceptor, InterceptorSync
  11. from connectrpc.method import IdempotencyLevel, MethodInfo
  12. from connectrpc.request import Headers, RequestContext
  13. from connectrpc.server import ConnectASGIApplication, ConnectWSGIApplication, Endpoint, EndpointSync
  14. import chatto.api.v1.attachments_pb2 as chatto_dot_api_dot_v1_dot_attachments__pb2
  15. class AssetService(Protocol):
  16. 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:
  17. raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
  18. 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:
  19. raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
  20. class AssetServiceASGIApplication(ConnectASGIApplication[AssetService]):
  21. def __init__(self, service: AssetService | AsyncGenerator[AssetService], *, interceptors: Iterable[Interceptor]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
  22. super().__init__(
  23. service=service,
  24. endpoints=lambda svc: {
  25. "/chatto.api.v1.AssetService/GetAsset": Endpoint.unary(
  26. method=MethodInfo(
  27. name="GetAsset",
  28. service_name="chatto.api.v1.AssetService",
  29. input=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest,
  30. output=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse,
  31. idempotency_level=IdempotencyLevel.UNKNOWN,
  32. ),
  33. function=svc.get_asset,
  34. ),
  35. "/chatto.api.v1.AssetService/BatchGetAssets": Endpoint.unary(
  36. method=MethodInfo(
  37. name="BatchGetAssets",
  38. service_name="chatto.api.v1.AssetService",
  39. input=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest,
  40. output=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse,
  41. idempotency_level=IdempotencyLevel.UNKNOWN,
  42. ),
  43. function=svc.batch_get_assets,
  44. ),
  45. },
  46. interceptors=interceptors,
  47. read_max_bytes=read_max_bytes,
  48. compressions=compressions,
  49. )
  50. @property
  51. def path(self) -> str:
  52. """Returns the URL path to mount the application to when serving multiple applications."""
  53. return "/chatto.api.v1.AssetService"
  54. class AssetServiceClient(ConnectClient):
  55. async def get_asset(
  56. self,
  57. request: chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest,
  58. *,
  59. headers: Headers | Mapping[str, str] | None = None,
  60. timeout_ms: int | None = None,
  61. ) -> chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse:
  62. return await self.execute_unary(
  63. request=request,
  64. method=MethodInfo(
  65. name="GetAsset",
  66. service_name="chatto.api.v1.AssetService",
  67. input=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest,
  68. output=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse,
  69. idempotency_level=IdempotencyLevel.UNKNOWN,
  70. ),
  71. headers=headers,
  72. timeout_ms=timeout_ms,
  73. )
  74. async def batch_get_assets(
  75. self,
  76. request: chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest,
  77. *,
  78. headers: Headers | Mapping[str, str] | None = None,
  79. timeout_ms: int | None = None,
  80. ) -> chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse:
  81. return await self.execute_unary(
  82. request=request,
  83. method=MethodInfo(
  84. name="BatchGetAssets",
  85. service_name="chatto.api.v1.AssetService",
  86. input=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest,
  87. output=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse,
  88. idempotency_level=IdempotencyLevel.UNKNOWN,
  89. ),
  90. headers=headers,
  91. timeout_ms=timeout_ms,
  92. )
  93. class AssetServiceSync(Protocol):
  94. 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:
  95. raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
  96. 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:
  97. raise ConnectError(Code.UNIMPLEMENTED, "Not implemented")
  98. class AssetServiceWSGIApplication(ConnectWSGIApplication):
  99. def __init__(self, service: AssetServiceSync, interceptors: Iterable[InterceptorSync]=(), read_max_bytes: int | None = None, compressions: Iterable[Compression] | None = None) -> None:
  100. super().__init__(
  101. endpoints={
  102. "/chatto.api.v1.AssetService/GetAsset": EndpointSync.unary(
  103. method=MethodInfo(
  104. name="GetAsset",
  105. service_name="chatto.api.v1.AssetService",
  106. input=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest,
  107. output=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse,
  108. idempotency_level=IdempotencyLevel.UNKNOWN,
  109. ),
  110. function=service.get_asset,
  111. ),
  112. "/chatto.api.v1.AssetService/BatchGetAssets": EndpointSync.unary(
  113. method=MethodInfo(
  114. name="BatchGetAssets",
  115. service_name="chatto.api.v1.AssetService",
  116. input=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest,
  117. output=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse,
  118. idempotency_level=IdempotencyLevel.UNKNOWN,
  119. ),
  120. function=service.batch_get_assets,
  121. ),
  122. },
  123. interceptors=interceptors,
  124. read_max_bytes=read_max_bytes,
  125. compressions=compressions,
  126. )
  127. @property
  128. def path(self) -> str:
  129. """Returns the URL path to mount the application to when serving multiple applications."""
  130. return "/chatto.api.v1.AssetService"
  131. class AssetServiceClientSync(ConnectClientSync):
  132. def get_asset(
  133. self,
  134. request: chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest,
  135. *,
  136. headers: Headers | Mapping[str, str] | None = None,
  137. timeout_ms: int | None = None,
  138. ) -> chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse:
  139. return self.execute_unary(
  140. request=request,
  141. method=MethodInfo(
  142. name="GetAsset",
  143. service_name="chatto.api.v1.AssetService",
  144. input=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetRequest,
  145. output=chatto_dot_api_dot_v1_dot_attachments__pb2.GetAssetResponse,
  146. idempotency_level=IdempotencyLevel.UNKNOWN,
  147. ),
  148. headers=headers,
  149. timeout_ms=timeout_ms,
  150. )
  151. def batch_get_assets(
  152. self,
  153. request: chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest,
  154. *,
  155. headers: Headers | Mapping[str, str] | None = None,
  156. timeout_ms: int | None = None,
  157. ) -> chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse:
  158. return self.execute_unary(
  159. request=request,
  160. method=MethodInfo(
  161. name="BatchGetAssets",
  162. service_name="chatto.api.v1.AssetService",
  163. input=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsRequest,
  164. output=chatto_dot_api_dot_v1_dot_attachments__pb2.BatchGetAssetsResponse,
  165. idempotency_level=IdempotencyLevel.UNKNOWN,
  166. ),
  167. headers=headers,
  168. timeout_ms=timeout_ms,
  169. )