Skip to content

Commit fa30d8a

Browse files
chore: generated code for commit fe6f5eda. [skip ci]
algolia/api-clients-automation@fe6f5ed Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 574e5f3 commit fa30d8a

File tree

8 files changed

+1567
-474
lines changed

8 files changed

+1567
-474
lines changed

algoliasearch/ingestion/client.py

Lines changed: 1123 additions & 447 deletions
Large diffs are not rendered by default.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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 typing import Any, Dict, List, Self
11+
12+
from pydantic import BaseModel, ConfigDict
13+
14+
from algoliasearch.ingestion.models.pagination import Pagination
15+
from algoliasearch.ingestion.models.task_v1 import TaskV1
16+
17+
18+
class ListTasksResponseV1(BaseModel):
19+
"""
20+
Configured tasks and pagination information.
21+
"""
22+
23+
tasks: List[TaskV1]
24+
pagination: Pagination
25+
26+
model_config = ConfigDict(
27+
use_enum_values=True, populate_by_name=True, validate_assignment=True
28+
)
29+
30+
def to_json(self) -> str:
31+
return self.model_dump_json(by_alias=True, exclude_unset=True)
32+
33+
@classmethod
34+
def from_json(cls, json_str: str) -> Self:
35+
"""Create an instance of ListTasksResponseV1 from a JSON string"""
36+
return cls.from_dict(loads(json_str))
37+
38+
def to_dict(self) -> Dict[str, Any]:
39+
"""Return the dictionary representation of the model using alias.
40+
41+
This has the following differences from calling pydantic's
42+
`self.model_dump(by_alias=True)`:
43+
44+
* `None` is only added to the output dict for nullable fields that
45+
were set at model initialization. Other fields with value `None`
46+
are ignored.
47+
"""
48+
_dict = self.model_dump(
49+
by_alias=True,
50+
exclude={},
51+
exclude_none=True,
52+
)
53+
_items = []
54+
if self.tasks:
55+
for _item in self.tasks:
56+
if _item:
57+
_items.append(_item.to_dict())
58+
_dict["tasks"] = _items
59+
if self.pagination:
60+
_dict["pagination"] = self.pagination.to_dict()
61+
return _dict
62+
63+
@classmethod
64+
def from_dict(cls, obj: Dict) -> Self:
65+
"""Create an instance of ListTasksResponseV1 from a dict"""
66+
if obj is None:
67+
return None
68+
69+
if not isinstance(obj, dict):
70+
return cls.model_validate(obj)
71+
72+
_obj = cls.model_validate(
73+
{
74+
"tasks": (
75+
[TaskV1.from_dict(_item) for _item in obj.get("tasks")]
76+
if obj.get("tasks") is not None
77+
else None
78+
),
79+
"pagination": (
80+
Pagination.from_dict(obj.get("pagination"))
81+
if obj.get("pagination") is not None
82+
else None
83+
),
84+
}
85+
)
86+
return _obj

algoliasearch/ingestion/models/task.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
from algoliasearch.ingestion.models.action_type import ActionType
1515
from algoliasearch.ingestion.models.task_input import TaskInput
16-
from algoliasearch.ingestion.models.trigger import Trigger
1716

1817

1918
class Task(BaseModel):
@@ -32,7 +31,19 @@ class Task(BaseModel):
3231
description="Universally unique identifier (UUID) of a destination resource.",
3332
alias="destinationID",
3433
)
35-
trigger: Trigger
34+
cron: Optional[StrictStr] = Field(
35+
default=None, description="Cron expression for the task's schedule."
36+
)
37+
last_run: Optional[StrictStr] = Field(
38+
default=None,
39+
description="The last time the scheduled task ran in RFC 3339 format.",
40+
alias="lastRun",
41+
)
42+
next_run: Optional[StrictStr] = Field(
43+
default=None,
44+
description="The next scheduled run of the task in RFC 3339 format.",
45+
alias="nextRun",
46+
)
3647
input: Optional[TaskInput] = None
3748
enabled: StrictBool = Field(description="Whether the task is enabled.")
3849
failure_threshold: Optional[Annotated[int, Field(le=100, strict=True, ge=0)]] = (
@@ -82,8 +93,6 @@ def to_dict(self) -> Dict[str, Any]:
8293
exclude={},
8394
exclude_none=True,
8495
)
85-
if self.trigger:
86-
_dict["trigger"] = self.trigger.to_dict()
8796
if self.input:
8897
_dict["input"] = self.input.to_dict()
8998
return _dict
@@ -102,11 +111,9 @@ def from_dict(cls, obj: Dict) -> Self:
102111
"taskID": obj.get("taskID"),
103112
"sourceID": obj.get("sourceID"),
104113
"destinationID": obj.get("destinationID"),
105-
"trigger": (
106-
Trigger.from_dict(obj.get("trigger"))
107-
if obj.get("trigger") is not None
108-
else None
109-
),
114+
"cron": obj.get("cron"),
115+
"lastRun": obj.get("lastRun"),
116+
"nextRun": obj.get("nextRun"),
110117
"input": (
111118
TaskInput.from_dict(obj.get("input"))
112119
if obj.get("input") is not None

algoliasearch/ingestion/models/task_create.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
1313

1414
from algoliasearch.ingestion.models.action_type import ActionType
15-
from algoliasearch.ingestion.models.task_create_trigger import TaskCreateTrigger
1615
from algoliasearch.ingestion.models.task_input import TaskInput
1716

1817

@@ -29,8 +28,10 @@ class TaskCreate(BaseModel):
2928
description="Universally unique identifier (UUID) of a destination resource.",
3029
alias="destinationID",
3130
)
32-
trigger: TaskCreateTrigger
3331
action: ActionType
32+
cron: Optional[StrictStr] = Field(
33+
default=None, description="Cron expression for the task's schedule."
34+
)
3435
enabled: Optional[StrictBool] = Field(
3536
default=None, description="Whether the task is enabled."
3637
)
@@ -73,8 +74,6 @@ def to_dict(self) -> Dict[str, Any]:
7374
exclude={},
7475
exclude_none=True,
7576
)
76-
if self.trigger:
77-
_dict["trigger"] = self.trigger.to_dict()
7877
if self.input:
7978
_dict["input"] = self.input.to_dict()
8079
return _dict
@@ -92,12 +91,8 @@ def from_dict(cls, obj: Dict) -> Self:
9291
{
9392
"sourceID": obj.get("sourceID"),
9493
"destinationID": obj.get("destinationID"),
95-
"trigger": (
96-
TaskCreateTrigger.from_dict(obj.get("trigger"))
97-
if obj.get("trigger") is not None
98-
else None
99-
),
10094
"action": obj.get("action"),
95+
"cron": obj.get("cron"),
10196
"enabled": obj.get("enabled"),
10297
"failureThreshold": obj.get("failureThreshold"),
10398
"input": (
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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 typing import Annotated, Any, Dict, Optional, Self
11+
12+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
13+
14+
from algoliasearch.ingestion.models.action_type import ActionType
15+
from algoliasearch.ingestion.models.task_create_trigger import TaskCreateTrigger
16+
from algoliasearch.ingestion.models.task_input import TaskInput
17+
18+
19+
class TaskCreateV1(BaseModel):
20+
"""
21+
API request body for creating a task using the V1 shape, please use methods and types that don't contain the V1 suffix.
22+
"""
23+
24+
source_id: StrictStr = Field(
25+
description="Universally uniqud identifier (UUID) of a source.",
26+
alias="sourceID",
27+
)
28+
destination_id: StrictStr = Field(
29+
description="Universally unique identifier (UUID) of a destination resource.",
30+
alias="destinationID",
31+
)
32+
trigger: TaskCreateTrigger
33+
action: ActionType
34+
enabled: Optional[StrictBool] = Field(
35+
default=None, description="Whether the task is enabled."
36+
)
37+
failure_threshold: Optional[Annotated[int, Field(le=100, strict=True, ge=0)]] = (
38+
Field(
39+
default=None,
40+
description="Maximum accepted percentage of failures for a task run to finish successfully.",
41+
alias="failureThreshold",
42+
)
43+
)
44+
input: Optional[TaskInput] = None
45+
cursor: Optional[StrictStr] = Field(
46+
default=None, description="Date of the last cursor in RFC 3339 format."
47+
)
48+
49+
model_config = ConfigDict(
50+
use_enum_values=True, populate_by_name=True, validate_assignment=True
51+
)
52+
53+
def to_json(self) -> str:
54+
return self.model_dump_json(by_alias=True, exclude_unset=True)
55+
56+
@classmethod
57+
def from_json(cls, json_str: str) -> Self:
58+
"""Create an instance of TaskCreateV1 from a JSON string"""
59+
return cls.from_dict(loads(json_str))
60+
61+
def to_dict(self) -> Dict[str, Any]:
62+
"""Return the dictionary representation of the model using alias.
63+
64+
This has the following differences from calling pydantic's
65+
`self.model_dump(by_alias=True)`:
66+
67+
* `None` is only added to the output dict for nullable fields that
68+
were set at model initialization. Other fields with value `None`
69+
are ignored.
70+
"""
71+
_dict = self.model_dump(
72+
by_alias=True,
73+
exclude={},
74+
exclude_none=True,
75+
)
76+
if self.trigger:
77+
_dict["trigger"] = self.trigger.to_dict()
78+
if self.input:
79+
_dict["input"] = self.input.to_dict()
80+
return _dict
81+
82+
@classmethod
83+
def from_dict(cls, obj: Dict) -> Self:
84+
"""Create an instance of TaskCreateV1 from a dict"""
85+
if obj is None:
86+
return None
87+
88+
if not isinstance(obj, dict):
89+
return cls.model_validate(obj)
90+
91+
_obj = cls.model_validate(
92+
{
93+
"sourceID": obj.get("sourceID"),
94+
"destinationID": obj.get("destinationID"),
95+
"trigger": (
96+
TaskCreateTrigger.from_dict(obj.get("trigger"))
97+
if obj.get("trigger") is not None
98+
else None
99+
),
100+
"action": obj.get("action"),
101+
"enabled": obj.get("enabled"),
102+
"failureThreshold": obj.get("failureThreshold"),
103+
"input": (
104+
TaskInput.from_dict(obj.get("input"))
105+
if obj.get("input") is not None
106+
else None
107+
),
108+
"cursor": obj.get("cursor"),
109+
}
110+
)
111+
return _obj

algoliasearch/ingestion/models/task_update.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
1313

1414
from algoliasearch.ingestion.models.task_input import TaskInput
15-
from algoliasearch.ingestion.models.trigger_update_input import TriggerUpdateInput
1615

1716

1817
class TaskUpdate(BaseModel):
@@ -25,7 +24,9 @@ class TaskUpdate(BaseModel):
2524
description="Universally unique identifier (UUID) of a destination resource.",
2625
alias="destinationID",
2726
)
28-
trigger: Optional[TriggerUpdateInput] = None
27+
cron: Optional[StrictStr] = Field(
28+
default=None, description="Cron expression for the task's schedule."
29+
)
2930
input: Optional[TaskInput] = None
3031
enabled: Optional[StrictBool] = Field(
3132
default=None, description="Whether the task is enabled."
@@ -65,8 +66,6 @@ def to_dict(self) -> Dict[str, Any]:
6566
exclude={},
6667
exclude_none=True,
6768
)
68-
if self.trigger:
69-
_dict["trigger"] = self.trigger.to_dict()
7069
if self.input:
7170
_dict["input"] = self.input.to_dict()
7271
return _dict
@@ -83,11 +82,7 @@ def from_dict(cls, obj: Dict) -> Self:
8382
_obj = cls.model_validate(
8483
{
8584
"destinationID": obj.get("destinationID"),
86-
"trigger": (
87-
TriggerUpdateInput.from_dict(obj.get("trigger"))
88-
if obj.get("trigger") is not None
89-
else None
90-
),
85+
"cron": obj.get("cron"),
9186
"input": (
9287
TaskInput.from_dict(obj.get("input"))
9388
if obj.get("input") is not None

0 commit comments

Comments
 (0)