Skip to content

Commit 7915b6e

Browse files
algolia-botFluf22
andcommitted
fix(specs): add missing redirect property to rule consequence schema (generated)
algolia/api-clients-automation#5934 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
1 parent 548a680 commit 7915b6e

3 files changed

Lines changed: 83 additions & 0 deletions

File tree

algoliasearch/search/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from .consequence_params import ConsequenceParams
4747
from .consequence_query import ConsequenceQuery
4848
from .consequence_query_object import ConsequenceQueryObject
49+
from .consequence_redirect import ConsequenceRedirect
4950
from .created_at_response import CreatedAtResponse
5051
from .delete_api_key_response import DeleteApiKeyResponse
5152
from .delete_by_params import DeleteByParams
@@ -222,6 +223,7 @@
222223
"ConsequenceParams",
223224
"ConsequenceQuery",
224225
"ConsequenceQueryObject",
226+
"ConsequenceRedirect",
225227
"CreatedAtResponse",
226228
"DeleteApiKeyResponse",
227229
"DeleteByParams",

algoliasearch/search/models/consequence.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020

2121
from algoliasearch.search.models.consequence_hide import ConsequenceHide
2222
from algoliasearch.search.models.consequence_params import ConsequenceParams
23+
from algoliasearch.search.models.consequence_redirect import ConsequenceRedirect
2324
from algoliasearch.search.models.promote import Promote
2425

2526
_ALIASES = {
2627
"params": "params",
2728
"promote": "promote",
2829
"filter_promotes": "filterPromotes",
2930
"hide": "hide",
31+
"redirect": "redirect",
3032
"user_data": "userData",
3133
}
3234

@@ -47,6 +49,7 @@ class Consequence(BaseModel):
4749
""" Determines whether promoted records must also match active filters for the consequence to apply. This ensures user-applied filters take priority and irrelevant matches aren't shown. For example, if you promote a record with `color: red` but the user filters for `color: blue`, the \"red\" record won't be shown. > In the Algolia dashboard, when you use the **Pin an item** consequence, `filterPromotes` appears as the checkbox: **Pinned items must match active filters to be displayed.** For examples, see [Promote results with rules](https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/how-to/promote-hits/#promote-results-matching-active-filters). """
4850
hide: Optional[List[ConsequenceHide]] = None
4951
""" Records you want to hide from the search results. """
52+
redirect: Optional[ConsequenceRedirect] = None
5053
user_data: Optional[object] = None
5154
""" A JSON object with custom data that will be appended to the `userData` array in the response. This object isn't interpreted by the API and is limited to 1&nbsp;kB of minified JSON. """
5255

@@ -100,5 +103,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
100103
if obj.get("hide") is not None
101104
else None
102105
)
106+
obj["redirect"] = (
107+
ConsequenceRedirect.from_dict(obj["redirect"])
108+
if obj.get("redirect") is not None
109+
else None
110+
)
103111

104112
return cls.model_validate(obj)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
_ALIASES = {
22+
"index_name": "indexName",
23+
}
24+
25+
26+
def _alias_generator(name: str) -> str:
27+
return _ALIASES.get(name, name)
28+
29+
30+
class ConsequenceRedirect(BaseModel):
31+
"""
32+
Redirect to a virtual replica index. This consequence is only valid for rules with `scope: redirect`.
33+
"""
34+
35+
index_name: str
36+
""" Name of the virtual replica index to redirect searches to. """
37+
38+
model_config = ConfigDict(
39+
strict=False,
40+
use_enum_values=True,
41+
populate_by_name=True,
42+
validate_assignment=True,
43+
protected_namespaces=(),
44+
alias_generator=_alias_generator,
45+
extra="allow",
46+
)
47+
48+
def to_json(self) -> str:
49+
return self.model_dump_json(by_alias=True, exclude_unset=True)
50+
51+
@classmethod
52+
def from_json(cls, json_str: str) -> Optional[Self]:
53+
"""Create an instance of ConsequenceRedirect from a JSON string"""
54+
return cls.from_dict(loads(json_str))
55+
56+
def to_dict(self) -> Dict[str, Any]:
57+
"""Return the dictionary representation of the model using alias."""
58+
return self.model_dump(
59+
by_alias=True,
60+
exclude_none=True,
61+
exclude_unset=True,
62+
)
63+
64+
@classmethod
65+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
66+
"""Create an instance of ConsequenceRedirect from a dict"""
67+
if obj is None:
68+
return None
69+
70+
if not isinstance(obj, dict):
71+
return cls.model_validate(obj)
72+
73+
return cls.model_validate(obj)

0 commit comments

Comments
 (0)