Skip to content

Commit 1a55358

Browse files
algolia-botFluf22millotp
committed
chore: generated code for commit a68907d1. [skip ci]
algolia/api-clients-automation@a68907d Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Thomas Raffray <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 78e1fdf commit 1a55358

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

algoliasearch/search/client.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ def _aggregator(_: GetTaskResponse) -> None:
254254

255255
async def wait_for_api_key(
256256
self,
257-
operation: str,
258257
key: str,
258+
operation: str,
259259
api_key: Optional[ApiKey] = None,
260260
max_retries: int = 50,
261261
timeout: RetryTimeout = RetryTimeout(),
262262
request_options: Optional[Union[dict, RequestOptions]] = None,
263-
) -> GetApiKeyResponse:
263+
) -> GetApiKeyResponse | None:
264264
"""
265265
Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
266266
"""
@@ -271,7 +271,7 @@ async def wait_for_api_key(
271271
"`apiKey` is required when waiting for an `update` operation."
272272
)
273273

274-
async def _func(_prev: GetApiKeyResponse) -> GetApiKeyResponse:
274+
async def _func(_prev: GetApiKeyResponse | None) -> GetApiKeyResponse | None:
275275
try:
276276
return await self.get_api_key(key=key, request_options=request_options)
277277
except RequestException as e:
@@ -281,20 +281,25 @@ async def _func(_prev: GetApiKeyResponse) -> GetApiKeyResponse:
281281
return None
282282
raise e
283283

284-
def _aggregator(_: GetApiKeyResponse) -> None:
284+
def _aggregator(_: GetApiKeyResponse | None) -> None:
285285
self._retry_count += 1
286286

287-
def _validate(_resp: GetApiKeyResponse) -> bool:
287+
def _validate(_resp: GetApiKeyResponse | None) -> bool:
288288
if operation == "update":
289-
for field in api_key:
290-
if isinstance(api_key[field], list) and isinstance(
291-
_resp[field], list
289+
resp_dict = _resp.to_dict()
290+
api_key_dict = (
291+
api_key.to_dict() if isinstance(api_key, ApiKey) else api_key
292+
)
293+
for field in api_key_dict:
294+
if isinstance(api_key_dict[field], list) and isinstance(
295+
resp_dict[field], list
292296
):
293-
if len(api_key[field]) != len(_resp[field]) or any(
294-
v != _resp[field][i] for i, v in enumerate(api_key[field])
297+
if len(api_key_dict[field]) != len(resp_dict[field]) or any(
298+
v != resp_dict[field][i]
299+
for i, v in enumerate(api_key_dict[field])
295300
):
296301
return False
297-
elif api_key[field] != _resp[field]:
302+
elif api_key_dict[field] != resp_dict[field]:
298303
return False
299304
return True
300305
elif operation == "add":

0 commit comments

Comments
 (0)