Skip to content

Commit 762debf

Browse files
authored
Merge pull request #719 from sanders41/meilisearch-1.5.0
Update for Meilisearch 1.5.0
2 parents c0b69f5 + 3ebddf0 commit 762debf

File tree

6 files changed

+234
-168
lines changed

6 files changed

+234
-168
lines changed

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
poetry run ruff format meilisearch_python_sdk tests
1717

1818
@test: start-meilisearch-detached && stop-meilisearch
19-
-poetry run pytest
19+
-poetry run pytest -x
2020

2121
@test-ci: start-meilisearch-detached && stop-meilisearch
2222
poetry run pytest --cov=meilisearch_python_sdk --cov-report=xml

meilisearch_python_sdk/_client.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,28 @@ async def create_index(self, uid: str, primary_key: str | None = None) -> AsyncI
209209
"""
210210
return await AsyncIndex.create(self.http_client, uid, primary_key)
211211

212+
async def create_snapshot(self) -> TaskInfo:
213+
"""Trigger the creation of a Meilisearch snapshot.
214+
215+
Returns:
216+
217+
The details of the task.
218+
219+
Raises:
220+
221+
MeilisearchCommunicationError: If there was an error communicating with the server.
222+
MeilisearchApiError: If the Meilisearch API returned an error.
223+
224+
Examples:
225+
226+
>>> from meilisearch_python_sdk import AsyncClient
227+
>>> async with AsyncClient("http://localhost.com", "masterKey") as client:
228+
>>> await client.create_snapshot()
229+
"""
230+
response = await self._http_requests.post("snapshots")
231+
232+
return TaskInfo(**response.json())
233+
212234
async def delete_index_if_exists(self, uid: str) -> bool:
213235
"""Deletes an index if it already exists.
214236
@@ -1015,6 +1037,28 @@ def create_index(self, uid: str, primary_key: str | None = None) -> Index:
10151037
"""
10161038
return Index.create(self.http_client, uid, primary_key)
10171039

1040+
def create_snapshot(self) -> TaskInfo:
1041+
"""Trigger the creation of a Meilisearch snapshot.
1042+
1043+
Returns:
1044+
1045+
The details of the task.
1046+
1047+
Raises:
1048+
1049+
MeilisearchCommunicationError: If there was an error communicating with the server.
1050+
MeilisearchApiError: If the Meilisearch API returned an error.
1051+
1052+
Examples:
1053+
1054+
>>> from meilisearch_python_sdk import Client
1055+
>>> client = Client("http://localhost.com", "masterKey")
1056+
>>> client.create_snapshot()
1057+
"""
1058+
response = self._http_requests.post("snapshots")
1059+
1060+
return TaskInfo(**response.json())
1061+
10181062
def delete_index_if_exists(self, uid: str) -> bool:
10191063
"""Deletes an index if it already exists.
10201064

0 commit comments

Comments
 (0)