Skip to content

Commit 05ac319

Browse files
fix(clients): support dict in helpers (generated)
algolia/api-clients-automation#4254 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent b912b02 commit 05ac319

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

algoliasearch/search/client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ async def browse_objects(
354354
"""
355355
Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
356356
"""
357+
if isinstance(browse_params, dict):
358+
browse_params = BrowseParamsObject().from_dict(browse_params)
359+
357360
if browse_params is None:
358361
browse_params = BrowseParamsObject(hits_per_page=1000)
359362

@@ -385,6 +388,9 @@ async def browse_rules(
385388
"""
386389
Helper: Iterate on the `search_rules` method of the client to allow aggregating rules of an index.
387390
"""
391+
if isinstance(search_rules_params, dict):
392+
search_rules_params = SearchRulesParams().from_dict(search_rules_params)
393+
388394
if search_rules_params is None:
389395
search_rules_params = SearchRulesParams(hits_per_page=1000)
390396

@@ -418,6 +424,11 @@ async def browse_synonyms(
418424
"""
419425
Helper: Iterate on the `search_synonyms` method of the client to allow aggregating synonyms of an index.
420426
"""
427+
if isinstance(search_synonyms_params, dict):
428+
search_synonyms_params = SearchSynonymsParams().from_dict(
429+
search_synonyms_params
430+
)
431+
421432
if search_synonyms_params is None:
422433
search_synonyms_params = SearchSynonymsParams(hits_per_page=1000, page=0)
423434
hits_per_page = 1000
@@ -453,6 +464,7 @@ async def generate_secured_api_key(
453464
"""
454465
if restrictions is None:
455466
restrictions = SecuredApiKeyRestrictions()
467+
456468
restrictions_dict = {}
457469
if isinstance(restrictions, SecuredApiKeyRestrictions):
458470
restrictions_dict = restrictions.to_dict()
@@ -5384,6 +5396,9 @@ def browse_objects(
53845396
"""
53855397
Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
53865398
"""
5399+
if isinstance(browse_params, dict):
5400+
browse_params = BrowseParamsObject().from_dict(browse_params)
5401+
53875402
if browse_params is None:
53885403
browse_params = BrowseParamsObject(hits_per_page=1000)
53895404

@@ -5415,6 +5430,9 @@ def browse_rules(
54155430
"""
54165431
Helper: Iterate on the `search_rules` method of the client to allow aggregating rules of an index.
54175432
"""
5433+
if isinstance(search_rules_params, dict):
5434+
search_rules_params = SearchRulesParams().from_dict(search_rules_params)
5435+
54185436
if search_rules_params is None:
54195437
search_rules_params = SearchRulesParams(hits_per_page=1000)
54205438

@@ -5448,6 +5466,11 @@ def browse_synonyms(
54485466
"""
54495467
Helper: Iterate on the `search_synonyms` method of the client to allow aggregating synonyms of an index.
54505468
"""
5469+
if isinstance(search_synonyms_params, dict):
5470+
search_synonyms_params = SearchSynonymsParams().from_dict(
5471+
search_synonyms_params
5472+
)
5473+
54515474
if search_synonyms_params is None:
54525475
search_synonyms_params = SearchSynonymsParams(hits_per_page=1000, page=0)
54535476
hits_per_page = 1000
@@ -5481,6 +5504,7 @@ def generate_secured_api_key(
54815504
"""
54825505
if restrictions is None:
54835506
restrictions = SecuredApiKeyRestrictions()
5507+
54845508
restrictions_dict = {}
54855509
if isinstance(restrictions, SecuredApiKeyRestrictions):
54865510
restrictions_dict = restrictions.to_dict()

0 commit comments

Comments
 (0)