Skip to content

Commit d1483b5

Browse files
algolia-botben-kalmusClaraMuller
committed
feat(specs): add compositions deduplication setting (generated)
algolia/api-clients-automation#5418 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Ben Kalmus <[email protected]> Co-authored-by: Clara Muller <[email protected]>
1 parent 78c824d commit d1483b5

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed

algoliasearch/composition/models/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
from .composition_source_search import CompositionSourceSearch
3636
from .compositions_search_response import CompositionsSearchResponse
3737
from .condition import Condition
38+
from .dedup_positioning import DedupPositioning
39+
from .deduplication import Deduplication
3840
from .delete_composition_action import DeleteCompositionAction
3941
from .delete_composition_rule_action import DeleteCompositionRuleAction
4042
from .distinct import Distinct
@@ -144,6 +146,8 @@
144146
"CompositionSourceSearch",
145147
"CompositionsSearchResponse",
146148
"Condition",
149+
"DedupPositioning",
150+
"Deduplication",
147151
"DeleteCompositionAction",
148152
"DeleteCompositionRuleAction",
149153
"Distinct",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 sys import version_info
12+
13+
if version_info >= (3, 11):
14+
from typing import Self
15+
else:
16+
from typing_extensions import Self
17+
18+
19+
class DedupPositioning(str, Enum):
20+
"""
21+
Deduplication positioning configures how a duplicate result should be resolved between an injected item and main search results. Current configuration supports: - 'highest': always select the item in the highest position, and remove duplicates that appear lower in the results. - 'highestInjected': duplicate result will be moved to its highest possible injected position, but not higher. If a duplicate appears higher in main search results, it will be removed to stay it's intended group position (which could be lower than main).
22+
"""
23+
24+
"""
25+
allowed enum values
26+
"""
27+
HIGHEST = "highest"
28+
29+
HIGHESTINJECTED = "highestInjected"
30+
31+
@classmethod
32+
def from_json(cls, json_str: str) -> Self:
33+
"""Create an instance of DedupPositioning from a JSON string"""
34+
return cls(loads(json_str))
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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.composition.models.dedup_positioning import DedupPositioning
22+
23+
_ALIASES = {
24+
"positioning": "positioning",
25+
}
26+
27+
28+
def _alias_generator(name: str) -> str:
29+
return _ALIASES.get(name, name)
30+
31+
32+
class Deduplication(BaseModel):
33+
"""
34+
Deduplication configures the methods used to resolve duplicate items between main search results and injected group results.
35+
"""
36+
37+
positioning: DedupPositioning
38+
39+
model_config = ConfigDict(
40+
strict=False,
41+
use_enum_values=True,
42+
populate_by_name=True,
43+
validate_assignment=True,
44+
protected_namespaces=(),
45+
alias_generator=_alias_generator,
46+
extra="allow",
47+
)
48+
49+
def to_json(self) -> str:
50+
return self.model_dump_json(by_alias=True, exclude_unset=True)
51+
52+
@classmethod
53+
def from_json(cls, json_str: str) -> Optional[Self]:
54+
"""Create an instance of Deduplication from a JSON string"""
55+
return cls.from_dict(loads(json_str))
56+
57+
def to_dict(self) -> Dict[str, Any]:
58+
"""Return the dictionary representation of the model using alias."""
59+
return self.model_dump(
60+
by_alias=True,
61+
exclude_none=True,
62+
exclude_unset=True,
63+
)
64+
65+
@classmethod
66+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
67+
"""Create an instance of Deduplication from a dict"""
68+
if obj is None:
69+
return None
70+
71+
if not isinstance(obj, dict):
72+
return cls.model_validate(obj)
73+
74+
obj["positioning"] = obj.get("positioning")
75+
76+
return cls.model_validate(obj)

algoliasearch/composition/models/injection.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
from typing_extensions import Self
1919

2020

21+
from algoliasearch.composition.models.deduplication import Deduplication
2122
from algoliasearch.composition.models.injected_item import InjectedItem
2223
from algoliasearch.composition.models.main import Main
2324

2425
_ALIASES = {
2526
"main": "main",
2627
"injected_items": "injectedItems",
28+
"deduplication": "deduplication",
2729
}
2830

2931

@@ -39,6 +41,7 @@ class Injection(BaseModel):
3941
main: Main
4042
injected_items: Optional[List[InjectedItem]] = None
4143
""" list of injected items of the current Composition. """
44+
deduplication: Optional[Deduplication] = None
4245

4346
model_config = ConfigDict(
4447
strict=False,
@@ -83,5 +86,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
8386
if obj.get("injectedItems") is not None
8487
else None
8588
)
89+
obj["deduplication"] = (
90+
Deduplication.from_dict(obj["deduplication"])
91+
if obj.get("deduplication") is not None
92+
else None
93+
)
8694

8795
return cls.model_validate(obj)

0 commit comments

Comments
 (0)