1010from httpx import AsyncClient
1111
1212from meilisearch_python_async ._http_requests import HttpRequests
13- from meilisearch_python_async .errors import InvalidRestriction , MeiliSearchApiError
13+ from meilisearch_python_async .errors import InvalidRestriction , MeilisearchApiError
1414from meilisearch_python_async .index import Index
1515from meilisearch_python_async .models .client import ClientStats , Key , KeyCreate , KeySearch , KeyUpdate
1616from meilisearch_python_async .models .health import Health
2121
2222
2323class Client :
24- """The client to connect to the MeiliSearchApi ."""
24+ """The client to connect to the MeilisearchApi ."""
2525
2626 def __init__ (
2727 self ,
@@ -35,8 +35,8 @@ def __init__(
3535
3636 Args:
3737
38- url: The url to the MeiliSearch API (ex: http://localhost:7700)
39- api_key: The optional API key for MeiliSearch . Defaults to None.
38+ url: The url to the Meilisearch API (ex: http://localhost:7700)
39+ api_key: The optional API key for Meilisearch . Defaults to None.
4040 timeout: The amount of time in seconds that the client will wait for a response before
4141 timing out. Defaults to None.
4242 verify: SSL certificates (a.k.a CA bundle) used to
@@ -72,7 +72,7 @@ async def aclose(self) -> None:
7272 await self .http_client .aclose ()
7373
7474 async def create_dump (self ) -> TaskInfo :
75- """Trigger the creation of a MeiliSearch dump.
75+ """Trigger the creation of a Meilisearch dump.
7676
7777 Returns:
7878
@@ -81,7 +81,7 @@ async def create_dump(self) -> TaskInfo:
8181 Raises:
8282
8383 MeilisearchCommunicationError: If there was an error communicating with the server.
84- MeilisearchApiError: If the MeiliSearch API returned an error.
84+ MeilisearchApiError: If the Meilisearch API returned an error.
8585
8686 Examples:
8787
@@ -108,7 +108,7 @@ async def create_index(self, uid: str, primary_key: str | None = None) -> Index:
108108 Raises:
109109
110110 MeilisearchCommunicationError: If there was an error communicating with the server.
111- MeilisearchApiError: If the MeiliSearch API returned an error.
111+ MeilisearchApiError: If the Meilisearch API returned an error.
112112
113113 Examples:
114114
@@ -132,7 +132,7 @@ async def delete_index_if_exists(self, uid: str) -> bool:
132132 Raises:
133133
134134 MeilisearchCommunicationError: If there was an error communicating with the server.
135- MeilisearchApiError: If the MeiliSearch API returned an error.
135+ MeilisearchApiError: If the Meilisearch API returned an error.
136136
137137 Examples:
138138
@@ -219,7 +219,7 @@ async def get_indexes(self) -> list[Index] | None:
219219 Raises:
220220
221221 MeilisearchCommunicationError: If there was an error communicating with the server.
222- MeilisearchApiError: If the MeiliSearch API returned an error.
222+ MeilisearchApiError: If the Meilisearch API returned an error.
223223
224224 Examples:
225225
@@ -257,7 +257,7 @@ async def get_index(self, uid: str) -> Index:
257257 Raises:
258258
259259 MeilisearchCommunicationError: If there was an error communicating with the server.
260- MeilisearchApiError: If the MeiliSearch API returned an error.
260+ MeilisearchApiError: If the Meilisearch API returned an error.
261261
262262 Examples:
263263
@@ -283,7 +283,7 @@ def index(self, uid: str) -> Index:
283283 Raises:
284284
285285 MeilisearchCommunicationError: If there was an error communicating with the server.
286- MeilisearchApiError: If the MeiliSearch API returned an error.
286+ MeilisearchApiError: If the Meilisearch API returned an error.
287287
288288 Examples:
289289
@@ -304,7 +304,7 @@ async def get_all_stats(self) -> ClientStats:
304304 Raises:
305305
306306 MeilisearchCommunicationError: If there was an error communicating with the server.
307- MeilisearchApiError: If the MeiliSearch API returned an error.
307+ MeilisearchApiError: If the Meilisearch API returned an error.
308308
309309 Examples:
310310
@@ -331,8 +331,8 @@ async def get_or_create_index(self, uid: str, primary_key: str | None = None) ->
331331 Raises:
332332
333333 MeilisearchCommunicationError: If there was an error communicating with the server.
334- MeilisearchApiError: If the MeiliSearch API returned an error.MeiliSearchTimeoutError : If the connection times out.
335- MeiliSearchTimeoutError : If the connection times out.
334+ MeilisearchApiError: If the Meilisearch API returned an error.MeilisearchTimeoutError : If the connection times out.
335+ MeilisearchTimeoutError : If the connection times out.
336336
337337 Examples:
338338
@@ -342,7 +342,7 @@ async def get_or_create_index(self, uid: str, primary_key: str | None = None) ->
342342 """
343343 try :
344344 index_instance = await self .get_index (uid )
345- except MeiliSearchApiError as err :
345+ except MeilisearchApiError as err :
346346 if "index_not_found" not in err .code :
347347 raise
348348 index_instance = await self .create_index (uid , primary_key )
@@ -363,7 +363,7 @@ async def create_key(self, key: KeyCreate) -> Key:
363363 Raises:
364364
365365 MeilisearchCommunicationError: If there was an error communicating with the server.
366- MeilisearchApiError: If the MeiliSearch API returned an error.
366+ MeilisearchApiError: If the Meilisearch API returned an error.
367367
368368 Examples:
369369
@@ -397,7 +397,7 @@ async def delete_key(self, key: str) -> int:
397397 Raises:
398398
399399 MeilisearchCommunicationError: If there was an error communicating with the server.
400- MeilisearchApiError: If the MeiliSearch API returned an error.
400+ MeilisearchApiError: If the Meilisearch API returned an error.
401401
402402 Examples:
403403
@@ -409,7 +409,7 @@ async def delete_key(self, key: str) -> int:
409409 return response .status_code
410410
411411 async def get_keys (self ) -> KeySearch :
412- """Gets the MeiliSearch API keys.
412+ """Gets the Meilisearch API keys.
413413
414414 Returns:
415415
@@ -418,7 +418,7 @@ async def get_keys(self) -> KeySearch:
418418 Raises:
419419
420420 MeilisearchCommunicationError: If there was an error communicating with the server.
421- MeilisearchApiError: If the MeiliSearch API returned an error.
421+ MeilisearchApiError: If the Meilisearch API returned an error.
422422
423423 Examples:
424424
@@ -444,7 +444,7 @@ async def get_key(self, key: str) -> Key:
444444 Raises:
445445
446446 MeilisearchCommunicationError: If there was an error communicating with the server.
447- MeilisearchApiError: If the MeiliSearch API returned an error.
447+ MeilisearchApiError: If the Meilisearch API returned an error.
448448
449449 Examples:
450450
@@ -471,7 +471,7 @@ async def update_key(self, key: KeyUpdate) -> Key:
471471 Raises:
472472
473473 MeilisearchCommunicationError: If there was an error communicating with the server.
474- MeilisearchApiError: If the MeiliSearch API returned an error.
474+ MeilisearchApiError: If the Meilisearch API returned an error.
475475
476476 Examples:
477477
@@ -486,7 +486,11 @@ async def update_key(self, key: KeyUpdate) -> Key:
486486 """
487487 # The json.loads(key.json()) is because Pydantic can't serialize a date in a Python dict,
488488 # but can when converting to a json string.
489- payload = {k : v for k , v in json .loads (key .json (by_alias = True )).items () if v is not None }
489+ payload = {
490+ k : v
491+ for k , v in json .loads (key .json (by_alias = True )).items ()
492+ if v is not None and k != "key"
493+ }
490494 response = await self ._http_requests .patch (f"keys/{ key .key } " , payload )
491495
492496 return Key (** response .json ())
@@ -505,7 +509,7 @@ async def get_raw_index(self, uid: str) -> IndexInfo | None:
505509 Raises:
506510
507511 MeilisearchCommunicationError: If there was an error communicating with the server.
508- MeilisearchApiError: If the MeiliSearch API returned an error.
512+ MeilisearchApiError: If the Meilisearch API returned an error.
509513
510514 Examples:
511515
@@ -532,7 +536,7 @@ async def get_raw_indexes(self) -> list[IndexInfo] | None:
532536 Raises:
533537
534538 MeilisearchCommunicationError: If there was an error communicating with the server.
535- MeilisearchApiError: If the MeiliSearch API returned an error.
539+ MeilisearchApiError: If the Meilisearch API returned an error.
536540
537541 Examples:
538542
@@ -548,16 +552,16 @@ async def get_raw_indexes(self) -> list[IndexInfo] | None:
548552 return [IndexInfo (** x ) for x in response .json ()["results" ]]
549553
550554 async def get_version (self ) -> Version :
551- """Get the MeiliSearch version.
555+ """Get the Meilisearch version.
552556
553557 Returns:
554558
555- Information about the version of MeiliSearch .
559+ Information about the version of Meilisearch .
556560
557561 Raises:
558562
559563 MeilisearchCommunicationError: If there was an error communicating with the server.
560- MeilisearchApiError: If the MeiliSearch API returned an error.
564+ MeilisearchApiError: If the Meilisearch API returned an error.
561565
562566 Examples:
563567
@@ -570,16 +574,16 @@ async def get_version(self) -> Version:
570574 return Version (** response .json ())
571575
572576 async def health (self ) -> Health :
573- """Get health of the MeiliSearch server.
577+ """Get health of the Meilisearch server.
574578
575579 Returns:
576580
577- The status of the MeiliSearch server.
581+ The status of the Meilisearch server.
578582
579583 Raises:
580584
581585 MeilisearchCommunicationError: If there was an error communicating with the server.
582- MeilisearchApiError: If the MeiliSearch API returned an error.
586+ MeilisearchApiError: If the Meilisearch API returned an error.
583587
584588 Examples:
585589
@@ -605,7 +609,7 @@ async def swap_indexes(self, indexes: list[tuple[str, str]]) -> TaskInfo:
605609 Raises:
606610
607611 MeilisearchCommunicationError: If there was an error communicating with the server.
608- MeilisearchApiError: If the MeiliSearch API returned an error.
612+ MeilisearchApiError: If the Meilisearch API returned an error.
609613
610614 Examples:
611615
0 commit comments