|
| 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 typing import Any, Dict, Optional, Self |
| 11 | + |
| 12 | +from pydantic import BaseModel, ConfigDict, StrictStr |
| 13 | + |
| 14 | + |
| 15 | +class RedirectURL(BaseModel): |
| 16 | + """ |
| 17 | + The redirect rule container. |
| 18 | + """ |
| 19 | + |
| 20 | + url: Optional[StrictStr] = None |
| 21 | + |
| 22 | + model_config = ConfigDict( |
| 23 | + use_enum_values=True, populate_by_name=True, validate_assignment=True |
| 24 | + ) |
| 25 | + |
| 26 | + def to_json(self) -> str: |
| 27 | + return self.model_dump_json(by_alias=True, exclude_unset=True) |
| 28 | + |
| 29 | + @classmethod |
| 30 | + def from_json(cls, json_str: str) -> Self: |
| 31 | + """Create an instance of RedirectURL from a JSON string""" |
| 32 | + return cls.from_dict(loads(json_str)) |
| 33 | + |
| 34 | + def to_dict(self) -> Dict[str, Any]: |
| 35 | + """Return the dictionary representation of the model using alias. |
| 36 | +
|
| 37 | + This has the following differences from calling pydantic's |
| 38 | + `self.model_dump(by_alias=True)`: |
| 39 | +
|
| 40 | + * `None` is only added to the output dict for nullable fields that |
| 41 | + were set at model initialization. Other fields with value `None` |
| 42 | + are ignored. |
| 43 | + """ |
| 44 | + _dict = self.model_dump( |
| 45 | + by_alias=True, |
| 46 | + exclude={}, |
| 47 | + exclude_none=True, |
| 48 | + ) |
| 49 | + return _dict |
| 50 | + |
| 51 | + @classmethod |
| 52 | + def from_dict(cls, obj: Dict) -> Self: |
| 53 | + """Create an instance of RedirectURL from a dict""" |
| 54 | + if obj is None: |
| 55 | + return None |
| 56 | + |
| 57 | + if not isinstance(obj, dict): |
| 58 | + return cls.model_validate(obj) |
| 59 | + |
| 60 | + _obj = cls.model_validate({"url": obj.get("url")}) |
| 61 | + return _obj |
0 commit comments