from __future__ import annotations
from collections.abc import Mapping
from typing import Any, TypeVar, cast
from attrs import define as _attrs_define
from ..types import UNSET, Unset
T = TypeVar("T", bound="CustomPropertySchemaFloatSettings")
[docs]
@_attrs_define
class CustomPropertySchemaFloatSettings:
"""Settings specific to 'Float' type custom properties."""
unit: None | str | Unset = UNSET
""" The unit of measurement the float value is expressed as. Can be null if the unit of measurement is not
specified. """
minimum_value: float | None | Unset = UNSET
""" The smallest acceptable float value. Can be null if a minimum value is not specified. Expressed in the unit
of measurement indicated by the property 'unit'. """
maximum_value: float | None | Unset = UNSET
""" The largest acceptable float value. Can be null if a maximum value is not specified. Expressed in the unit
of measurement indicated by the property 'unit'. """
[docs]
def to_dict(self) -> dict[str, Any]:
unit: None | str | Unset
if isinstance(self.unit, Unset):
unit = UNSET
else:
unit = self.unit
minimum_value: float | None | Unset
if isinstance(self.minimum_value, Unset):
minimum_value = UNSET
else:
minimum_value = self.minimum_value
maximum_value: float | None | Unset
if isinstance(self.maximum_value, Unset):
maximum_value = UNSET
else:
maximum_value = self.maximum_value
field_dict: dict[str, Any] = {}
field_dict.update({})
if unit is not UNSET:
field_dict["unit"] = unit
if minimum_value is not UNSET:
field_dict["minimumValue"] = minimum_value
if maximum_value is not UNSET:
field_dict["maximumValue"] = maximum_value
return field_dict
[docs]
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
def _parse_unit(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)
unit = _parse_unit(d.pop("unit", UNSET))
def _parse_minimum_value(data: object) -> float | None | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(float | None | Unset, data)
minimum_value = _parse_minimum_value(d.pop("minimumValue", UNSET))
def _parse_maximum_value(data: object) -> float | None | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(float | None | Unset, data)
maximum_value = _parse_maximum_value(d.pop("maximumValue", UNSET))
custom_property_schema_float_settings = cls(
unit=unit,
minimum_value=minimum_value,
maximum_value=maximum_value,
)
return custom_property_schema_float_settings