meilisearch-python-sdk 2.6.1__tar.gz → 2.7.0__tar.gz
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.
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/PKG-INFO +1 -1
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/_http_requests.py +63 -19
- meilisearch_python_sdk-2.7.0/meilisearch_python_sdk/_version.py +1 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/index.py +373 -130
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/pyproject.toml +1 -1
- meilisearch_python_sdk-2.6.1/meilisearch_python_sdk/_version.py +0 -1
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/LICENSE +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/README.md +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/__init__.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/_client.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/_task.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/_utils.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/decorators.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/errors.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/models/__init__.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/models/client.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/models/documents.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/models/health.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/models/index.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/models/search.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/models/settings.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/models/task.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/models/version.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/plugins.py +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/py.typed +0 -0
- {meilisearch_python_sdk-2.6.1 → meilisearch_python_sdk-2.7.0}/meilisearch_python_sdk/types.py +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import gzip
|
|
4
|
+
import json
|
|
3
5
|
from functools import lru_cache
|
|
4
6
|
from typing import Any, Callable
|
|
5
7
|
|
|
@@ -30,15 +32,22 @@ class AsyncHttpRequests:
|
|
|
30
32
|
http_method: Callable,
|
|
31
33
|
path: str,
|
|
32
34
|
body: Any | None = None,
|
|
33
|
-
content_type: str = "
|
|
35
|
+
content_type: str = "application/json",
|
|
36
|
+
compress: bool = False,
|
|
34
37
|
) -> Response:
|
|
35
|
-
headers = build_headers(content_type)
|
|
38
|
+
headers = build_headers(content_type, compress)
|
|
39
|
+
|
|
36
40
|
try:
|
|
37
41
|
if body is None:
|
|
38
42
|
response = await http_method(path)
|
|
39
|
-
elif content_type == "application/json":
|
|
43
|
+
elif content_type == "application/json" and not compress:
|
|
40
44
|
response = await http_method(path, json=body, headers=headers)
|
|
41
45
|
else:
|
|
46
|
+
if body and compress:
|
|
47
|
+
if content_type == "application/json":
|
|
48
|
+
body = gzip.compress(json.dumps(body).encode("utf-8"))
|
|
49
|
+
else:
|
|
50
|
+
body = gzip.compress((body).encode("utf-8"))
|
|
42
51
|
response = await http_method(path, content=body, headers=headers)
|
|
43
52
|
|
|
44
53
|
response.raise_for_status()
|
|
@@ -57,19 +66,31 @@ class AsyncHttpRequests:
|
|
|
57
66
|
return await self._send_request(self.http_client.get, path)
|
|
58
67
|
|
|
59
68
|
async def patch(
|
|
60
|
-
self,
|
|
69
|
+
self,
|
|
70
|
+
path: str,
|
|
71
|
+
body: Any | None = None,
|
|
72
|
+
content_type: str = "application/json",
|
|
73
|
+
compress: bool = False,
|
|
61
74
|
) -> Response:
|
|
62
|
-
return await self._send_request(self.http_client.patch, path, body, content_type)
|
|
75
|
+
return await self._send_request(self.http_client.patch, path, body, content_type, compress)
|
|
63
76
|
|
|
64
77
|
async def post(
|
|
65
|
-
self,
|
|
78
|
+
self,
|
|
79
|
+
path: str,
|
|
80
|
+
body: Any | None = None,
|
|
81
|
+
content_type: str = "application/json",
|
|
82
|
+
compress: bool = False,
|
|
66
83
|
) -> Response:
|
|
67
|
-
return await self._send_request(self.http_client.post, path, body, content_type)
|
|
84
|
+
return await self._send_request(self.http_client.post, path, body, content_type, compress)
|
|
68
85
|
|
|
69
86
|
async def put(
|
|
70
|
-
self,
|
|
87
|
+
self,
|
|
88
|
+
path: str,
|
|
89
|
+
body: Any | None = None,
|
|
90
|
+
content_type: str = "application/json",
|
|
91
|
+
compress: bool = False,
|
|
71
92
|
) -> Response:
|
|
72
|
-
return await self._send_request(self.http_client.put, path, body, content_type)
|
|
93
|
+
return await self._send_request(self.http_client.put, path, body, content_type, compress)
|
|
73
94
|
|
|
74
95
|
async def delete(self, path: str, body: dict | None = None) -> Response:
|
|
75
96
|
return await self._send_request(self.http_client.delete, path, body)
|
|
@@ -85,14 +106,20 @@ class HttpRequests:
|
|
|
85
106
|
path: str,
|
|
86
107
|
body: Any | None = None,
|
|
87
108
|
content_type: str = "applicaton/json",
|
|
109
|
+
compress: bool = False,
|
|
88
110
|
) -> Response:
|
|
89
|
-
headers = build_headers(content_type)
|
|
111
|
+
headers = build_headers(content_type, compress)
|
|
90
112
|
try:
|
|
91
113
|
if not body:
|
|
92
114
|
response = http_method(path)
|
|
93
|
-
elif content_type == "application/json":
|
|
115
|
+
elif content_type == "application/json" and not compress:
|
|
94
116
|
response = http_method(path, json=body, headers=headers)
|
|
95
117
|
else:
|
|
118
|
+
if body and compress:
|
|
119
|
+
if content_type == "application/json":
|
|
120
|
+
body = gzip.compress(json.dumps(body).encode("utf-8"))
|
|
121
|
+
else:
|
|
122
|
+
body = gzip.compress((body).encode("utf-8"))
|
|
96
123
|
response = http_method(path, content=body, headers=headers)
|
|
97
124
|
|
|
98
125
|
response.raise_for_status()
|
|
@@ -111,26 +138,43 @@ class HttpRequests:
|
|
|
111
138
|
return self._send_request(self.http_client.get, path)
|
|
112
139
|
|
|
113
140
|
def patch(
|
|
114
|
-
self,
|
|
141
|
+
self,
|
|
142
|
+
path: str,
|
|
143
|
+
body: Any | None = None,
|
|
144
|
+
content_type: str = "application/json",
|
|
145
|
+
compress: bool = False,
|
|
115
146
|
) -> Response:
|
|
116
|
-
return self._send_request(self.http_client.patch, path, body, content_type)
|
|
147
|
+
return self._send_request(self.http_client.patch, path, body, content_type, compress)
|
|
117
148
|
|
|
118
149
|
def post(
|
|
119
|
-
self,
|
|
150
|
+
self,
|
|
151
|
+
path: str,
|
|
152
|
+
body: Any | None = None,
|
|
153
|
+
content_type: str = "application/json",
|
|
154
|
+
compress: bool = False,
|
|
120
155
|
) -> Response:
|
|
121
|
-
return self._send_request(self.http_client.post, path, body, content_type)
|
|
156
|
+
return self._send_request(self.http_client.post, path, body, content_type, compress)
|
|
122
157
|
|
|
123
158
|
def put(
|
|
124
|
-
self,
|
|
159
|
+
self,
|
|
160
|
+
path: str,
|
|
161
|
+
body: Any | None = None,
|
|
162
|
+
content_type: str = "application/json",
|
|
163
|
+
compress: bool = False,
|
|
125
164
|
) -> Response:
|
|
126
|
-
return self._send_request(self.http_client.put, path, body, content_type)
|
|
165
|
+
return self._send_request(self.http_client.put, path, body, content_type, compress)
|
|
127
166
|
|
|
128
167
|
def delete(self, path: str, body: dict | None = None) -> Response:
|
|
129
168
|
return self._send_request(self.http_client.delete, path, body)
|
|
130
169
|
|
|
131
170
|
|
|
132
|
-
def build_headers(content_type: str) -> dict[str, str]:
|
|
133
|
-
|
|
171
|
+
def build_headers(content_type: str, compress: bool) -> dict[str, str]:
|
|
172
|
+
headers = {"user-agent": user_agent(), "Content-Type": content_type}
|
|
173
|
+
|
|
174
|
+
if compress:
|
|
175
|
+
headers["Content-Encoding"] = "gzip"
|
|
176
|
+
|
|
177
|
+
return headers
|
|
134
178
|
|
|
135
179
|
|
|
136
180
|
@lru_cache(maxsize=1)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "2.7.0"
|