Skip to content

Commit 33fa2e6

Browse files
fix(specs): document abTest field on listIndices response (generated)
algolia/api-clients-automation#6443 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
1 parent 6abf26c commit 33fa2e6

5 files changed

Lines changed: 279 additions & 0 deletions

File tree

algoliasearch/search/models/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
from .facet_stats import FacetStats
7979
from .facets import Facets
8080
from .fetched_index import FetchedIndex
81+
from .fetched_index_ab_test import FetchedIndexAbTest
82+
from .fetched_index_ab_test_target import FetchedIndexAbTestTarget
83+
from .fetched_index_ab_test_variant import FetchedIndexAbTestVariant
8184
from .get_api_key_response import GetApiKeyResponse
8285
from .get_dictionary_settings_response import GetDictionarySettingsResponse
8386
from .get_logs_response import GetLogsResponse
@@ -265,6 +268,9 @@
265268
"FacetStats",
266269
"Facets",
267270
"FetchedIndex",
271+
"FetchedIndexAbTest",
272+
"FetchedIndexAbTestTarget",
273+
"FetchedIndexAbTestVariant",
268274
"GetApiKeyResponse",
269275
"GetDictionarySettingsResponse",
270276
"GetLogsResponse",

algoliasearch/search/models/fetched_index.py

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

2020

21+
from algoliasearch.search.models.fetched_index_ab_test import FetchedIndexAbTest
22+
2123
_ALIASES = {
2224
"name": "name",
2325
"created_at": "createdAt",
@@ -31,6 +33,8 @@
3133
"primary": "primary",
3234
"replicas": "replicas",
3335
"virtual": "virtual",
36+
"ab_test": "abTest",
37+
"source_ab_test": "sourceABTest",
3438
}
3539

3640

@@ -67,6 +71,9 @@ class FetchedIndex(BaseModel):
6771
""" Only present if the index is a primary index with replicas. Contains the names of all linked replicas. """
6872
virtual: Optional[bool] = None
6973
""" Only present if the index is a [virtual replica](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/how-to/sort-an-index-alphabetically/#virtual-replicas). """
74+
ab_test: Optional[FetchedIndexAbTest] = None
75+
source_ab_test: Optional[str] = None
76+
""" Name of the index that owns the A/B test configuration. Only present when this index participates in an A/B test configured on another index. """
7077

7178
model_config = ConfigDict(
7279
strict=False,
@@ -103,4 +110,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
103110
if not isinstance(obj, dict):
104111
return cls.model_validate(obj)
105112

113+
obj["abTest"] = (
114+
FetchedIndexAbTest.from_dict(obj["abTest"])
115+
if obj.get("abTest") is not None
116+
else None
117+
)
118+
106119
return cls.model_validate(obj)
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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, List, 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.search.models.fetched_index_ab_test_target import (
22+
FetchedIndexAbTestTarget,
23+
)
24+
from algoliasearch.search.models.fetched_index_ab_test_variant import (
25+
FetchedIndexAbTestVariant,
26+
)
27+
28+
_ALIASES = {
29+
"id": "id",
30+
"is_dark": "isDark",
31+
"version": "version",
32+
"type": "type",
33+
"target": "target",
34+
"variants": "variants",
35+
}
36+
37+
38+
def _alias_generator(name: str) -> str:
39+
return _ALIASES.get(name, name)
40+
41+
42+
class FetchedIndexAbTest(BaseModel):
43+
"""
44+
A/B test metadata. Only present if the index is part of an active A/B test.
45+
"""
46+
47+
id: int
48+
""" A/B test ID. """
49+
is_dark: Optional[bool] = None
50+
""" Whether the A/B test is a dark test (server-side measured, not user-facing). Only present when true. """
51+
version: Optional[int] = None
52+
""" A/B test schema version. Only present for v2 and later tests. """
53+
type: Optional[str] = None
54+
""" A/B test type. Only present for v2 and later tests. Currently always `index-configuration`. """
55+
target: Optional[FetchedIndexAbTestTarget] = None
56+
variants: List[FetchedIndexAbTestVariant]
57+
""" A/B test variants. """
58+
59+
model_config = ConfigDict(
60+
strict=False,
61+
use_enum_values=True,
62+
populate_by_name=True,
63+
validate_assignment=True,
64+
protected_namespaces=(),
65+
alias_generator=_alias_generator,
66+
extra="allow",
67+
)
68+
69+
def to_json(self) -> str:
70+
return self.model_dump_json(by_alias=True, exclude_unset=True)
71+
72+
@classmethod
73+
def from_json(cls, json_str: str) -> Optional[Self]:
74+
"""Create an instance of FetchedIndexAbTest from a JSON string"""
75+
return cls.from_dict(loads(json_str))
76+
77+
def to_dict(self) -> Dict[str, Any]:
78+
"""Return the dictionary representation of the model using alias."""
79+
return self.model_dump(
80+
by_alias=True,
81+
exclude_none=True,
82+
exclude_unset=True,
83+
)
84+
85+
@classmethod
86+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
87+
"""Create an instance of FetchedIndexAbTest from a dict"""
88+
if obj is None:
89+
return None
90+
91+
if not isinstance(obj, dict):
92+
return cls.model_validate(obj)
93+
94+
obj["target"] = (
95+
FetchedIndexAbTestTarget.from_dict(obj["target"])
96+
if obj.get("target") is not None
97+
else None
98+
)
99+
obj["variants"] = (
100+
[FetchedIndexAbTestVariant.from_dict(_item) for _item in obj["variants"]]
101+
if obj.get("variants") is not None
102+
else None
103+
)
104+
105+
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 FetchedIndexAbTestTarget(BaseModel):
31+
"""
32+
A/B test target criteria. Only present for v2 and later tests.
33+
"""
34+
35+
index_name: str
36+
""" Index name to match. Use `*` to target the entire application. """
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 FetchedIndexAbTestTarget 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 FetchedIndexAbTestTarget 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)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
"percentage": "percentage",
24+
"custom_search_parameters": "customSearchParameters",
25+
"payload": "payload",
26+
}
27+
28+
29+
def _alias_generator(name: str) -> str:
30+
return _ALIASES.get(name, name)
31+
32+
33+
class FetchedIndexAbTestVariant(BaseModel):
34+
"""
35+
A/B test variant for an index.
36+
"""
37+
38+
index_name: Optional[str] = None
39+
""" Index name of the variant. Only present for v0/v1 tests; in v2 this moves into `payload`. """
40+
percentage: int
41+
""" Percentage of search traffic routed to this variant. """
42+
custom_search_parameters: Optional[str] = None
43+
""" URL-encoded custom search parameters applied to this variant. Only present for v0/v1 tests; in v2 this moves into `payload`. """
44+
payload: Optional[Dict[str, object]] = None
45+
""" Type-specific configuration. Only present for v2 and later tests. Shape depends on the parent A/B test's `type`. """
46+
47+
model_config = ConfigDict(
48+
strict=False,
49+
use_enum_values=True,
50+
populate_by_name=True,
51+
validate_assignment=True,
52+
protected_namespaces=(),
53+
alias_generator=_alias_generator,
54+
extra="allow",
55+
)
56+
57+
def to_json(self) -> str:
58+
return self.model_dump_json(by_alias=True, exclude_unset=True)
59+
60+
@classmethod
61+
def from_json(cls, json_str: str) -> Optional[Self]:
62+
"""Create an instance of FetchedIndexAbTestVariant from a JSON string"""
63+
return cls.from_dict(loads(json_str))
64+
65+
def to_dict(self) -> Dict[str, Any]:
66+
"""Return the dictionary representation of the model using alias."""
67+
return self.model_dump(
68+
by_alias=True,
69+
exclude_none=True,
70+
exclude_unset=True,
71+
)
72+
73+
@classmethod
74+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
75+
"""Create an instance of FetchedIndexAbTestVariant from a dict"""
76+
if obj is None:
77+
return None
78+
79+
if not isinstance(obj, dict):
80+
return cls.model_validate(obj)
81+
82+
return cls.model_validate(obj)

0 commit comments

Comments
 (0)