|
22 | 22 | KeyCreate, |
23 | 23 | KeySearch, |
24 | 24 | KeyUpdate, |
| 25 | + Network, |
25 | 26 | ) |
26 | 27 | from meilisearch_python_sdk.models.health import Health |
27 | 28 | from meilisearch_python_sdk.models.index import IndexInfo |
@@ -196,12 +197,66 @@ async def aclose(self) -> None: |
196 | 197 | """ |
197 | 198 | await self.http_client.aclose() |
198 | 199 |
|
| 200 | + async def add_or_update_networks(self, *, network: Network) -> Network: |
| 201 | + """Set or update remote networks. |
| 202 | +
|
| 203 | + Args: |
| 204 | + network: Information to use for the networks. |
| 205 | +
|
| 206 | + Returns: |
| 207 | + An instance of Network containing the network information. |
| 208 | +
|
| 209 | + Raises: |
| 210 | + MeilisearchCommunicationError: If there was an error communicating with the server. |
| 211 | + MeilisearchApiError: If the Meilisearch API returned an error. |
| 212 | +
|
| 213 | + Examples: |
| 214 | + >>> from meilisearch_python_sdk import AsyncClient |
| 215 | + >>> from meilisearch_python_sdk.models.client import Network, Remote |
| 216 | + >>> |
| 217 | + >>> |
| 218 | + >>> network = Network( |
| 219 | + >>> self_="remote_1", |
| 220 | + >>> remotes={ |
| 221 | + >>> "remote_1": {"url": "http://localhost:7700", "searchApiKey": "xxxx"}, |
| 222 | + >>> "remote_2": {"url": "http://localhost:7720", "searchApiKey": "xxxx"}, |
| 223 | + >>> }, |
| 224 | + >>> ) |
| 225 | + >>> async with AsyncClient("http://localhost.com", "masterKey") as client: |
| 226 | + >>> response = await client.add_or_update_networks(network=network) |
| 227 | + """ |
| 228 | + response = await self._http_requests.patch( |
| 229 | + "network", network.model_dump(by_alias=True, exclude_none=True) |
| 230 | + ) |
| 231 | + |
| 232 | + return Network(**response.json()) |
| 233 | + |
| 234 | + async def get_networks(self) -> Network: |
| 235 | + """Fetches the remote-networks |
| 236 | +
|
| 237 | + Returns: |
| 238 | + An instance of Network containing information about each remote. |
| 239 | +
|
| 240 | + Raises: |
| 241 | + MeilisearchCommunicationError: If there was an error communicating with the server. |
| 242 | + MeilisearchApiError: If the Meilisearch API returned an error. |
| 243 | +
|
| 244 | + Examples: |
| 245 | + >>> from meilisearch_python_sdk import AsyncClient |
| 246 | + >>> |
| 247 | + >>> |
| 248 | + >>> async with AsyncClient("http://localhost.com", "masterKey") as client: |
| 249 | + >>> response = await client.get_networks() |
| 250 | + """ |
| 251 | + response = await self._http_requests.get("network") |
| 252 | + |
| 253 | + return Network(**response.json()) |
| 254 | + |
199 | 255 | async def create_dump(self) -> TaskInfo: |
200 | 256 | """Trigger the creation of a Meilisearch dump. |
201 | 257 |
|
202 | 258 | Returns: |
203 | 259 | The details of the task. |
204 | | -
|
205 | 260 | Raises: |
206 | 261 | MeilisearchCommunicationError: If there was an error communicating with the server. |
207 | 262 | MeilisearchApiError: If the Meilisearch API returned an error. |
@@ -1061,6 +1116,61 @@ def __init__( |
1061 | 1116 |
|
1062 | 1117 | self._http_requests = HttpRequests(self.http_client, json_handler=self.json_handler) |
1063 | 1118 |
|
| 1119 | + def add_or_update_networks(self, *, network: Network) -> Network: |
| 1120 | + """Set or update remote networks. |
| 1121 | +
|
| 1122 | + Args: |
| 1123 | + network: Information to use for the networks. |
| 1124 | +
|
| 1125 | + Returns: |
| 1126 | + An instance of Network containing the network information. |
| 1127 | +
|
| 1128 | + Raises: |
| 1129 | + MeilisearchCommunicationError: If there was an error communicating with the server. |
| 1130 | + MeilisearchApiError: If the Meilisearch API returned an error. |
| 1131 | +
|
| 1132 | + Examples: |
| 1133 | + >>> from meilisearch_python_sdk import Client |
| 1134 | + >>> from meilisearch_python_sdk.models.client import Network, Remote |
| 1135 | + >>> |
| 1136 | + >>> |
| 1137 | + >>> network = Network( |
| 1138 | + >>> self_="remote_1", |
| 1139 | + >>> remotes={ |
| 1140 | + >>> "remote_1": {"url": "http://localhost:7700", "searchApiKey": "xxxx"}, |
| 1141 | + >>> "remote_2": {"url": "http://localhost:7720", "searchApiKey": "xxxx"}, |
| 1142 | + >>> }, |
| 1143 | + >>> ) |
| 1144 | + >>> client = Client("http://localhost.com", "masterKey") |
| 1145 | + >>> response = client.add_or_update_networks(network=network) |
| 1146 | + """ |
| 1147 | + response = self._http_requests.patch( |
| 1148 | + "network", network.model_dump(by_alias=True, exclude_none=True) |
| 1149 | + ) |
| 1150 | + |
| 1151 | + return Network(**response.json()) |
| 1152 | + |
| 1153 | + def get_networks(self) -> Network: |
| 1154 | + """Fetches the remote-networks |
| 1155 | +
|
| 1156 | + Returns: |
| 1157 | + An instance of Network containing information about each remote. |
| 1158 | +
|
| 1159 | + Raises: |
| 1160 | + MeilisearchCommunicationError: If there was an error communicating with the server. |
| 1161 | + MeilisearchApiError: If the Meilisearch API returned an error. |
| 1162 | +
|
| 1163 | + Examples: |
| 1164 | + >>> from meilisearch_python_sdk import AsyncClient |
| 1165 | + >>> |
| 1166 | + >>> |
| 1167 | + >>> client = Client("http://localhost.com", "masterKey") |
| 1168 | + >>> response = client.get_networks() |
| 1169 | + """ |
| 1170 | + response = self._http_requests.get("network") |
| 1171 | + |
| 1172 | + return Network(**response.json()) |
| 1173 | + |
1064 | 1174 | def create_dump(self) -> TaskInfo: |
1065 | 1175 | """Trigger the creation of a Meilisearch dump. |
1066 | 1176 |
|
|
0 commit comments