Skip to content

Commit 0b0fa26

Browse files
committed
feat(python): switch api key helper
1 parent 567da8e commit 0b0fa26

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

clients/algoliasearch-client-python/algoliasearch/http/transporter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def __enter__(self) -> None:
4848
def __exit__(self, exc_type, exc_value, traceback) -> None:
4949
pass
5050

51+
def set_api_key(self, api_key: str) -> None:
52+
"""Sets a new API key to authenticate requests."""
53+
self._config.api_key = api_key
54+
5155
def prepare(
5256
self,
5357
request_options: RequestOptions,

templates/python/api.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ class {{classname}}:
8080
async def close(self) -> None:
8181
"""Closes the underlying `transporter` of the API client."""
8282
return await self._transporter.close()
83+
84+
def set_api_key(self, api_key: str) -> None:
85+
"""Sets a new API key to authenticate requests."""
86+
self._transporter.set_api_key(api_key)
8387

8488
{{#isSearchClient}}
8589
{{> search_helpers}}

0 commit comments

Comments
 (0)