Skip to content

Commit 036cb1c

Browse files
algolia-botmillotp
andcommitted
feat(specs): add runSource endpoint (generated)
algolia/api-clients-automation#3453 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 74a1600 commit 036cb1c

File tree

4 files changed

+259
-0
lines changed

4 files changed

+259
-0
lines changed

algoliasearch/ingestion/client.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
from algoliasearch.ingestion.models.run_list_response import RunListResponse
7272
from algoliasearch.ingestion.models.run_response import RunResponse
7373
from algoliasearch.ingestion.models.run_sort_keys import RunSortKeys
74+
from algoliasearch.ingestion.models.run_source_payload import RunSourcePayload
75+
from algoliasearch.ingestion.models.run_source_response import RunSourceResponse
7476
from algoliasearch.ingestion.models.run_status import RunStatus
7577
from algoliasearch.ingestion.models.sort_keys import SortKeys
7678
from algoliasearch.ingestion.models.source import Source
@@ -3310,6 +3312,80 @@ async def push_task(
33103312
)
33113313
).deserialize(RunResponse)
33123314

3315+
async def run_source_with_http_info(
3316+
self,
3317+
source_id: Annotated[
3318+
StrictStr, Field(description="Unique identifier of a source.")
3319+
],
3320+
run_source_payload: Optional[RunSourcePayload] = None,
3321+
request_options: Optional[Union[dict, RequestOptions]] = None,
3322+
) -> ApiResponse[str]:
3323+
"""
3324+
Runs all tasks linked to a source, only available for Shopify sources. It will create 1 run per task.
3325+
3326+
Required API Key ACLs:
3327+
- addObject
3328+
- deleteIndex
3329+
- editSettings
3330+
3331+
:param source_id: Unique identifier of a source. (required)
3332+
:type source_id: str
3333+
:param run_source_payload:
3334+
:type run_source_payload: RunSourcePayload
3335+
: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)
3336+
:return: Returns the raw algoliasearch 'APIResponse' object.
3337+
"""
3338+
3339+
if source_id is None:
3340+
raise ValueError(
3341+
"Parameter `source_id` is required when calling `run_source`."
3342+
)
3343+
3344+
_data = {}
3345+
if run_source_payload is not None:
3346+
_data = run_source_payload
3347+
3348+
return await self._transporter.request(
3349+
verb=Verb.POST,
3350+
path="/1/sources/{sourceID}/run".replace(
3351+
"{sourceID}", quote(str(source_id), safe="")
3352+
),
3353+
request_options=self._request_options.merge(
3354+
data=dumps(bodySerializer(_data)),
3355+
user_request_options=request_options,
3356+
),
3357+
use_read_transporter=False,
3358+
)
3359+
3360+
async def run_source(
3361+
self,
3362+
source_id: Annotated[
3363+
StrictStr, Field(description="Unique identifier of a source.")
3364+
],
3365+
run_source_payload: Optional[RunSourcePayload] = None,
3366+
request_options: Optional[Union[dict, RequestOptions]] = None,
3367+
) -> RunSourceResponse:
3368+
"""
3369+
Runs all tasks linked to a source, only available for Shopify sources. It will create 1 run per task.
3370+
3371+
Required API Key ACLs:
3372+
- addObject
3373+
- deleteIndex
3374+
- editSettings
3375+
3376+
:param source_id: Unique identifier of a source. (required)
3377+
:type source_id: str
3378+
:param run_source_payload:
3379+
:type run_source_payload: RunSourcePayload
3380+
: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)
3381+
:return: Returns the deserialized response in a 'RunSourceResponse' result object.
3382+
"""
3383+
return (
3384+
await self.run_source_with_http_info(
3385+
source_id, run_source_payload, request_options
3386+
)
3387+
).deserialize(RunSourceResponse)
3388+
33133389
async def run_task_with_http_info(
33143390
self,
33153391
task_id: Annotated[
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 enum import Enum
10+
from json import loads
11+
from typing import Self
12+
13+
14+
class EntityType(str, Enum):
15+
"""
16+
Type of entity to update.
17+
"""
18+
19+
"""
20+
allowed enum values
21+
"""
22+
PRODUCT = "product"
23+
COLLECTION = "collection"
24+
25+
@classmethod
26+
def from_json(cls, json_str: str) -> Self:
27+
"""Create an instance of EntityType from a JSON string"""
28+
return cls(loads(json_str))
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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, Optional, Self
11+
12+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
13+
14+
from algoliasearch.ingestion.models.entity_type import EntityType
15+
16+
17+
class RunSourcePayload(BaseModel):
18+
"""
19+
RunSourcePayload
20+
"""
21+
22+
index_to_include: Optional[List[StrictStr]] = Field(
23+
default=None,
24+
description="List of index names to include in reidexing/update.",
25+
alias="indexToInclude",
26+
)
27+
index_to_exclude: Optional[List[StrictStr]] = Field(
28+
default=None,
29+
description="List of index names to exclude in reidexing/update.",
30+
alias="indexToExclude",
31+
)
32+
entity_ids: Optional[List[StrictStr]] = Field(
33+
default=None, description="List of entityID to update.", alias="entityIDs"
34+
)
35+
entity_type: Optional[EntityType] = Field(default=None, alias="entityType")
36+
37+
model_config = ConfigDict(
38+
use_enum_values=True, populate_by_name=True, validate_assignment=True
39+
)
40+
41+
def to_json(self) -> str:
42+
return self.model_dump_json(by_alias=True, exclude_unset=True)
43+
44+
@classmethod
45+
def from_json(cls, json_str: str) -> Self:
46+
"""Create an instance of RunSourcePayload from a JSON string"""
47+
return cls.from_dict(loads(json_str))
48+
49+
def to_dict(self) -> Dict[str, Any]:
50+
"""Return the dictionary representation of the model using alias.
51+
52+
This has the following differences from calling pydantic's
53+
`self.model_dump(by_alias=True)`:
54+
55+
* `None` is only added to the output dict for nullable fields that
56+
were set at model initialization. Other fields with value `None`
57+
are ignored.
58+
"""
59+
_dict = self.model_dump(
60+
by_alias=True,
61+
exclude={},
62+
exclude_none=True,
63+
)
64+
return _dict
65+
66+
@classmethod
67+
def from_dict(cls, obj: Dict) -> Self:
68+
"""Create an instance of RunSourcePayload from a dict"""
69+
if obj is None:
70+
return None
71+
72+
if not isinstance(obj, dict):
73+
return cls.model_validate(obj)
74+
75+
_obj = cls.model_validate(
76+
{
77+
"indexToInclude": obj.get("indexToInclude"),
78+
"indexToExclude": obj.get("indexToExclude"),
79+
"entityIDs": obj.get("entityIDs"),
80+
"entityType": obj.get("entityType"),
81+
}
82+
)
83+
return _obj
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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, Self
11+
12+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
13+
14+
15+
class RunSourceResponse(BaseModel):
16+
"""
17+
RunSourceResponse
18+
"""
19+
20+
task_with_run_id: Dict[str, StrictStr] = Field(
21+
description="Map of taskID sent for reindex with the corresponding runID.",
22+
alias="taskWithRunID",
23+
)
24+
created_at: StrictStr = Field(
25+
description="Date of creation in RFC 3339 format.", alias="createdAt"
26+
)
27+
28+
model_config = ConfigDict(
29+
use_enum_values=True, populate_by_name=True, validate_assignment=True
30+
)
31+
32+
def to_json(self) -> str:
33+
return self.model_dump_json(by_alias=True, exclude_unset=True)
34+
35+
@classmethod
36+
def from_json(cls, json_str: str) -> Self:
37+
"""Create an instance of RunSourceResponse from a JSON string"""
38+
return cls.from_dict(loads(json_str))
39+
40+
def to_dict(self) -> Dict[str, Any]:
41+
"""Return the dictionary representation of the model using alias.
42+
43+
This has the following differences from calling pydantic's
44+
`self.model_dump(by_alias=True)`:
45+
46+
* `None` is only added to the output dict for nullable fields that
47+
were set at model initialization. Other fields with value `None`
48+
are ignored.
49+
"""
50+
_dict = self.model_dump(
51+
by_alias=True,
52+
exclude={},
53+
exclude_none=True,
54+
)
55+
return _dict
56+
57+
@classmethod
58+
def from_dict(cls, obj: Dict) -> Self:
59+
"""Create an instance of RunSourceResponse from a dict"""
60+
if obj is None:
61+
return None
62+
63+
if not isinstance(obj, dict):
64+
return cls.model_validate(obj)
65+
66+
_obj = cls.model_validate(
67+
{
68+
"taskWithRunID": obj.get("taskWithRunID"),
69+
"createdAt": obj.get("createdAt"),
70+
}
71+
)
72+
return _obj

0 commit comments

Comments
 (0)