|
25 | 25 | from aleph_message.models.execution.program import Encoding
|
26 | 26 | from aleph_message.status import MessageStatus
|
27 | 27 |
|
28 |
| -from ..models.message import MessageFilter |
29 |
| -from ..models.post import PostFilter, PostsResponse |
| 28 | +from ..query.filters import MessageFilter, PostFilter |
| 29 | +from ..query.responses import PostsResponse |
30 | 30 | from ..types import GenericMessage, StorageEnum
|
| 31 | +from ..utils import Writable |
31 | 32 |
|
32 | 33 | DEFAULT_PAGE_SIZE = 200
|
33 | 34 |
|
34 | 35 |
|
35 |
| -class BaseAlephClient(ABC): |
| 36 | +class AlephClient(ABC): |
36 | 37 | @abstractmethod
|
37 | 38 | async def fetch_aggregate(self, address: str, key: str) -> Dict[str, Dict]:
|
38 | 39 | """
|
@@ -110,6 +111,44 @@ async def download_file(
|
110 | 111 | """
|
111 | 112 | pass
|
112 | 113 |
|
| 114 | + async def download_file_ipfs( |
| 115 | + self, |
| 116 | + file_hash: str, |
| 117 | + ) -> bytes: |
| 118 | + """ |
| 119 | + Get a file from the ipfs storage engine as raw bytes. |
| 120 | +
|
| 121 | + Warning: Downloading large files can be slow. |
| 122 | +
|
| 123 | + :param file_hash: The hash of the file to retrieve. |
| 124 | + """ |
| 125 | + raise NotImplementedError() |
| 126 | + |
| 127 | + async def download_file_ipfs_to_buffer( |
| 128 | + self, |
| 129 | + file_hash: str, |
| 130 | + output_buffer: Writable[bytes], |
| 131 | + ) -> None: |
| 132 | + """ |
| 133 | + Download a file from the storage engine and write it to the specified output buffer. |
| 134 | +
|
| 135 | + :param file_hash: The hash of the file to retrieve. |
| 136 | + :param output_buffer: The binary output buffer to write the file data to. |
| 137 | + """ |
| 138 | + raise NotImplementedError() |
| 139 | + |
| 140 | + async def download_file_to_buffer( |
| 141 | + self, |
| 142 | + file_hash: str, |
| 143 | + output_buffer: Writable[bytes], |
| 144 | + ) -> None: |
| 145 | + """ |
| 146 | + Download a file from the storage engine and write it to the specified output buffer. |
| 147 | + :param file_hash: The hash of the file to retrieve. |
| 148 | + :param output_buffer: Writable binary buffer. The file will be written to this buffer. |
| 149 | + """ |
| 150 | + raise NotImplementedError() |
| 151 | + |
113 | 152 | @abstractmethod
|
114 | 153 | async def get_messages(
|
115 | 154 | self,
|
@@ -180,7 +219,7 @@ def watch_messages(
|
180 | 219 | pass
|
181 | 220 |
|
182 | 221 |
|
183 |
| -class BaseAuthenticatedAlephClient(BaseAlephClient): |
| 222 | +class AuthenticatedAlephClient(AlephClient): |
184 | 223 | @abstractmethod
|
185 | 224 | async def create_post(
|
186 | 225 | self,
|
@@ -350,3 +389,19 @@ async def submit(
|
350 | 389 | :param sync: If true, waits for the message to be processed by the API server (Default: False)
|
351 | 390 | """
|
352 | 391 | pass
|
| 392 | + |
| 393 | + async def ipfs_push(self, content: Mapping) -> str: |
| 394 | + """ |
| 395 | + Push a file to IPFS. |
| 396 | +
|
| 397 | + :param content: Content of the file to push |
| 398 | + """ |
| 399 | + raise NotImplementedError() |
| 400 | + |
| 401 | + async def storage_push(self, content: Mapping) -> str: |
| 402 | + """ |
| 403 | + Push arbitrary content as JSON to the storage service. |
| 404 | +
|
| 405 | + :param content: The dict-like content to upload |
| 406 | + """ |
| 407 | + raise NotImplementedError() |
0 commit comments