Skip to content

Commit 44a73d1

Browse files
feat(specs): add put task endpoint to ingestion api (generated)
algolia/api-clients-automation#5281 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent c3d3fc7 commit 44a73d1

File tree

4 files changed

+258
-5
lines changed

4 files changed

+258
-5
lines changed

algoliasearch/ingestion/client.py

Lines changed: 139 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
TaskCreate,
9191
TaskCreateResponse,
9292
TaskCreateV1,
93+
TaskReplace,
9394
TaskSearch,
9495
TaskSortKeys,
9596
TaskUpdate,
@@ -3848,6 +3849,74 @@ async def push_task(
38483849
)
38493850
return resp.deserialize(WatchResponse, resp.raw_data)
38503851

3852+
async def replace_task_with_http_info(
3853+
self,
3854+
task_id: Annotated[
3855+
StrictStr, Field(description="Unique identifier of a task.")
3856+
],
3857+
task_replace: Union[TaskReplace, dict[str, Any]],
3858+
request_options: Optional[Union[dict, RequestOptions]] = None,
3859+
) -> ApiResponse[str]:
3860+
"""
3861+
Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields.
3862+
3863+
3864+
:param task_id: Unique identifier of a task. (required)
3865+
:type task_id: str
3866+
:param task_replace: (required)
3867+
:type task_replace: TaskReplace
3868+
: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)
3869+
:return: Returns the raw algoliasearch 'APIResponse' object.
3870+
"""
3871+
3872+
if task_id is None:
3873+
raise ValueError(
3874+
"Parameter `task_id` is required when calling `replace_task`."
3875+
)
3876+
3877+
if task_replace is None:
3878+
raise ValueError(
3879+
"Parameter `task_replace` is required when calling `replace_task`."
3880+
)
3881+
3882+
_data = {}
3883+
if task_replace is not None:
3884+
_data = task_replace
3885+
3886+
return await self._transporter.request(
3887+
verb=Verb.PUT,
3888+
path="/2/tasks/{taskID}".replace("{taskID}", quote(str(task_id), safe="")),
3889+
request_options=self._request_options.merge(
3890+
data=dumps(body_serializer(_data)),
3891+
user_request_options=request_options,
3892+
),
3893+
use_read_transporter=False,
3894+
)
3895+
3896+
async def replace_task(
3897+
self,
3898+
task_id: Annotated[
3899+
StrictStr, Field(description="Unique identifier of a task.")
3900+
],
3901+
task_replace: Union[TaskReplace, dict[str, Any]],
3902+
request_options: Optional[Union[dict, RequestOptions]] = None,
3903+
) -> TaskUpdateResponse:
3904+
"""
3905+
Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields.
3906+
3907+
3908+
:param task_id: Unique identifier of a task. (required)
3909+
:type task_id: str
3910+
:param task_replace: (required)
3911+
:type task_replace: TaskReplace
3912+
: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)
3913+
:return: Returns the deserialized response in a 'TaskUpdateResponse' result object.
3914+
"""
3915+
resp = await self.replace_task_with_http_info(
3916+
task_id, task_replace, request_options
3917+
)
3918+
return resp.deserialize(TaskUpdateResponse, resp.raw_data)
3919+
38513920
async def run_source_with_http_info(
38523921
self,
38533922
source_id: Annotated[
@@ -4884,7 +4953,7 @@ async def update_task_with_http_info(
48844953
request_options: Optional[Union[dict, RequestOptions]] = None,
48854954
) -> ApiResponse[str]:
48864955
"""
4887-
Updates a task by its ID.
4956+
Partially updates a task by its ID.
48884957
48894958
48904959
:param task_id: Unique identifier of a task. (required)
@@ -4928,7 +4997,7 @@ async def update_task(
49284997
request_options: Optional[Union[dict, RequestOptions]] = None,
49294998
) -> TaskUpdateResponse:
49304999
"""
4931-
Updates a task by its ID.
5000+
Partially updates a task by its ID.
49325001
49335002
49345003
:param task_id: Unique identifier of a task. (required)
@@ -8956,6 +9025,72 @@ def push_task(
89569025
)
89579026
return resp.deserialize(WatchResponse, resp.raw_data)
89589027

9028+
def replace_task_with_http_info(
9029+
self,
9030+
task_id: Annotated[
9031+
StrictStr, Field(description="Unique identifier of a task.")
9032+
],
9033+
task_replace: Union[TaskReplace, dict[str, Any]],
9034+
request_options: Optional[Union[dict, RequestOptions]] = None,
9035+
) -> ApiResponse[str]:
9036+
"""
9037+
Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields.
9038+
9039+
9040+
:param task_id: Unique identifier of a task. (required)
9041+
:type task_id: str
9042+
:param task_replace: (required)
9043+
:type task_replace: TaskReplace
9044+
: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)
9045+
:return: Returns the raw algoliasearch 'APIResponse' object.
9046+
"""
9047+
9048+
if task_id is None:
9049+
raise ValueError(
9050+
"Parameter `task_id` is required when calling `replace_task`."
9051+
)
9052+
9053+
if task_replace is None:
9054+
raise ValueError(
9055+
"Parameter `task_replace` is required when calling `replace_task`."
9056+
)
9057+
9058+
_data = {}
9059+
if task_replace is not None:
9060+
_data = task_replace
9061+
9062+
return self._transporter.request(
9063+
verb=Verb.PUT,
9064+
path="/2/tasks/{taskID}".replace("{taskID}", quote(str(task_id), safe="")),
9065+
request_options=self._request_options.merge(
9066+
data=dumps(body_serializer(_data)),
9067+
user_request_options=request_options,
9068+
),
9069+
use_read_transporter=False,
9070+
)
9071+
9072+
def replace_task(
9073+
self,
9074+
task_id: Annotated[
9075+
StrictStr, Field(description="Unique identifier of a task.")
9076+
],
9077+
task_replace: Union[TaskReplace, dict[str, Any]],
9078+
request_options: Optional[Union[dict, RequestOptions]] = None,
9079+
) -> TaskUpdateResponse:
9080+
"""
9081+
Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields.
9082+
9083+
9084+
:param task_id: Unique identifier of a task. (required)
9085+
:type task_id: str
9086+
:param task_replace: (required)
9087+
:type task_replace: TaskReplace
9088+
: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)
9089+
:return: Returns the deserialized response in a 'TaskUpdateResponse' result object.
9090+
"""
9091+
resp = self.replace_task_with_http_info(task_id, task_replace, request_options)
9092+
return resp.deserialize(TaskUpdateResponse, resp.raw_data)
9093+
89599094
def run_source_with_http_info(
89609095
self,
89619096
source_id: Annotated[
@@ -9990,7 +10125,7 @@ def update_task_with_http_info(
999010125
request_options: Optional[Union[dict, RequestOptions]] = None,
999110126
) -> ApiResponse[str]:
999210127
"""
9993-
Updates a task by its ID.
10128+
Partially updates a task by its ID.
999410129
999510130
999610131
:param task_id: Unique identifier of a task. (required)
@@ -10034,7 +10169,7 @@ def update_task(
1003410169
request_options: Optional[Union[dict, RequestOptions]] = None,
1003510170
) -> TaskUpdateResponse:
1003610171
"""
10037-
Updates a task by its ID.
10172+
Partially updates a task by its ID.
1003810173
1003910174
1004010175
:param task_id: Unique identifier of a task. (required)

algoliasearch/ingestion/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
from .task_create_trigger import TaskCreateTrigger
133133
from .task_create_v1 import TaskCreateV1
134134
from .task_input import TaskInput
135+
from .task_replace import TaskReplace
135136
from .task_search import TaskSearch
136137
from .task_sort_keys import TaskSortKeys
137138
from .task_update import TaskUpdate
@@ -282,6 +283,7 @@
282283
"TaskCreateTrigger",
283284
"TaskCreateV1",
284285
"TaskInput",
286+
"TaskReplace",
285287
"TaskSearch",
286288
"TaskSortKeys",
287289
"TaskUpdate",
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# coding: utf-8
2+
3+
"""
4+
Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from json import loads
10+
from sys import version_info
11+
from typing import Any, Dict, Optional
12+
13+
from pydantic import BaseModel, ConfigDict
14+
15+
if version_info >= (3, 11):
16+
from typing import Self
17+
else:
18+
from typing_extensions import Self
19+
20+
21+
from algoliasearch.ingestion.models.action_type import ActionType
22+
from algoliasearch.ingestion.models.notifications import Notifications
23+
from algoliasearch.ingestion.models.policies import Policies
24+
from algoliasearch.ingestion.models.task_input import TaskInput
25+
26+
_ALIASES = {
27+
"destination_id": "destinationID",
28+
"action": "action",
29+
"subscription_action": "subscriptionAction",
30+
"cron": "cron",
31+
"enabled": "enabled",
32+
"failure_threshold": "failureThreshold",
33+
"input": "input",
34+
"cursor": "cursor",
35+
"notifications": "notifications",
36+
"policies": "policies",
37+
}
38+
39+
40+
def _alias_generator(name: str) -> str:
41+
return _ALIASES.get(name, name)
42+
43+
44+
class TaskReplace(BaseModel):
45+
"""
46+
API request body for updating a task.
47+
"""
48+
49+
destination_id: str
50+
""" Universally unique identifier (UUID) of a destination resource. """
51+
action: ActionType
52+
subscription_action: Optional[ActionType] = None
53+
cron: Optional[str] = None
54+
""" Cron expression for the task's schedule. """
55+
enabled: Optional[bool] = None
56+
""" Whether the task is enabled. """
57+
failure_threshold: Optional[int] = None
58+
""" Maximum accepted percentage of failures for a task run to finish successfully. """
59+
input: Optional[TaskInput] = None
60+
cursor: Optional[str] = None
61+
""" Date of the last cursor in RFC 3339 format. """
62+
notifications: Optional[Notifications] = None
63+
policies: Optional[Policies] = None
64+
65+
model_config = ConfigDict(
66+
strict=False,
67+
use_enum_values=True,
68+
populate_by_name=True,
69+
validate_assignment=True,
70+
protected_namespaces=(),
71+
alias_generator=_alias_generator,
72+
extra="allow",
73+
)
74+
75+
def to_json(self) -> str:
76+
return self.model_dump_json(by_alias=True, exclude_unset=True)
77+
78+
@classmethod
79+
def from_json(cls, json_str: str) -> Optional[Self]:
80+
"""Create an instance of TaskReplace from a JSON string"""
81+
return cls.from_dict(loads(json_str))
82+
83+
def to_dict(self) -> Dict[str, Any]:
84+
"""Return the dictionary representation of the model using alias."""
85+
return self.model_dump(
86+
by_alias=True,
87+
exclude_none=True,
88+
exclude_unset=True,
89+
)
90+
91+
@classmethod
92+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
93+
"""Create an instance of TaskReplace from a dict"""
94+
if obj is None:
95+
return None
96+
97+
if not isinstance(obj, dict):
98+
return cls.model_validate(obj)
99+
100+
obj["action"] = obj.get("action")
101+
obj["subscriptionAction"] = obj.get("subscriptionAction")
102+
obj["input"] = (
103+
TaskInput.from_dict(obj["input"]) if obj.get("input") is not None else None
104+
)
105+
obj["notifications"] = (
106+
Notifications.from_dict(obj["notifications"])
107+
if obj.get("notifications") is not None
108+
else None
109+
)
110+
obj["policies"] = (
111+
Policies.from_dict(obj["policies"])
112+
if obj.get("policies") is not None
113+
else None
114+
)
115+
116+
return cls.model_validate(obj)

algoliasearch/ingestion/models/task_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _alias_generator(name: str) -> str:
4141

4242
class TaskUpdate(BaseModel):
4343
"""
44-
API request body for updating a task.
44+
API request body for partially updating a task.
4545
"""
4646

4747
destination_id: Optional[str] = None

0 commit comments

Comments
 (0)