meilisearch-python-sdk 5.5.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.
Files changed (32) hide show
  1. meilisearch_python_sdk/__init__.py +8 -0
  2. meilisearch_python_sdk/_batch.py +166 -0
  3. meilisearch_python_sdk/_client.py +2468 -0
  4. meilisearch_python_sdk/_http_requests.py +197 -0
  5. meilisearch_python_sdk/_task.py +368 -0
  6. meilisearch_python_sdk/_utils.py +58 -0
  7. meilisearch_python_sdk/_version.py +1 -0
  8. meilisearch_python_sdk/decorators.py +242 -0
  9. meilisearch_python_sdk/errors.py +75 -0
  10. meilisearch_python_sdk/index/__init__.py +4 -0
  11. meilisearch_python_sdk/index/_common.py +296 -0
  12. meilisearch_python_sdk/index/async_index.py +4891 -0
  13. meilisearch_python_sdk/index/index.py +3839 -0
  14. meilisearch_python_sdk/json_handler.py +74 -0
  15. meilisearch_python_sdk/models/__init__.py +0 -0
  16. meilisearch_python_sdk/models/batch.py +58 -0
  17. meilisearch_python_sdk/models/client.py +97 -0
  18. meilisearch_python_sdk/models/documents.py +12 -0
  19. meilisearch_python_sdk/models/health.py +5 -0
  20. meilisearch_python_sdk/models/index.py +46 -0
  21. meilisearch_python_sdk/models/search.py +126 -0
  22. meilisearch_python_sdk/models/settings.py +197 -0
  23. meilisearch_python_sdk/models/task.py +77 -0
  24. meilisearch_python_sdk/models/version.py +9 -0
  25. meilisearch_python_sdk/models/webhook.py +24 -0
  26. meilisearch_python_sdk/plugins.py +124 -0
  27. meilisearch_python_sdk/py.typed +0 -0
  28. meilisearch_python_sdk/types.py +8 -0
  29. meilisearch_python_sdk-5.5.0.dist-info/METADATA +279 -0
  30. meilisearch_python_sdk-5.5.0.dist-info/RECORD +32 -0
  31. meilisearch_python_sdk-5.5.0.dist-info/WHEEL +4 -0
  32. meilisearch_python_sdk-5.5.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,8 @@
1
+ from meilisearch_python_sdk._client import AsyncClient, Client
2
+ from meilisearch_python_sdk._version import VERSION
3
+ from meilisearch_python_sdk.index import AsyncIndex, Index
4
+
5
+ __version__ = VERSION
6
+
7
+
8
+ __all__ = ["AsyncClient", "AsyncIndex", "Client", "Index"]
@@ -0,0 +1,166 @@
1
+ from __future__ import annotations
2
+
3
+ from datetime import datetime
4
+ from typing import TYPE_CHECKING
5
+
6
+ from meilisearch_python_sdk._utils import get_async_client, get_client
7
+ from meilisearch_python_sdk.errors import BatchNotFoundError
8
+ from meilisearch_python_sdk.models.batch import BatchResult, BatchStatus
9
+
10
+ if TYPE_CHECKING:
11
+ from httpx import AsyncClient as HttpxAsyncClient # pragma: no cover
12
+ from httpx import Client as HttpxClient # pragma: no cover
13
+
14
+ from meilisearch_python_sdk._client import ( # pragma: no cover
15
+ AsyncClient,
16
+ Client,
17
+ )
18
+
19
+
20
+ async def async_get_batch(
21
+ client: HttpxAsyncClient | AsyncClient, batch_uid: int
22
+ ) -> BatchResult | None:
23
+ client_ = get_async_client(client)
24
+ response = await client_.get(f"batches/{batch_uid}")
25
+
26
+ if response.status_code == 404:
27
+ raise BatchNotFoundError(f"Batch {batch_uid} not found")
28
+
29
+ return BatchResult(**response.json())
30
+
31
+
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:
48
+ client_ = get_async_client(client)
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)
64
+
65
+ return BatchStatus(**response.json())
66
+
67
+
68
+ def get_batch(client: HttpxClient | Client, batch_uid: int) -> BatchResult | None:
69
+ client_ = get_client(client)
70
+ response = client_.get(f"batches/{batch_uid}")
71
+
72
+ if response.status_code == 404:
73
+ raise BatchNotFoundError(f"Batch {batch_uid} not found")
74
+
75
+ return BatchResult(**response.json())
76
+
77
+
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:
94
+ client_ = get_client(client)
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)
111
+
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