Skip to content

Commit 1be63d2

Browse files
algolia-botshortcutsmillotp
committed
fix(specs): ingestion push task payload [skip-bc] (generated)
algolia/api-clients-automation#3607 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 57d54bf commit 1be63d2

File tree

3 files changed

+55
-42
lines changed

3 files changed

+55
-42
lines changed

algoliasearch/ingestion/client.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from algoliasearch.ingestion.models.authentication_update_response import (
3535
AuthenticationUpdateResponse,
3636
)
37-
from algoliasearch.ingestion.models.batch_write_params import BatchWriteParams
3837
from algoliasearch.ingestion.models.delete_response import DeleteResponse
3938
from algoliasearch.ingestion.models.destination import Destination
4039
from algoliasearch.ingestion.models.destination_create import DestinationCreate
@@ -73,6 +72,7 @@
7372
)
7473
from algoliasearch.ingestion.models.order_keys import OrderKeys
7574
from algoliasearch.ingestion.models.platform_with_none import PlatformWithNone
75+
from algoliasearch.ingestion.models.push_task_payload import PushTaskPayload
7676
from algoliasearch.ingestion.models.run import Run
7777
from algoliasearch.ingestion.models.run_list_response import RunListResponse
7878
from algoliasearch.ingestion.models.run_response import RunResponse
@@ -3385,8 +3385,8 @@ async def push_task_with_http_info(
33853385
task_id: Annotated[
33863386
StrictStr, Field(description="Unique identifier of a task.")
33873387
],
3388-
batch_write_params: Annotated[
3389-
BatchWriteParams,
3388+
push_task_payload: Annotated[
3389+
PushTaskPayload,
33903390
Field(
33913391
description="Request body of a Search API `batch` request that will be pushed in the Connectors pipeline."
33923392
),
@@ -3403,8 +3403,8 @@ async def push_task_with_http_info(
34033403
34043404
:param task_id: Unique identifier of a task. (required)
34053405
:type task_id: str
3406-
:param batch_write_params: Request body of a Search API `batch` request that will be pushed in the Connectors pipeline. (required)
3407-
:type batch_write_params: BatchWriteParams
3406+
:param push_task_payload: Request body of a Search API `batch` request that will be pushed in the Connectors pipeline. (required)
3407+
:type push_task_payload: PushTaskPayload
34083408
:param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
34093409
:return: Returns the raw algoliasearch 'APIResponse' object.
34103410
"""
@@ -3414,14 +3414,14 @@ async def push_task_with_http_info(
34143414
"Parameter `task_id` is required when calling `push_task`."
34153415
)
34163416

3417-
if batch_write_params is None:
3417+
if push_task_payload is None:
34183418
raise ValueError(
3419-
"Parameter `batch_write_params` is required when calling `push_task`."
3419+
"Parameter `push_task_payload` is required when calling `push_task`."
34203420
)
34213421

34223422
_data = {}
3423-
if batch_write_params is not None:
3424-
_data = batch_write_params
3423+
if push_task_payload is not None:
3424+
_data = push_task_payload
34253425

34263426
return await self._transporter.request(
34273427
verb=Verb.POST,
@@ -3440,8 +3440,8 @@ async def push_task(
34403440
task_id: Annotated[
34413441
StrictStr, Field(description="Unique identifier of a task.")
34423442
],
3443-
batch_write_params: Annotated[
3444-
BatchWriteParams,
3443+
push_task_payload: Annotated[
3444+
PushTaskPayload,
34453445
Field(
34463446
description="Request body of a Search API `batch` request that will be pushed in the Connectors pipeline."
34473447
),
@@ -3458,14 +3458,14 @@ async def push_task(
34583458
34593459
:param task_id: Unique identifier of a task. (required)
34603460
:type task_id: str
3461-
:param batch_write_params: Request body of a Search API `batch` request that will be pushed in the Connectors pipeline. (required)
3462-
:type batch_write_params: BatchWriteParams
3461+
:param push_task_payload: Request body of a Search API `batch` request that will be pushed in the Connectors pipeline. (required)
3462+
:type push_task_payload: PushTaskPayload
34633463
:param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
34643464
:return: Returns the deserialized response in a 'RunResponse' result object.
34653465
"""
34663466
return (
34673467
await self.push_task_with_http_info(
3468-
task_id, batch_write_params, request_options
3468+
task_id, push_task_payload, request_options
34693469
)
34703470
).deserialize(RunResponse)
34713471

algoliasearch/ingestion/models/batch_write_params.py renamed to algoliasearch/ingestion/models/push_task_payload.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111

1212
from pydantic import BaseModel, ConfigDict
1313

14-
from algoliasearch.ingestion.models.batch_request import BatchRequest
14+
from algoliasearch.ingestion.models.action import Action
15+
from algoliasearch.ingestion.models.push_task_records import PushTaskRecords
1516

1617

17-
class BatchWriteParams(BaseModel):
18+
class PushTaskPayload(BaseModel):
1819
"""
19-
Batch parameters.
20+
PushTaskPayload
2021
"""
2122

22-
requests: List[BatchRequest]
23+
action: Action
24+
records: List[PushTaskRecords]
2325

2426
model_config = ConfigDict(
2527
use_enum_values=True, populate_by_name=True, validate_assignment=True
@@ -30,7 +32,7 @@ def to_json(self) -> str:
3032

3133
@classmethod
3234
def from_json(cls, json_str: str) -> Self:
33-
"""Create an instance of BatchWriteParams from a JSON string"""
35+
"""Create an instance of PushTaskPayload from a JSON string"""
3436
return cls.from_dict(loads(json_str))
3537

3638
def to_dict(self) -> Dict[str, Any]:
@@ -49,16 +51,16 @@ def to_dict(self) -> Dict[str, Any]:
4951
exclude_none=True,
5052
)
5153
_items = []
52-
if self.requests:
53-
for _item in self.requests:
54+
if self.records:
55+
for _item in self.records:
5456
if _item:
5557
_items.append(_item.to_dict())
56-
_dict["requests"] = _items
58+
_dict["records"] = _items
5759
return _dict
5860

5961
@classmethod
6062
def from_dict(cls, obj: Dict) -> Self:
61-
"""Create an instance of BatchWriteParams from a dict"""
63+
"""Create an instance of PushTaskPayload from a dict"""
6264
if obj is None:
6365
return None
6466

@@ -67,11 +69,12 @@ def from_dict(cls, obj: Dict) -> Self:
6769

6870
_obj = cls.model_validate(
6971
{
70-
"requests": (
71-
[BatchRequest.from_dict(_item) for _item in obj.get("requests")]
72-
if obj.get("requests") is not None
72+
"action": obj.get("action"),
73+
"records": (
74+
[PushTaskRecords.from_dict(_item) for _item in obj.get("records")]
75+
if obj.get("records") is not None
7376
else None
74-
)
77+
),
7578
}
7679
)
7780
return _obj

algoliasearch/ingestion/models/batch_request.py renamed to algoliasearch/ingestion/models/push_task_records.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@
77
from __future__ import annotations
88

99
from json import loads
10-
from typing import Any, Dict, Self
10+
from typing import Any, ClassVar, Dict, List, Self
1111

12-
from pydantic import BaseModel, ConfigDict, Field
12+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
1313

14-
from algoliasearch.ingestion.models.action import Action
1514

16-
17-
class BatchRequest(BaseModel):
15+
class PushTaskRecords(BaseModel):
1816
"""
19-
BatchRequest
17+
PushTaskRecords
2018
"""
2119

22-
action: Action
23-
body: Dict[str, Any] = Field(
24-
description="Operation arguments (varies with specified `action`)."
20+
object_id: StrictStr = Field(
21+
description="Unique record identifier.", alias="objectID"
2522
)
23+
additional_properties: Dict[str, Any] = {}
24+
__properties: ClassVar[List[str]] = ["objectID"]
2625

2726
model_config = ConfigDict(
2827
use_enum_values=True, populate_by_name=True, validate_assignment=True
@@ -33,7 +32,7 @@ def to_json(self) -> str:
3332

3433
@classmethod
3534
def from_json(cls, json_str: str) -> Self:
36-
"""Create an instance of BatchRequest from a JSON string"""
35+
"""Create an instance of PushTaskRecords from a JSON string"""
3736
return cls.from_dict(loads(json_str))
3837

3938
def to_dict(self) -> Dict[str, Any]:
@@ -45,24 +44,35 @@ def to_dict(self) -> Dict[str, Any]:
4544
* `None` is only added to the output dict for nullable fields that
4645
were set at model initialization. Other fields with value `None`
4746
are ignored.
47+
* Fields in `self.additional_properties` are added to the output dict.
4848
"""
4949
_dict = self.model_dump(
5050
by_alias=True,
51-
exclude={},
51+
exclude={
52+
"additional_properties",
53+
},
5254
exclude_none=True,
5355
)
56+
# puts key-value pairs in additional_properties in the top level
57+
if self.additional_properties is not None:
58+
for _key, _value in self.additional_properties.items():
59+
_dict[_key] = _value
60+
5461
return _dict
5562

5663
@classmethod
5764
def from_dict(cls, obj: Dict) -> Self:
58-
"""Create an instance of BatchRequest from a dict"""
65+
"""Create an instance of PushTaskRecords from a dict"""
5966
if obj is None:
6067
return None
6168

6269
if not isinstance(obj, dict):
6370
return cls.model_validate(obj)
6471

65-
_obj = cls.model_validate(
66-
{"action": obj.get("action"), "body": obj.get("body")}
67-
)
72+
_obj = cls.model_validate({"objectID": obj.get("objectID")})
73+
# store additional fields in additional_properties
74+
for _key in obj.keys():
75+
if _key not in cls.__properties:
76+
_obj.additional_properties[_key] = obj.get(_key)
77+
6878
return _obj

0 commit comments

Comments
 (0)