|
| 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