Skip to content

Commit d9e88c1

Browse files
algolia-botFluf22millotp
committed
feat(clients): helper to switch API key in use (generated)
algolia/api-clients-automation#3616 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Thomas Raffray <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 2fe4e5d commit d9e88c1

File tree

11 files changed

+45
-0
lines changed

11 files changed

+45
-0
lines changed

algoliasearch/abtesting/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ async def close(self) -> None:
116116
"""Closes the underlying `transporter` of the API client."""
117117
return await self._transporter.close()
118118

119+
def set_client_api_key(self, api_key: str) -> None:
120+
"""Sets a new API key to authenticate requests."""
121+
self._transporter._config.set_client_api_key(api_key)
122+
119123
async def add_ab_tests_with_http_info(
120124
self,
121125
add_ab_tests_request: AddABTestsRequest,

algoliasearch/analytics/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ async def close(self) -> None:
162162
"""Closes the underlying `transporter` of the API client."""
163163
return await self._transporter.close()
164164

165+
def set_client_api_key(self, api_key: str) -> None:
166+
"""Sets a new API key to authenticate requests."""
167+
self._transporter._config.set_client_api_key(api_key)
168+
165169
async def custom_delete_with_http_info(
166170
self,
167171
path: Annotated[

algoliasearch/http/base_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@ def __init__(self, app_id: Optional[str] = None, api_key: Optional[str] = None):
4040
self.headers = None
4141
self.proxies = None
4242
self.hosts = None
43+
44+
def set_client_api_key(self, api_key: str) -> None:
45+
"""Sets a new API key to authenticate requests."""
46+
self.api_key = api_key
47+
self.headers["x-algolia-api-key"] = api_key

algoliasearch/ingestion/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ async def close(self) -> None:
204204
"""Closes the underlying `transporter` of the API client."""
205205
return await self._transporter.close()
206206

207+
def set_client_api_key(self, api_key: str) -> None:
208+
"""Sets a new API key to authenticate requests."""
209+
self._transporter._config.set_client_api_key(api_key)
210+
207211
async def create_authentication_with_http_info(
208212
self,
209213
authentication_create: AuthenticationCreate,

algoliasearch/insights/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ async def close(self) -> None:
108108
"""Closes the underlying `transporter` of the API client."""
109109
return await self._transporter.close()
110110

111+
def set_client_api_key(self, api_key: str) -> None:
112+
"""Sets a new API key to authenticate requests."""
113+
self._transporter._config.set_client_api_key(api_key)
114+
111115
async def custom_delete_with_http_info(
112116
self,
113117
path: Annotated[

algoliasearch/monitoring/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ async def close(self) -> None:
114114
"""Closes the underlying `transporter` of the API client."""
115115
return await self._transporter.close()
116116

117+
def set_client_api_key(self, api_key: str) -> None:
118+
"""Sets a new API key to authenticate requests."""
119+
self._transporter._config.set_client_api_key(api_key)
120+
117121
async def custom_delete_with_http_info(
118122
self,
119123
path: Annotated[

algoliasearch/personalization/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ async def close(self) -> None:
118118
"""Closes the underlying `transporter` of the API client."""
119119
return await self._transporter.close()
120120

121+
def set_client_api_key(self, api_key: str) -> None:
122+
"""Sets a new API key to authenticate requests."""
123+
self._transporter._config.set_client_api_key(api_key)
124+
121125
async def custom_delete_with_http_info(
122126
self,
123127
path: Annotated[

algoliasearch/query_suggestions/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ async def close(self) -> None:
116116
"""Closes the underlying `transporter` of the API client."""
117117
return await self._transporter.close()
118118

119+
def set_client_api_key(self, api_key: str) -> None:
120+
"""Sets a new API key to authenticate requests."""
121+
self._transporter._config.set_client_api_key(api_key)
122+
119123
async def create_config_with_http_info(
120124
self,
121125
configuration_with_index: ConfigurationWithIndex,

algoliasearch/recommend/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ async def close(self) -> None:
122122
"""Closes the underlying `transporter` of the API client."""
123123
return await self._transporter.close()
124124

125+
def set_client_api_key(self, api_key: str) -> None:
126+
"""Sets a new API key to authenticate requests."""
127+
self._transporter._config.set_client_api_key(api_key)
128+
125129
async def custom_delete_with_http_info(
126130
self,
127131
path: Annotated[

algoliasearch/search/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ async def close(self) -> None:
203203
"""Closes the underlying `transporter` of the API client."""
204204
return await self._transporter.close()
205205

206+
def set_client_api_key(self, api_key: str) -> None:
207+
"""Sets a new API key to authenticate requests."""
208+
self._transporter._config.set_client_api_key(api_key)
209+
206210
async def wait_for_task(
207211
self,
208212
index_name: str,

algoliasearch/usage/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ async def close(self) -> None:
107107
"""Closes the underlying `transporter` of the API client."""
108108
return await self._transporter.close()
109109

110+
def set_client_api_key(self, api_key: str) -> None:
111+
"""Sets a new API key to authenticate requests."""
112+
self._transporter._config.set_client_api_key(api_key)
113+
110114
async def custom_delete_with_http_info(
111115
self,
112116
path: Annotated[

0 commit comments

Comments
 (0)