|
4 | 4 | import hashlib |
5 | 5 | import hmac |
6 | 6 | import os |
| 7 | +import sys |
7 | 8 | from typing import Any, Awaitable, Dict, Iterable, List, TypeVar, Union |
8 | 9 |
|
| 10 | +if sys.version_info >= (3, 8): |
| 11 | + from typing import Literal |
| 12 | +else: |
| 13 | + from typing_extensions import Literal |
| 14 | + |
9 | 15 | import jwt |
10 | 16 |
|
11 | 17 | from stream_chat.types.stream_response import StreamResponse |
@@ -1122,6 +1128,89 @@ def list_push_providers(self) -> Union[StreamResponse, Awaitable[StreamResponse] |
1122 | 1128 | """ |
1123 | 1129 | pass |
1124 | 1130 |
|
| 1131 | + @abc.abstractmethod |
| 1132 | + def create_import_url( |
| 1133 | + self, filename: str |
| 1134 | + ) -> Union[StreamResponse, Awaitable[StreamResponse]]: |
| 1135 | + """ |
| 1136 | + Create a URL to import a file. |
| 1137 | + Full flow: |
| 1138 | + :: |
| 1139 | +
|
| 1140 | + url_resp = client.create_import_url("myfile.json") |
| 1141 | +
|
| 1142 | + upload_resp = requests.put( |
| 1143 | + url_resp["upload_url"], |
| 1144 | + data=open("myfile.json", "rb"), |
| 1145 | + headers={"Content-Type": "application/json"}, |
| 1146 | + ) |
| 1147 | +
|
| 1148 | + create_resp = client.create_import(url_resp["path"], "upsert") |
| 1149 | + import_resp = client.get_import(create_resp["import_task"]["id"]) |
| 1150 | + """ |
| 1151 | + pass |
| 1152 | + |
| 1153 | + def create_import( |
| 1154 | + self, path: str, mode: Literal["insert", "upsert"] = "upsert" |
| 1155 | + ) -> Union[StreamResponse, Awaitable[StreamResponse]]: |
| 1156 | + """ |
| 1157 | + Create an import task. |
| 1158 | + Full flow: |
| 1159 | + :: |
| 1160 | +
|
| 1161 | + url_resp = client.create_import_url("myfile.json") |
| 1162 | +
|
| 1163 | + upload_resp = requests.put( |
| 1164 | + url_resp["upload_url"], |
| 1165 | + data=open("myfile.json", "rb"), |
| 1166 | + headers={"Content-Type": "application/json"}, |
| 1167 | + ) |
| 1168 | +
|
| 1169 | + create_resp = client.create_import(url_resp["path"], "upsert") |
| 1170 | + import_resp = client.get_import(create_resp["import_task"]["id"]) |
| 1171 | + """ |
| 1172 | + pass |
| 1173 | + |
| 1174 | + def get_import(self, id: str) -> Union[StreamResponse, Awaitable[StreamResponse]]: |
| 1175 | + """ |
| 1176 | + Get the status of an import task. |
| 1177 | + Full flow: |
| 1178 | + :: |
| 1179 | +
|
| 1180 | + url_resp = client.create_import_url("myfile.json") |
| 1181 | +
|
| 1182 | + upload_resp = requests.put( |
| 1183 | + url_resp["upload_url"], |
| 1184 | + data=open("myfile.json", "rb"), |
| 1185 | + headers={"Content-Type": "application/json"}, |
| 1186 | + ) |
| 1187 | +
|
| 1188 | + create_resp = client.create_import(url_resp["path"], "upsert") |
| 1189 | + import_resp = client.get_import(create_resp["import_task"]["id"]) |
| 1190 | + """ |
| 1191 | + pass |
| 1192 | + |
| 1193 | + def list_imports( |
| 1194 | + self, options: Dict = None |
| 1195 | + ) -> Union[StreamResponse, Awaitable[StreamResponse]]: |
| 1196 | + """ |
| 1197 | + List all import tasks. Options can contain a "limit" and "offset" parameter. |
| 1198 | + Full flow: |
| 1199 | + :: |
| 1200 | +
|
| 1201 | + url_resp = client.create_import_url("myfile.json") |
| 1202 | +
|
| 1203 | + upload_resp = requests.put( |
| 1204 | + url_resp["upload_url"], |
| 1205 | + data=open("myfile.json", "rb"), |
| 1206 | + headers={"Content-Type": "application/json"}, |
| 1207 | + ) |
| 1208 | +
|
| 1209 | + create_resp = client.create_import(url_resp["path"], "upsert") |
| 1210 | + import_resp = client.get_import(create_resp["import_task"]["id"]) |
| 1211 | + """ |
| 1212 | + pass |
| 1213 | + |
1125 | 1214 | ##################### |
1126 | 1215 | # Private methods # |
1127 | 1216 | ##################### |
|
0 commit comments