Skip to content

Commit f377640

Browse files
authored
feat(templates): add request_options to python helpers consistently (#3868)
1 parent eb59db0 commit f377640

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

templates/python/search_helpers.mustache

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
{{^isSyncClient}}async {{/isSyncClient}}def generate_secured_api_key(
195195
self,
196196
parent_api_key: str,
197-
restrictions: Optional[SecuredApiKeyRestrictions] = SecuredApiKeyRestrictions(),
197+
restrictions: Optional[Union[dict, SecuredApiKeyRestrictions]] = SecuredApiKeyRestrictions(),
198198
) -> str:
199199
"""
200200
Helper: Generates a secured API key based on the given `parent_api_key` and given `restrictions`.
@@ -244,32 +244,35 @@
244244
self,
245245
index_name: str,
246246
objects: List[Dict[str, Any]],
247+
request_options: Optional[Union[dict, RequestOptions]] = None,
247248
) -> List[BatchResponse]:
248249
"""
249250
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.
250251
"""
251-
return {{^isSyncClient}}await {{/isSyncClient}}self.chunked_batch(index_name=index_name, objects=objects, action=Action.ADDOBJECT)
252+
return {{^isSyncClient}}await {{/isSyncClient}}self.chunked_batch(index_name=index_name, objects=objects, action=Action.ADDOBJECT, request_options=request_options)
252253
253254
{{^isSyncClient}}async {{/isSyncClient}}def delete_objects(
254255
self,
255256
index_name: str,
256257
object_ids: List[str],
258+
request_options: Optional[Union[dict, RequestOptions]] = None,
257259
) -> List[BatchResponse]:
258260
"""
259261
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.
260262
"""
261-
return {{^isSyncClient}}await {{/isSyncClient}}self.chunked_batch(index_name=index_name, objects=[{"objectID": id} for id in object_ids], action=Action.DELETEOBJECT)
263+
return {{^isSyncClient}}await {{/isSyncClient}}self.chunked_batch(index_name=index_name, objects=[{"objectID": id} for id in object_ids], action=Action.DELETEOBJECT, request_options=request_options)
262264
263265
{{^isSyncClient}}async {{/isSyncClient}}def partial_update_objects(
264266
self,
265267
index_name: str,
266268
objects: List[Dict[str, Any]],
267269
create_if_not_exists: Optional[bool] = False,
270+
request_options: Optional[Union[dict, RequestOptions]] = None,
268271
) -> List[BatchResponse]:
269272
"""
270273
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.
271274
"""
272-
return {{^isSyncClient}}await {{/isSyncClient}}self.chunked_batch(index_name=index_name, objects=objects, action=Action.PARTIALUPDATEOBJECT if create_if_not_exists else Action.PARTIALUPDATEOBJECTNOCREATE)
275+
return {{^isSyncClient}}await {{/isSyncClient}}self.chunked_batch(index_name=index_name, objects=objects, action=Action.PARTIALUPDATEOBJECT if create_if_not_exists else Action.PARTIALUPDATEOBJECTNOCREATE, request_options=request_options)
273276
274277
{{^isSyncClient}}async {{/isSyncClient}}def chunked_batch(
275278
self,

0 commit comments

Comments
 (0)