Skip to content

Commit

Permalink
feat(specs): add runSource endpoint (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3453

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
algolia-bot and millotp committed Aug 2, 2024
1 parent 74a1600 commit 036cb1c
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 0 deletions.
76 changes: 76 additions & 0 deletions algoliasearch/ingestion/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
from algoliasearch.ingestion.models.run_list_response import RunListResponse
from algoliasearch.ingestion.models.run_response import RunResponse
from algoliasearch.ingestion.models.run_sort_keys import RunSortKeys
from algoliasearch.ingestion.models.run_source_payload import RunSourcePayload
from algoliasearch.ingestion.models.run_source_response import RunSourceResponse
from algoliasearch.ingestion.models.run_status import RunStatus
from algoliasearch.ingestion.models.sort_keys import SortKeys
from algoliasearch.ingestion.models.source import Source
Expand Down Expand Up @@ -3310,6 +3312,80 @@ async def push_task(
)
).deserialize(RunResponse)

async def run_source_with_http_info(
self,
source_id: Annotated[
StrictStr, Field(description="Unique identifier of a source.")
],
run_source_payload: Optional[RunSourcePayload] = None,
request_options: Optional[Union[dict, RequestOptions]] = None,
) -> ApiResponse[str]:
"""
Runs all tasks linked to a source, only available for Shopify sources. It will create 1 run per task.
Required API Key ACLs:
- addObject
- deleteIndex
- editSettings
:param source_id: Unique identifier of a source. (required)
:type source_id: str
:param run_source_payload:
:type run_source_payload: RunSourcePayload
: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)
:return: Returns the raw algoliasearch 'APIResponse' object.
"""

if source_id is None:
raise ValueError(
"Parameter `source_id` is required when calling `run_source`."
)

_data = {}
if run_source_payload is not None:
_data = run_source_payload

return await self._transporter.request(
verb=Verb.POST,
path="/1/sources/{sourceID}/run".replace(
"{sourceID}", quote(str(source_id), safe="")
),
request_options=self._request_options.merge(
data=dumps(bodySerializer(_data)),
user_request_options=request_options,
),
use_read_transporter=False,
)

async def run_source(
self,
source_id: Annotated[
StrictStr, Field(description="Unique identifier of a source.")
],
run_source_payload: Optional[RunSourcePayload] = None,
request_options: Optional[Union[dict, RequestOptions]] = None,
) -> RunSourceResponse:
"""
Runs all tasks linked to a source, only available for Shopify sources. It will create 1 run per task.
Required API Key ACLs:
- addObject
- deleteIndex
- editSettings
:param source_id: Unique identifier of a source. (required)
:type source_id: str
:param run_source_payload:
:type run_source_payload: RunSourcePayload
: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)
:return: Returns the deserialized response in a 'RunSourceResponse' result object.
"""
return (
await self.run_source_with_http_info(
source_id, run_source_payload, request_options
)
).deserialize(RunSourceResponse)

async def run_task_with_http_info(
self,
task_id: Annotated[
Expand Down
28 changes: 28 additions & 0 deletions algoliasearch/ingestion/models/entity_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# coding: utf-8

"""
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.
"""

from __future__ import annotations

from enum import Enum
from json import loads
from typing import Self


class EntityType(str, Enum):
"""
Type of entity to update.
"""

"""
allowed enum values
"""
PRODUCT = "product"
COLLECTION = "collection"

@classmethod
def from_json(cls, json_str: str) -> Self:
"""Create an instance of EntityType from a JSON string"""
return cls(loads(json_str))
83 changes: 83 additions & 0 deletions algoliasearch/ingestion/models/run_source_payload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# coding: utf-8

"""
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.
"""

from __future__ import annotations

from json import loads
from typing import Any, Dict, List, Optional, Self

from pydantic import BaseModel, ConfigDict, Field, StrictStr

from algoliasearch.ingestion.models.entity_type import EntityType


class RunSourcePayload(BaseModel):
"""
RunSourcePayload
"""

index_to_include: Optional[List[StrictStr]] = Field(
default=None,
description="List of index names to include in reidexing/update.",
alias="indexToInclude",
)
index_to_exclude: Optional[List[StrictStr]] = Field(
default=None,
description="List of index names to exclude in reidexing/update.",
alias="indexToExclude",
)
entity_ids: Optional[List[StrictStr]] = Field(
default=None, description="List of entityID to update.", alias="entityIDs"
)
entity_type: Optional[EntityType] = Field(default=None, alias="entityType")

model_config = ConfigDict(
use_enum_values=True, populate_by_name=True, validate_assignment=True
)

def to_json(self) -> str:
return self.model_dump_json(by_alias=True, exclude_unset=True)

@classmethod
def from_json(cls, json_str: str) -> Self:
"""Create an instance of RunSourcePayload from a JSON string"""
return cls.from_dict(loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
_dict = self.model_dump(
by_alias=True,
exclude={},
exclude_none=True,
)
return _dict

@classmethod
def from_dict(cls, obj: Dict) -> Self:
"""Create an instance of RunSourcePayload from a dict"""
if obj is None:
return None

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

_obj = cls.model_validate(
{
"indexToInclude": obj.get("indexToInclude"),
"indexToExclude": obj.get("indexToExclude"),
"entityIDs": obj.get("entityIDs"),
"entityType": obj.get("entityType"),
}
)
return _obj
72 changes: 72 additions & 0 deletions algoliasearch/ingestion/models/run_source_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# coding: utf-8

"""
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.
"""

from __future__ import annotations

from json import loads
from typing import Any, Dict, Self

from pydantic import BaseModel, ConfigDict, Field, StrictStr


class RunSourceResponse(BaseModel):
"""
RunSourceResponse
"""

task_with_run_id: Dict[str, StrictStr] = Field(
description="Map of taskID sent for reindex with the corresponding runID.",
alias="taskWithRunID",
)
created_at: StrictStr = Field(
description="Date of creation in RFC 3339 format.", alias="createdAt"
)

model_config = ConfigDict(
use_enum_values=True, populate_by_name=True, validate_assignment=True
)

def to_json(self) -> str:
return self.model_dump_json(by_alias=True, exclude_unset=True)

@classmethod
def from_json(cls, json_str: str) -> Self:
"""Create an instance of RunSourceResponse from a JSON string"""
return cls.from_dict(loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
_dict = self.model_dump(
by_alias=True,
exclude={},
exclude_none=True,
)
return _dict

@classmethod
def from_dict(cls, obj: Dict) -> Self:
"""Create an instance of RunSourceResponse from a dict"""
if obj is None:
return None

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

_obj = cls.model_validate(
{
"taskWithRunID": obj.get("taskWithRunID"),
"createdAt": obj.get("createdAt"),
}
)
return _obj

0 comments on commit 036cb1c

Please sign in to comment.