|
| 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 | + "injected_item_key": "_injectedItemKey", |
| 23 | +} |
| 24 | + |
| 25 | + |
| 26 | +def _alias_generator(name: str) -> str: |
| 27 | + return _ALIASES.get(name, name) |
| 28 | + |
| 29 | + |
| 30 | +class HitMetadata(BaseModel): |
| 31 | + """ |
| 32 | + An object that contains the extra key-value pairs provided in the injectedItem definition. |
| 33 | + """ |
| 34 | + |
| 35 | + injected_item_key: Optional[str] = None |
| 36 | + """ The key of the injectedItem that inserted this metadata. """ |
| 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 HitMetadata 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 HitMetadata 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