meilisearch-python-sdk 4.0.0__py3-none-any.whl → 4.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of meilisearch-python-sdk might be problematic. Click here for more details.

@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from datetime import datetime
3
4
  from typing import TYPE_CHECKING
4
5
 
5
6
  from meilisearch_python_sdk._utils import get_async_client, get_client
@@ -28,9 +29,38 @@ async def async_get_batch(
28
29
  return BatchResult(**response.json())
29
30
 
30
31
 
31
- async def async_get_batches(client: HttpxAsyncClient | AsyncClient) -> BatchStatus:
32
+ async def async_get_batches(
33
+ client: HttpxAsyncClient | AsyncClient,
34
+ *,
35
+ uids: list[int] | None = None,
36
+ batch_uids: list[int] | None = None,
37
+ index_uids: list[int] | None = None,
38
+ statuses: list[str] | None = None,
39
+ types: list[str] | None = None,
40
+ limit: int = 20,
41
+ from_: str | None = None,
42
+ reverse: bool = False,
43
+ before_enqueued_at: datetime | None = None,
44
+ after_enqueued_at: datetime | None = None,
45
+ before_started_at: datetime | None = None,
46
+ after_finished_at: datetime | None = None,
47
+ ) -> BatchStatus:
32
48
  client_ = get_async_client(client)
33
- response = await client_.get("batches")
49
+ params = _build_parameters(
50
+ uids=uids,
51
+ batch_uids=batch_uids,
52
+ index_uids=index_uids,
53
+ statuses=statuses,
54
+ types=types,
55
+ limit=limit,
56
+ from_=from_,
57
+ reverse=reverse,
58
+ before_enqueued_at=before_enqueued_at,
59
+ after_enqueued_at=after_enqueued_at,
60
+ before_started_at=before_started_at,
61
+ after_finished_at=after_finished_at,
62
+ )
63
+ response = await client_.get("batches", params=params)
34
64
 
35
65
  return BatchStatus(**response.json())
36
66
 
@@ -45,8 +75,92 @@ def get_batch(client: HttpxClient | Client, batch_uid: int) -> BatchResult | Non
45
75
  return BatchResult(**response.json())
46
76
 
47
77
 
48
- def get_batches(client: HttpxClient | Client) -> BatchStatus:
78
+ def get_batches(
79
+ client: HttpxClient | Client,
80
+ *,
81
+ uids: list[int] | None = None,
82
+ batch_uids: list[int] | None = None,
83
+ index_uids: list[int] | None = None,
84
+ statuses: list[str] | None = None,
85
+ types: list[str] | None = None,
86
+ limit: int = 20,
87
+ from_: str | None = None,
88
+ reverse: bool = False,
89
+ before_enqueued_at: datetime | None = None,
90
+ after_enqueued_at: datetime | None = None,
91
+ before_started_at: datetime | None = None,
92
+ after_finished_at: datetime | None = None,
93
+ ) -> BatchStatus:
49
94
  client_ = get_client(client)
50
- response = client_.get("batches")
95
+ params = _build_parameters(
96
+ uids=uids,
97
+ batch_uids=batch_uids,
98
+ index_uids=index_uids,
99
+ statuses=statuses,
100
+ types=types,
101
+ limit=limit,
102
+ from_=from_,
103
+ reverse=reverse,
104
+ before_enqueued_at=before_enqueued_at,
105
+ after_enqueued_at=after_enqueued_at,
106
+ before_started_at=before_started_at,
107
+ after_finished_at=after_finished_at,
108
+ )
109
+
110
+ response = client_.get("batches", params=params)
51
111
 
52
112
  return BatchStatus(**response.json())
113
+
114
+
115
+ def _build_parameters(
116
+ *,
117
+ uids: list[int] | None = None,
118
+ batch_uids: list[int] | None = None,
119
+ index_uids: list[int] | None = None,
120
+ statuses: list[str] | None = None,
121
+ types: list[str] | None = None,
122
+ limit: int = 20,
123
+ from_: str | None = None,
124
+ reverse: bool = False,
125
+ before_enqueued_at: datetime | None = None,
126
+ after_enqueued_at: datetime | None = None,
127
+ before_started_at: datetime | None = None,
128
+ after_finished_at: datetime | None = None,
129
+ ) -> dict[str, str]:
130
+ params = {}
131
+
132
+ if uids:
133
+ params["uids"] = ",".join([str(uid) for uid in uids])
134
+
135
+ if batch_uids: # pragma: no cover
136
+ params["batchUids"] = ",".join([str(uid) for uid in batch_uids])
137
+
138
+ if index_uids: # pragma: no cover
139
+ params["indexUids"] = ",".join([str(uid) for uid in index_uids])
140
+
141
+ if statuses: # pragma: no cover
142
+ params["statuses"] = ",".join(statuses)
143
+
144
+ if types: # pragma: no cover
145
+ params["types"] = ",".join(types)
146
+
147
+ params["limit"] = str(limit)
148
+
149
+ if from_: # pragma: no cover
150
+ params["from"] = from_
151
+
152
+ params["reverse"] = "true" if reverse else "false"
153
+
154
+ if before_enqueued_at: # pragma: no cover
155
+ params["beforeEnqueuedAt"] = before_enqueued_at.isoformat()
156
+
157
+ if after_enqueued_at: # pragma: no cover
158
+ params["afterEnqueuedAt"] = after_enqueued_at.isoformat()
159
+
160
+ if before_started_at: # pragma: no cover
161
+ params["beforeStartedAt"] = before_started_at.isoformat()
162
+
163
+ if after_finished_at: # pragma: no cover
164
+ params["afterFinishedAt"] = after_finished_at.isoformat()
165
+
166
+ return params
@@ -9,7 +9,9 @@ from httpx import AsyncClient as HttpxAsyncClient
9
9
  from httpx import Client as HttpxClient
10
10
 
11
11
  from meilisearch_python_sdk import _task
12
- from meilisearch_python_sdk._batch import async_get_batch, async_get_batches, get_batch, get_batches
12
+ from meilisearch_python_sdk._batch import async_get_batch, async_get_batches
13
+ from meilisearch_python_sdk._batch import get_batch as _get_batch
14
+ from meilisearch_python_sdk._batch import get_batches as _get_batches
13
15
  from meilisearch_python_sdk._http_requests import AsyncHttpRequests, HttpRequests
14
16
  from meilisearch_python_sdk.errors import InvalidRestriction, MeilisearchApiError
15
17
  from meilisearch_python_sdk.index import AsyncIndex, Index
@@ -775,14 +777,43 @@ class AsyncClient(BaseClient):
775
777
  async def get_batch(self, batch_uid: int) -> BatchResult | None:
776
778
  return await async_get_batch(self, batch_uid)
777
779
 
778
- async def get_batches(self) -> BatchStatus:
779
- return await async_get_batches(self)
780
+ async def get_batches(
781
+ self,
782
+ *,
783
+ uids: list[int] | None = None,
784
+ batch_uids: list[int] | None = None,
785
+ index_uids: list[int] | None = None,
786
+ statuses: list[str] | None = None,
787
+ types: list[str] | None = None,
788
+ limit: int = 20,
789
+ from_: str | None = None,
790
+ reverse: bool = False,
791
+ before_enqueued_at: datetime | None = None,
792
+ after_enqueued_at: datetime | None = None,
793
+ before_started_at: datetime | None = None,
794
+ after_finished_at: datetime | None = None,
795
+ ) -> BatchStatus:
796
+ return await async_get_batches(
797
+ self,
798
+ uids=uids,
799
+ batch_uids=batch_uids,
800
+ index_uids=index_uids,
801
+ statuses=statuses,
802
+ types=types,
803
+ limit=limit,
804
+ from_=from_,
805
+ reverse=reverse,
806
+ before_enqueued_at=before_enqueued_at,
807
+ after_enqueued_at=after_enqueued_at,
808
+ before_started_at=before_started_at,
809
+ after_finished_at=after_finished_at,
810
+ )
780
811
 
781
812
  async def cancel_tasks(
782
813
  self,
783
814
  *,
784
- uids: list[str] | None = None,
785
- index_uids: list[str] | None = None,
815
+ uids: list[int] | None = None,
816
+ index_uids: list[int] | None = None,
786
817
  statuses: list[str] | None = None,
787
818
  types: list[str] | None = None,
788
819
  before_enqueued_at: datetime | None = None,
@@ -856,8 +887,8 @@ class AsyncClient(BaseClient):
856
887
  async def delete_tasks(
857
888
  self,
858
889
  *,
859
- uids: list[str] | None = None,
860
- index_uids: list[str] | None = None,
890
+ uids: list[int] | None = None,
891
+ index_uids: list[int] | None = None,
861
892
  statuses: list[str] | None = None,
862
893
  types: list[str] | None = None,
863
894
  before_enqueued_at: datetime | None = None,
@@ -1599,16 +1630,45 @@ class Client(BaseClient):
1599
1630
  return TaskInfo(**response.json())
1600
1631
 
1601
1632
  def get_batch(self, batch_uid: int) -> BatchResult | None:
1602
- return get_batch(self, batch_uid)
1633
+ return _get_batch(self, batch_uid)
1603
1634
 
1604
- def get_batches(self) -> BatchStatus:
1605
- return get_batches(self)
1635
+ def get_batches(
1636
+ self,
1637
+ *,
1638
+ uids: list[int] | None = None,
1639
+ batch_uids: list[int] | None = None,
1640
+ index_uids: list[int] | None = None,
1641
+ statuses: list[str] | None = None,
1642
+ types: list[str] | None = None,
1643
+ limit: int = 20,
1644
+ from_: str | None = None,
1645
+ reverse: bool = False,
1646
+ before_enqueued_at: datetime | None = None,
1647
+ after_enqueued_at: datetime | None = None,
1648
+ before_started_at: datetime | None = None,
1649
+ after_finished_at: datetime | None = None,
1650
+ ) -> BatchStatus:
1651
+ return _get_batches(
1652
+ self,
1653
+ uids=uids,
1654
+ batch_uids=batch_uids,
1655
+ index_uids=index_uids,
1656
+ statuses=statuses,
1657
+ types=types,
1658
+ limit=limit,
1659
+ from_=from_,
1660
+ reverse=reverse,
1661
+ before_enqueued_at=before_enqueued_at,
1662
+ after_enqueued_at=after_enqueued_at,
1663
+ before_started_at=before_started_at,
1664
+ after_finished_at=after_finished_at,
1665
+ )
1606
1666
 
1607
1667
  def cancel_tasks(
1608
1668
  self,
1609
1669
  *,
1610
- uids: list[str] | None = None,
1611
- index_uids: list[str] | None = None,
1670
+ uids: list[int] | None = None,
1671
+ index_uids: list[int] | None = None,
1612
1672
  statuses: list[str] | None = None,
1613
1673
  types: list[str] | None = None,
1614
1674
  before_enqueued_at: datetime | None = None,
@@ -1660,8 +1720,8 @@ class Client(BaseClient):
1660
1720
  def delete_tasks(
1661
1721
  self,
1662
1722
  *,
1663
- uids: list[str] | None = None,
1664
- index_uids: list[str] | None = None,
1723
+ uids: list[int] | None = None,
1724
+ index_uids: list[int] | None = None,
1665
1725
  statuses: list[str] | None = None,
1666
1726
  types: list[str] | None = None,
1667
1727
  before_enqueued_at: datetime | None = None,
@@ -22,8 +22,8 @@ if TYPE_CHECKING:
22
22
  async def async_cancel_tasks(
23
23
  client: HttpxAsyncClient | AsyncClient,
24
24
  *,
25
- uids: list[str] | None = None,
26
- index_uids: list[str] | None = None,
25
+ uids: list[int] | None = None,
26
+ index_uids: list[int] | None = None,
27
27
  statuses: list[str] | None = None,
28
28
  types: list[str] | None = None,
29
29
  before_enqueued_at: datetime | None = None,
@@ -86,8 +86,8 @@ async def async_cancel_tasks(
86
86
  async def async_delete_tasks(
87
87
  client: HttpxAsyncClient | AsyncClient,
88
88
  *,
89
- uids: list[str] | None = None,
90
- index_uids: list[str] | None = None,
89
+ uids: list[int] | None = None,
90
+ index_uids: list[int] | None = None,
91
91
  statuses: list[str] | None = None,
92
92
  types: list[str] | None = None,
93
93
  before_enqueued_at: datetime | None = None,
@@ -193,8 +193,8 @@ async def async_wait_for_task(
193
193
  def cancel_tasks(
194
194
  client: HttpxClient | Client,
195
195
  *,
196
- uids: list[str] | None = None,
197
- index_uids: list[str] | None = None,
196
+ uids: list[int] | None = None,
197
+ index_uids: list[int] | None = None,
198
198
  statuses: list[str] | None = None,
199
199
  types: list[str] | None = None,
200
200
  before_enqueued_at: datetime | None = None,
@@ -227,8 +227,8 @@ def cancel_tasks(
227
227
  def delete_tasks(
228
228
  client: HttpxClient | Client,
229
229
  *,
230
- uids: list[str] | None = None,
231
- index_uids: list[str] | None = None,
230
+ uids: list[int] | None = None,
231
+ index_uids: list[int] | None = None,
232
232
  statuses: list[str] | None = None,
233
233
  types: list[str] | None = None,
234
234
  before_enqueued_at: datetime | None = None,
@@ -338,8 +338,8 @@ def _get_json_handler(
338
338
 
339
339
 
340
340
  def _process_params(
341
- uids: list[str] | None = None,
342
- index_uids: list[str] | None = None,
341
+ uids: list[int] | None = None,
342
+ index_uids: list[int] | None = None,
343
343
  statuses: list[str] | None = None,
344
344
  types: list[str] | None = None,
345
345
  before_enqueued_at: datetime | None = None,
@@ -1 +1 @@
1
- VERSION = "4.0.0"
1
+ VERSION = "4.1.0"
@@ -2,10 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import json
4
4
  from abc import ABC, abstractmethod
5
- from typing import TYPE_CHECKING, Any
6
-
7
- if TYPE_CHECKING: # pragma: no cover
8
- pass
5
+ from typing import Any
9
6
 
10
7
  try:
11
8
  import orjson
@@ -1,13 +1,15 @@
1
1
  from __future__ import annotations
2
2
 
3
- import sys
4
3
  from collections.abc import MutableMapping
5
- from typing import Any, Union
4
+ from typing import TYPE_CHECKING, Any, Union
6
5
 
7
- if sys.version_info >= (3, 10): # pragma: no cover
8
- from typing import TypeAlias
9
- else:
10
- from typing_extensions import TypeAlias
6
+ if TYPE_CHECKING: # pragma: no cover
7
+ import sys
8
+
9
+ if sys.version_info >= (3, 10):
10
+ from typing import TypeAlias
11
+ else:
12
+ from typing_extensions import TypeAlias
11
13
 
12
14
  Filter: TypeAlias = Union[str, list[Union[str, list[str]]]]
13
15
  JsonDict: TypeAlias = dict[str, Any]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meilisearch-python-sdk
3
- Version: 4.0.0
3
+ Version: 4.1.0
4
4
  Summary: A Python client providing both async and sync support for the Meilisearch API
5
5
  Project-URL: repository, https://github.com/sanders41/meilisearch-python-sdk
6
6
  Project-URL: homepage, https://github.com/sanders41/meilisearch-python-sdk
@@ -57,7 +57,7 @@ Description-Content-Type: text/markdown
57
57
 
58
58
  # Meilisearch Python SDK
59
59
 
60
- [![Tests Status](https://github.com/sanders41/meilisearch-python-sdk/workflows/Testing/badge.svg?branch=main&event=push)](https://github.com/sanders41/meilisearch-python-sdk/actions?query=workflow%3ATesting+branch%3Amain+event%3Apush)
60
+ [![Tests Status](https://github.com/sanders41/meilisearch-python-sdk/actions/workflows/testing.yml/badge.svg?branch=main&event=push)](https://github.com/sanders41/meilisearch-python-sdk/actions?query=workflow%3ATesting+branch%3Amain+event%3Apush)
61
61
  [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/sanders41/meilisearch-python-sdk/main.svg)](https://results.pre-commit.ci/latest/github/sanders41/meilisearch-python-sdk/main)
62
62
  [![Coverage](https://codecov.io/github/sanders41/meilisearch-python-sdk/coverage.svg?branch=main)](https://codecov.io/gh/sanders41/meilisearch-python-sdk)
63
63
  [![PyPI version](https://badge.fury.io/py/meilisearch-python-sdk.svg)](https://badge.fury.io/py/meilisearch-python-sdk)
@@ -142,15 +142,15 @@ variable, this will be an `UpdateId` object, and use it to check the status of t
142
142
  #### AsyncClient
143
143
 
144
144
  ```py
145
- update = await index.add_documents(documents)
146
- status = await client.index('books').get_update_status(update.update_id)
145
+ task = await index.add_documents([{"id": 1, "title": "test"}])
146
+ status = await client.get_task(task.task_uid)
147
147
  ```
148
148
 
149
149
  #### Client
150
150
 
151
151
  ```py
152
- update = index.add_documents(documents)
153
- status = client.index('books').get_update_status(update.update_id)
152
+ task = index.add_documents([{"id": 1, "title": "test"}])
153
+ status = client.get_task(task.task_uid)
154
154
  ```
155
155
 
156
156
  ### Basic Searching
@@ -1,17 +1,17 @@
1
1
  meilisearch_python_sdk/__init__.py,sha256=SB0Jlm6FwT13J9xasZKseZzTWBk0hkfe1CWyWmIIZnE,258
2
- meilisearch_python_sdk/_batch.py,sha256=kO8JJpelrmDQbBVA5teFiG-tX8KBMcONYHbcqpHCfg4,1603
3
- meilisearch_python_sdk/_client.py,sha256=HN_T9rotwqCrsKjJEszB0hgUdkV0bZLVkYhkbqvUPbo,71204
2
+ meilisearch_python_sdk/_batch.py,sha256=Hbt-M8Lt8ZDZqcKToUMzUd5zvT-gku709er4pRlvXWk,5065
3
+ meilisearch_python_sdk/_client.py,sha256=LJ_MXxdIMfZ-Rva3feZRS7pzfY7rgr0lYUxY8hD9be4,73282
4
4
  meilisearch_python_sdk/_http_requests.py,sha256=O3M3n-t1jAKwccWowPbk-HPD3ExtHq8a3XhnZT5facs,6746
5
- meilisearch_python_sdk/_task.py,sha256=9w8ncyi2KQkfDaO5ejbD2IzLejXIQCZ44bqTarjcwXM,12485
5
+ meilisearch_python_sdk/_task.py,sha256=QgVcqMlZdURRS_oYpB_bTBa5dvT3Sp_-O0-s6TqAxHk,12485
6
6
  meilisearch_python_sdk/_utils.py,sha256=NoCDxJPhjABeuSxFTNCih585UDWdXEUBD_FvdgtScQw,1539
7
- meilisearch_python_sdk/_version.py,sha256=7fW10HPawx5fQGb_cUxvRh9Y5glb-Iser4_JvWxqCGk,18
7
+ meilisearch_python_sdk/_version.py,sha256=5hHes-uiUQVCKxIz0rFy7XVtaMCXeP6lPXPOk_JZPmU,18
8
8
  meilisearch_python_sdk/decorators.py,sha256=njMn40P-qOzKGGQLCDpsBKWyj2ai10s4XG4IUBSHoD4,8674
9
9
  meilisearch_python_sdk/errors.py,sha256=RNNHXtXLBiCVZaLM2MeKKs9RbRuE-SLRttiPeVAEXgA,2133
10
10
  meilisearch_python_sdk/index.py,sha256=QIZk0O8cZ3qR2osPb03gSatR72dGaFEF_MC0PqTLmdU,341518
11
- meilisearch_python_sdk/json_handler.py,sha256=q_87zSnJfDNuVEI9cEvuOQOGBC7AGWJMEqCh2kGAAqA,2107
11
+ meilisearch_python_sdk/json_handler.py,sha256=c1rGKzYlE0dGfLygQjPqVUNfQkN1JvafBGmIx31JW8g,2044
12
12
  meilisearch_python_sdk/plugins.py,sha256=YySzTuVr4IrogTgrP8q-gZPsew8TwedopjWnTj5eV48,3607
13
13
  meilisearch_python_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- meilisearch_python_sdk/types.py,sha256=VBzt-JF6w1f5V_aTAM3NetDQxs9fscnRy8t-Y1HWZXM,404
14
+ meilisearch_python_sdk/types.py,sha256=WxbQBPfy5S_j9hRKJ74ktuIxkH9Oifn7GYStQjs49Ik,458
15
15
  meilisearch_python_sdk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  meilisearch_python_sdk/models/batch.py,sha256=w0R0tINqm5DkkdX-9RXDqyS8rxDGCjEySSzzyVZ_gGs,1465
17
17
  meilisearch_python_sdk/models/client.py,sha256=ntecx3ya_5EwgnxZfqYsBg9UlyQe_i3jgaTlRWFUVTE,2451
@@ -22,7 +22,7 @@ meilisearch_python_sdk/models/search.py,sha256=Wmv8LmhwMVGoZnndkhw16RuoxxC203jlc
22
22
  meilisearch_python_sdk/models/settings.py,sha256=uCm-F4PDeCR5e2d8WrGT8hwq0VhrCv19MatQVpS8ocU,4154
23
23
  meilisearch_python_sdk/models/task.py,sha256=_PyuH5tSlHCKMwFsx1nMKjFgc8bDBZxscKYZOdf-4pg,2166
24
24
  meilisearch_python_sdk/models/version.py,sha256=YDu-aj5H-d6nSaWRTXzlwWghmZAoiknaw250UyEd48I,215
25
- meilisearch_python_sdk-4.0.0.dist-info/METADATA,sha256=JNg2qOakPOhUf0U3YMlfyaIffZu11lNVTJWzavY_2zY,9771
26
- meilisearch_python_sdk-4.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- meilisearch_python_sdk-4.0.0.dist-info/licenses/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
28
- meilisearch_python_sdk-4.0.0.dist-info/RECORD,,
25
+ meilisearch_python_sdk-4.1.0.dist-info/METADATA,sha256=ZTC9P3sbdC7sxtMnXpHAa0EOagZ1zXkWWOPrnSf84cs,9763
26
+ meilisearch_python_sdk-4.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ meilisearch_python_sdk-4.1.0.dist-info/licenses/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
28
+ meilisearch_python_sdk-4.1.0.dist-info/RECORD,,