Skip to content

Commit 36e1f8d

Browse files
committed
Add keys parameter in missing routes v0.28.x
1 parent cd973eb commit 36e1f8d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

.code-samples.meilisearch.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,14 +589,15 @@ authorization_header_1: |-
589589
client = Client('http://127.0.0.1:7700', 'masterKey')
590590
client.get_keys()
591591
tenant_token_guide_generate_sdk_1: |-
592+
uid = '85c3c2f9-bdd6-41f1-abd8-11fcf80e0f76';
592593
api_key = 'B5KdX2MY2jV6EXfUs6scSfmC...'
593594
expires_at = datetime(2025, 12, 20)
594595
search_rules = {
595596
'patient_medical_records': {
596597
'filter': 'user_id = 1'
597598
}
598599
}
599-
token = client.generate_tenant_token(search_rules=search_rules, api_key=api_key, expires_at=expires_at)
600+
token = client.generate_tenant_token(api_key_uid=uid, search_rules=search_rules, api_key=api_key, expires_at=expires_at)
600601
tenant_token_guide_search_sdk_1: |-
601602
front_end_client = Client('http://127.0.0.1:7700', token)
602603
front_end_client.index('patient_medical_records').search('blood test')

meilisearch/client.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import datetime
77
from urllib import parse
88
from typing import Any, Dict, List, Optional, Union
9-
from xmlrpc.client import Boolean
109
from meilisearch.index import Index
1110
from meilisearch.config import Config
1211
from meilisearch.task import get_task, get_tasks, wait_for_task
@@ -309,7 +308,7 @@ def create_key(
309308

310309
def update_key(
311310
self,
312-
key: str,
311+
key_or_uid: str,
313312
options: Dict[str, Any]
314313
) -> Dict[str, Any]:
315314
"""Update an API key.
@@ -318,7 +317,7 @@ def update_key(
318317
319318
----------
320319
key:
321-
The key for which to update the information.
320+
The key or the uid of the key for which to update the information.
322321
options:
323322
The information to use in creating the key (ex: { 'description': 'Search Key', 'expiresAt': '22-01-01' }). Note that if an
324323
expires_at value is included it should be in UTC time.
@@ -334,16 +333,16 @@ def update_key(
334333
MeiliSearchApiError
335334
An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors
336335
"""
337-
url = f'{self.config.paths.keys}/{key}'
336+
url = f'{self.config.paths.keys}/{key_or_uid}'
338337
return self.http.patch(url, options)
339338

340-
def delete_key(self, key: str) -> Dict[str, int]:
339+
def delete_key(self, key_or_uid: str) -> Dict[str, int]:
341340
"""Deletes an API key.
342341
343342
Parameters
344343
----------
345344
key:
346-
The key to delete.
345+
The key or the uid of the key to delete.
347346
348347
Returns
349348
-------
@@ -356,7 +355,7 @@ def delete_key(self, key: str) -> Dict[str, int]:
356355
MeiliSearchApiError
357356
An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors
358357
"""
359-
return self.http.delete(f'{self.config.paths.keys}/{key}')
358+
return self.http.delete(f'{self.config.paths.keys}/{key_or_uid}')
360359

361360
def get_version(self) -> Dict[str, str]:
362361
"""Get version Meilisearch

0 commit comments

Comments
 (0)