Skip to content

Commit 7d830c0

Browse files
feat(specs): introduce multifeed composition behavior for beta release (generated)
algolia/api-clients-automation#5828 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Gavin Wade <[email protected]>
1 parent 563c39e commit 7d830c0

3 files changed

Lines changed: 96 additions & 2 deletions

File tree

algoliasearch/composition/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
from .main_injection_query_parameters import MainInjectionQueryParameters
7272
from .match_level import MatchLevel
7373
from .matched_geo_location import MatchedGeoLocation
74+
from .multifeed import Multifeed
7475
from .multiple_batch_request import MultipleBatchRequest
7576
from .multiple_batch_response import MultipleBatchResponse
7677
from .numeric_filters import NumericFilters
@@ -182,6 +183,7 @@
182183
"MainInjectionQueryParameters",
183184
"MatchLevel",
184185
"MatchedGeoLocation",
186+
"Multifeed",
185187
"MultipleBatchRequest",
186188
"MultipleBatchResponse",
187189
"NumericFilters",

algoliasearch/composition/models/composition_behavior.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919

2020

2121
from algoliasearch.composition.models.injection import Injection
22+
from algoliasearch.composition.models.multifeed import Multifeed
2223

2324
_ALIASES = {
2425
"injection": "injection",
26+
"multifeed": "multifeed",
2527
}
2628

2729

@@ -31,10 +33,11 @@ def _alias_generator(name: str) -> str:
3133

3234
class CompositionBehavior(BaseModel):
3335
"""
34-
CompositionBehavior
36+
An object containing either an `injection` or `multifeed` behavior schema, but not both.
3537
"""
3638

37-
injection: Injection
39+
injection: Optional[Injection] = None
40+
multifeed: Optional[Multifeed] = None
3841

3942
model_config = ConfigDict(
4043
strict=False,
@@ -76,5 +79,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
7679
if obj.get("injection") is not None
7780
else None
7881
)
82+
obj["multifeed"] = (
83+
Multifeed.from_dict(obj["multifeed"])
84+
if obj.get("multifeed") is not None
85+
else None
86+
)
7987

8088
return cls.model_validate(obj)
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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.composition.models.injection import Injection
22+
23+
_ALIASES = {
24+
"feeds": "feeds",
25+
"feeds_order": "feedsOrder",
26+
}
27+
28+
29+
def _alias_generator(name: str) -> str:
30+
return _ALIASES.get(name, name)
31+
32+
33+
class Multifeed(BaseModel):
34+
"""
35+
Multifeed
36+
"""
37+
38+
feeds: Dict[str, Injection]
39+
""" A key-value store of Feed ID to Feed. Currently, the only supported Feed type is an Injection. """
40+
feeds_order: Optional[List[str]] = None
41+
""" A list of Feed IDs that specifies the order in which to order the results in the response. The IDs should be a subset of those in the Feeds object, and only those specified will be processed. When this field is not set, all Feeds are processed and returned with a default ordering. """
42+
43+
model_config = ConfigDict(
44+
strict=False,
45+
use_enum_values=True,
46+
populate_by_name=True,
47+
validate_assignment=True,
48+
protected_namespaces=(),
49+
alias_generator=_alias_generator,
50+
extra="allow",
51+
)
52+
53+
def to_json(self) -> str:
54+
return self.model_dump_json(by_alias=True, exclude_unset=True)
55+
56+
@classmethod
57+
def from_json(cls, json_str: str) -> Optional[Self]:
58+
"""Create an instance of Multifeed from a JSON string"""
59+
return cls.from_dict(loads(json_str))
60+
61+
def to_dict(self) -> Dict[str, Any]:
62+
"""Return the dictionary representation of the model using alias."""
63+
return self.model_dump(
64+
by_alias=True,
65+
exclude_none=True,
66+
exclude_unset=True,
67+
)
68+
69+
@classmethod
70+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
71+
"""Create an instance of Multifeed from a dict"""
72+
if obj is None:
73+
return None
74+
75+
if not isinstance(obj, dict):
76+
return cls.model_validate(obj)
77+
78+
obj["feeds"] = (
79+
dict((_k, Injection.from_dict(_v)) for _k, _v in obj["feeds"].items())
80+
if obj.get("feeds") is not None
81+
else None
82+
)
83+
84+
return cls.model_validate(obj)

0 commit comments

Comments
 (0)