Skip to content

Add keys parameter in missing routes v0.28.x #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,15 @@ authorization_header_1: |-
client = Client('http://127.0.0.1:7700', 'masterKey')
client.get_keys()
tenant_token_guide_generate_sdk_1: |-
uid = '85c3c2f9-bdd6-41f1-abd8-11fcf80e0f76';
api_key = 'B5KdX2MY2jV6EXfUs6scSfmC...'
expires_at = datetime(2025, 12, 20)
search_rules = {
'patient_medical_records': {
'filter': 'user_id = 1'
}
}
token = client.generate_tenant_token(search_rules=search_rules, api_key=api_key, expires_at=expires_at)
token = client.generate_tenant_token(api_key_uid=uid, search_rules=search_rules, api_key=api_key, expires_at=expires_at)
tenant_token_guide_search_sdk_1: |-
front_end_client = Client('http://127.0.0.1:7700', token)
front_end_client.index('patient_medical_records').search('blood test')
13 changes: 6 additions & 7 deletions meilisearch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import datetime
from urllib import parse
from typing import Any, Dict, List, Optional, Union
from xmlrpc.client import Boolean
from meilisearch.index import Index
from meilisearch.config import Config
from meilisearch.task import get_task, get_tasks, wait_for_task
Expand Down Expand Up @@ -309,7 +308,7 @@ def create_key(

def update_key(
self,
key: str,
key_or_uid: str,
options: Dict[str, Any]
) -> Dict[str, Any]:
"""Update an API key.
Expand All @@ -318,7 +317,7 @@ def update_key(

----------
key:
The key for which to update the information.
The key or the uid of the key for which to update the information.
options:
The information to use in creating the key (ex: { 'description': 'Search Key', 'expiresAt': '22-01-01' }). Note that if an
expires_at value is included it should be in UTC time.
Expand All @@ -334,16 +333,16 @@ def update_key(
MeiliSearchApiError
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
"""
url = f'{self.config.paths.keys}/{key}'
url = f'{self.config.paths.keys}/{key_or_uid}'
return self.http.patch(url, options)

def delete_key(self, key: str) -> Dict[str, int]:
def delete_key(self, key_or_uid: str) -> Dict[str, int]:
"""Deletes an API key.

Parameters
----------
key:
The key to delete.
The key or the uid of the key to delete.

Returns
-------
Expand All @@ -356,7 +355,7 @@ def delete_key(self, key: str) -> Dict[str, int]:
MeiliSearchApiError
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
"""
return self.http.delete(f'{self.config.paths.keys}/{key}')
return self.http.delete(f'{self.config.paths.keys}/{key_or_uid}')

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