|
41 | 41 | from algoliasearch.http.verb import Verb
|
42 | 42 | from algoliasearch.ingestion.client import IngestionClient, IngestionClientSync
|
43 | 43 | from algoliasearch.ingestion.config import IngestionConfig
|
| 44 | +from algoliasearch.ingestion.models import Action as IngestionAction |
44 | 45 | from algoliasearch.ingestion.models import WatchResponse
|
45 | 46 | from algoliasearch.search.config import SearchConfig
|
46 | 47 | from algoliasearch.search.models import (
|
@@ -291,7 +292,7 @@ async def wait_for_api_key(
|
291 | 292 | "`apiKey` is required when waiting for an `update` operation."
|
292 | 293 | )
|
293 | 294 |
|
294 |
| - async def _func(_prev: Optional[GetApiKeyResponse]) -> GetApiKeyResponse: |
| 295 | + async def _func(_: Optional[GetApiKeyResponse]) -> GetApiKeyResponse: |
295 | 296 | try:
|
296 | 297 | return await self.get_api_key(key=key, request_options=request_options)
|
297 | 298 | except RequestException as e:
|
@@ -431,9 +432,7 @@ async def browse_synonyms(
|
431 | 432 | page = search_synonyms_params.page or 0
|
432 | 433 | search_synonyms_params.hits_per_page = hits_per_page
|
433 | 434 |
|
434 |
| - async def _func( |
435 |
| - _prev: Optional[SearchSynonymsResponse], |
436 |
| - ) -> SearchSynonymsResponse: |
| 435 | + async def _func(_: Optional[SearchSynonymsResponse]) -> SearchSynonymsResponse: |
437 | 436 | nonlocal page
|
438 | 437 | resp = await self.search_synonyms(
|
439 | 438 | index_name=index_name,
|
@@ -534,22 +533,20 @@ async def save_objects_with_transformation(
|
534 | 533 | wait_for_tasks: bool = False,
|
535 | 534 | batch_size: int = 1000,
|
536 | 535 | request_options: Optional[Union[dict, RequestOptions]] = None,
|
537 |
| - ) -> WatchResponse: |
| 536 | + ) -> List[WatchResponse]: |
538 | 537 | """
|
539 | 538 | Helper: Similar to the `save_objects` method but requires a Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) to be created first, in order to transform records before indexing them to Algolia. The `region` must've been passed to the client's config at instantiation.
|
540 | 539 | """
|
541 | 540 | if self._ingestion_transporter is None:
|
542 | 541 | raise ValueError(
|
543 | 542 | "`region` must be provided at client instantiation before calling this method."
|
544 | 543 | )
|
545 |
| - |
546 |
| - return await self._ingestion_transporter.push( |
| 544 | + return await self._ingestion_transporter.chunked_push( |
547 | 545 | index_name=index_name,
|
548 |
| - push_task_payload={ |
549 |
| - "action": Action.ADDOBJECT, |
550 |
| - "records": objects, |
551 |
| - }, |
552 |
| - watch=wait_for_tasks, |
| 546 | + objects=objects, |
| 547 | + action=IngestionAction.ADDOBJECT, |
| 548 | + wait_for_tasks=wait_for_tasks, |
| 549 | + batch_size=batch_size, |
553 | 550 | request_options=request_options,
|
554 | 551 | )
|
555 | 552 |
|
@@ -604,24 +601,22 @@ async def partial_update_objects_with_transformation(
|
604 | 601 | wait_for_tasks: bool = False,
|
605 | 602 | batch_size: int = 1000,
|
606 | 603 | request_options: Optional[Union[dict, RequestOptions]] = None,
|
607 |
| - ) -> WatchResponse: |
| 604 | + ) -> List[WatchResponse]: |
608 | 605 | """
|
609 | 606 | Helper: Similar to the `partial_update_objects` method but requires a Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) to be created first, in order to transform records before indexing them to Algolia. The `region` must've been passed to the client instantiation method.
|
610 | 607 | """
|
611 | 608 | if self._ingestion_transporter is None:
|
612 | 609 | raise ValueError(
|
613 | 610 | "`region` must be provided at client instantiation before calling this method."
|
614 | 611 | )
|
615 |
| - |
616 |
| - return await self._ingestion_transporter.push( |
| 612 | + return await self._ingestion_transporter.chunked_push( |
617 | 613 | index_name=index_name,
|
618 |
| - push_task_payload={ |
619 |
| - "action": Action.PARTIALUPDATEOBJECT |
620 |
| - if create_if_not_exists |
621 |
| - else Action.PARTIALUPDATEOBJECTNOCREATE, |
622 |
| - "records": objects, |
623 |
| - }, |
624 |
| - watch=wait_for_tasks, |
| 614 | + objects=objects, |
| 615 | + action=IngestionAction.PARTIALUPDATEOBJECT |
| 616 | + if create_if_not_exists |
| 617 | + else IngestionAction.PARTIALUPDATEOBJECTNOCREATE, |
| 618 | + wait_for_tasks=wait_for_tasks, |
| 619 | + batch_size=batch_size, |
625 | 620 | request_options=request_options,
|
626 | 621 | )
|
627 | 622 |
|
@@ -5426,7 +5421,7 @@ def wait_for_api_key(
|
5426 | 5421 | "`apiKey` is required when waiting for an `update` operation."
|
5427 | 5422 | )
|
5428 | 5423 |
|
5429 |
| - def _func(_prev: Optional[GetApiKeyResponse]) -> GetApiKeyResponse: |
| 5424 | + def _func(_: Optional[GetApiKeyResponse]) -> GetApiKeyResponse: |
5430 | 5425 | try:
|
5431 | 5426 | return self.get_api_key(key=key, request_options=request_options)
|
5432 | 5427 | except RequestException as e:
|
@@ -5566,7 +5561,7 @@ def browse_synonyms(
|
5566 | 5561 | page = search_synonyms_params.page or 0
|
5567 | 5562 | search_synonyms_params.hits_per_page = hits_per_page
|
5568 | 5563 |
|
5569 |
| - def _func(_prev: Optional[SearchSynonymsResponse]) -> SearchSynonymsResponse: |
| 5564 | + def _func(_: Optional[SearchSynonymsResponse]) -> SearchSynonymsResponse: |
5570 | 5565 | nonlocal page
|
5571 | 5566 | resp = self.search_synonyms(
|
5572 | 5567 | index_name=index_name,
|
@@ -5667,22 +5662,20 @@ def save_objects_with_transformation(
|
5667 | 5662 | wait_for_tasks: bool = False,
|
5668 | 5663 | batch_size: int = 1000,
|
5669 | 5664 | request_options: Optional[Union[dict, RequestOptions]] = None,
|
5670 |
| - ) -> WatchResponse: |
| 5665 | + ) -> List[WatchResponse]: |
5671 | 5666 | """
|
5672 | 5667 | Helper: Similar to the `save_objects` method but requires a Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) to be created first, in order to transform records before indexing them to Algolia. The `region` must've been passed to the client's config at instantiation.
|
5673 | 5668 | """
|
5674 | 5669 | if self._ingestion_transporter is None:
|
5675 | 5670 | raise ValueError(
|
5676 | 5671 | "`region` must be provided at client instantiation before calling this method."
|
5677 | 5672 | )
|
5678 |
| - |
5679 |
| - return self._ingestion_transporter.push( |
| 5673 | + return self._ingestion_transporter.chunked_push( |
5680 | 5674 | index_name=index_name,
|
5681 |
| - push_task_payload={ |
5682 |
| - "action": Action.ADDOBJECT, |
5683 |
| - "records": objects, |
5684 |
| - }, |
5685 |
| - watch=wait_for_tasks, |
| 5675 | + objects=objects, |
| 5676 | + action=IngestionAction.ADDOBJECT, |
| 5677 | + wait_for_tasks=wait_for_tasks, |
| 5678 | + batch_size=batch_size, |
5686 | 5679 | request_options=request_options,
|
5687 | 5680 | )
|
5688 | 5681 |
|
@@ -5737,24 +5730,22 @@ def partial_update_objects_with_transformation(
|
5737 | 5730 | wait_for_tasks: bool = False,
|
5738 | 5731 | batch_size: int = 1000,
|
5739 | 5732 | request_options: Optional[Union[dict, RequestOptions]] = None,
|
5740 |
| - ) -> WatchResponse: |
| 5733 | + ) -> List[WatchResponse]: |
5741 | 5734 | """
|
5742 | 5735 | Helper: Similar to the `partial_update_objects` method but requires a Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) to be created first, in order to transform records before indexing them to Algolia. The `region` must've been passed to the client instantiation method.
|
5743 | 5736 | """
|
5744 | 5737 | if self._ingestion_transporter is None:
|
5745 | 5738 | raise ValueError(
|
5746 | 5739 | "`region` must be provided at client instantiation before calling this method."
|
5747 | 5740 | )
|
5748 |
| - |
5749 |
| - return self._ingestion_transporter.push( |
| 5741 | + return self._ingestion_transporter.chunked_push( |
5750 | 5742 | index_name=index_name,
|
5751 |
| - push_task_payload={ |
5752 |
| - "action": Action.PARTIALUPDATEOBJECT |
5753 |
| - if create_if_not_exists |
5754 |
| - else Action.PARTIALUPDATEOBJECTNOCREATE, |
5755 |
| - "records": objects, |
5756 |
| - }, |
5757 |
| - watch=wait_for_tasks, |
| 5743 | + objects=objects, |
| 5744 | + action=IngestionAction.PARTIALUPDATEOBJECT |
| 5745 | + if create_if_not_exists |
| 5746 | + else IngestionAction.PARTIALUPDATEOBJECTNOCREATE, |
| 5747 | + wait_for_tasks=wait_for_tasks, |
| 5748 | + batch_size=batch_size, |
5758 | 5749 | request_options=request_options,
|
5759 | 5750 | )
|
5760 | 5751 |
|
|
0 commit comments