-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(specs): add v2 endpoints for ingestion
algolia/api-clients-automation#3416 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
1 parent
befa44c
commit 3d4ca53
Showing
4 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 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 Action(str, Enum): | ||
""" | ||
Type of indexing operation. | ||
""" | ||
|
||
""" | ||
allowed enum values | ||
""" | ||
ADDOBJECT = "addObject" | ||
UPDATEOBJECT = "updateObject" | ||
PARTIALUPDATEOBJECT = "partialUpdateObject" | ||
PARTIALUPDATEOBJECTNOCREATE = "partialUpdateObjectNoCreate" | ||
DELETEOBJECT = "deleteObject" | ||
DELETE = "delete" | ||
CLEAR = "clear" | ||
|
||
@classmethod | ||
def from_json(cls, json_str: str) -> Self: | ||
"""Create an instance of Action from a JSON string""" | ||
return cls(loads(json_str)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# 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 | ||
|
||
from algoliasearch.ingestion.models.action import Action | ||
|
||
|
||
class BatchRequest(BaseModel): | ||
""" | ||
BatchRequest | ||
""" | ||
|
||
action: Action | ||
body: Dict[str, Any] = Field( | ||
description="Operation arguments (varies with specified `action`)." | ||
) | ||
|
||
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 BatchRequest 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 BatchRequest from a dict""" | ||
if obj is None: | ||
return None | ||
|
||
if not isinstance(obj, dict): | ||
return cls.model_validate(obj) | ||
|
||
_obj = cls.model_validate( | ||
{"action": obj.get("action"), "body": obj.get("body")} | ||
) | ||
return _obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# 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, Self | ||
|
||
from pydantic import BaseModel, ConfigDict | ||
|
||
from algoliasearch.ingestion.models.batch_request import BatchRequest | ||
|
||
|
||
class BatchWriteParams(BaseModel): | ||
""" | ||
Batch parameters. | ||
""" | ||
|
||
requests: List[BatchRequest] | ||
|
||
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 BatchWriteParams 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, | ||
) | ||
_items = [] | ||
if self.requests: | ||
for _item in self.requests: | ||
if _item: | ||
_items.append(_item.to_dict()) | ||
_dict["requests"] = _items | ||
return _dict | ||
|
||
@classmethod | ||
def from_dict(cls, obj: Dict) -> Self: | ||
"""Create an instance of BatchWriteParams from a dict""" | ||
if obj is None: | ||
return None | ||
|
||
if not isinstance(obj, dict): | ||
return cls.model_validate(obj) | ||
|
||
_obj = cls.model_validate( | ||
{ | ||
"requests": ( | ||
[BatchRequest.from_dict(_item) for _item in obj.get("requests")] | ||
if obj.get("requests") is not None | ||
else None | ||
) | ||
} | ||
) | ||
return _obj |