Skip to content

Commit aa1fffc

Browse files
algolia-botkai687
andcommitted
feat(templates): add request_options to python helpers consistently (generated)
algolia/api-clients-automation#3868 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Kai Welke <[email protected]>
1 parent 57069aa commit aa1fffc

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

algoliasearch/search/client.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,9 @@ async def _func(_prev: SearchRulesResponse) -> SearchRulesResponse:
420420
async def generate_secured_api_key(
421421
self,
422422
parent_api_key: str,
423-
restrictions: Optional[SecuredApiKeyRestrictions] = SecuredApiKeyRestrictions(),
423+
restrictions: Optional[
424+
Union[dict, SecuredApiKeyRestrictions]
425+
] = SecuredApiKeyRestrictions(),
424426
) -> str:
425427
"""
426428
Helper: Generates a secured API key based on the given `parent_api_key` and given `restrictions`.
@@ -470,18 +472,23 @@ async def save_objects(
470472
self,
471473
index_name: str,
472474
objects: List[Dict[str, Any]],
475+
request_options: Optional[Union[dict, RequestOptions]] = None,
473476
) -> List[BatchResponse]:
474477
"""
475478
Helper: Saves the given array of objects in the given index. The `chunked_batch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
476479
"""
477480
return await self.chunked_batch(
478-
index_name=index_name, objects=objects, action=Action.ADDOBJECT
481+
index_name=index_name,
482+
objects=objects,
483+
action=Action.ADDOBJECT,
484+
request_options=request_options,
479485
)
480486

481487
async def delete_objects(
482488
self,
483489
index_name: str,
484490
object_ids: List[str],
491+
request_options: Optional[Union[dict, RequestOptions]] = None,
485492
) -> List[BatchResponse]:
486493
"""
487494
Helper: Deletes every records for the given objectIDs. The `chunked_batch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
@@ -490,13 +497,15 @@ async def delete_objects(
490497
index_name=index_name,
491498
objects=[{"objectID": id} for id in object_ids],
492499
action=Action.DELETEOBJECT,
500+
request_options=request_options,
493501
)
494502

495503
async def partial_update_objects(
496504
self,
497505
index_name: str,
498506
objects: List[Dict[str, Any]],
499507
create_if_not_exists: Optional[bool] = False,
508+
request_options: Optional[Union[dict, RequestOptions]] = None,
500509
) -> List[BatchResponse]:
501510
"""
502511
Helper: Replaces object content of all the given objects according to their respective `objectID` field. The `chunked_batch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
@@ -507,6 +516,7 @@ async def partial_update_objects(
507516
action=Action.PARTIALUPDATEOBJECT
508517
if create_if_not_exists
509518
else Action.PARTIALUPDATEOBJECTNOCREATE,
519+
request_options=request_options,
510520
)
511521

512522
async def chunked_batch(
@@ -5346,7 +5356,9 @@ def _func(_prev: SearchRulesResponse) -> SearchRulesResponse:
53465356
def generate_secured_api_key(
53475357
self,
53485358
parent_api_key: str,
5349-
restrictions: Optional[SecuredApiKeyRestrictions] = SecuredApiKeyRestrictions(),
5359+
restrictions: Optional[
5360+
Union[dict, SecuredApiKeyRestrictions]
5361+
] = SecuredApiKeyRestrictions(),
53505362
) -> str:
53515363
"""
53525364
Helper: Generates a secured API key based on the given `parent_api_key` and given `restrictions`.
@@ -5396,18 +5408,23 @@ def save_objects(
53965408
self,
53975409
index_name: str,
53985410
objects: List[Dict[str, Any]],
5411+
request_options: Optional[Union[dict, RequestOptions]] = None,
53995412
) -> List[BatchResponse]:
54005413
"""
54015414
Helper: Saves the given array of objects in the given index. The `chunked_batch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
54025415
"""
54035416
return self.chunked_batch(
5404-
index_name=index_name, objects=objects, action=Action.ADDOBJECT
5417+
index_name=index_name,
5418+
objects=objects,
5419+
action=Action.ADDOBJECT,
5420+
request_options=request_options,
54055421
)
54065422

54075423
def delete_objects(
54085424
self,
54095425
index_name: str,
54105426
object_ids: List[str],
5427+
request_options: Optional[Union[dict, RequestOptions]] = None,
54115428
) -> List[BatchResponse]:
54125429
"""
54135430
Helper: Deletes every records for the given objectIDs. The `chunked_batch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
@@ -5416,13 +5433,15 @@ def delete_objects(
54165433
index_name=index_name,
54175434
objects=[{"objectID": id} for id in object_ids],
54185435
action=Action.DELETEOBJECT,
5436+
request_options=request_options,
54195437
)
54205438

54215439
def partial_update_objects(
54225440
self,
54235441
index_name: str,
54245442
objects: List[Dict[str, Any]],
54255443
create_if_not_exists: Optional[bool] = False,
5444+
request_options: Optional[Union[dict, RequestOptions]] = None,
54265445
) -> List[BatchResponse]:
54275446
"""
54285447
Helper: Replaces object content of all the given objects according to their respective `objectID` field. The `chunked_batch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
@@ -5433,6 +5452,7 @@ def partial_update_objects(
54335452
action=Action.PARTIALUPDATEOBJECT
54345453
if create_if_not_exists
54355454
else Action.PARTIALUPDATEOBJECTNOCREATE,
5455+
request_options=request_options,
54365456
)
54375457

54385458
def chunked_batch(

0 commit comments

Comments
 (0)