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="CustomPropertySchemaSelectOption")
[docs]
@_attrs_define
class CustomPropertySchemaSelectOption:
"""A select option."""
value: None | str | Unset = UNSET
""" The unique identifier value for this select option. """
label: None | str | Unset = UNSET
""" The user-friendly label of this select option. """
[docs]
def to_dict(self) -> dict[str, Any]:
value: None | str | Unset
if isinstance(self.value, Unset):
value = UNSET
else:
value = self.value
label: None | str | Unset
if isinstance(self.label, Unset):
label = UNSET
else:
label = self.label
field_dict: dict[str, Any] = {}
field_dict.update({})
if value is not UNSET:
field_dict["value"] = value
if label is not UNSET:
field_dict["label"] = label
return field_dict
[docs]
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
def _parse_value(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)
value = _parse_value(d.pop("value", UNSET))
def _parse_label(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)
label = _parse_label(d.pop("label", UNSET))
custom_property_schema_select_option = cls(
value=value,
label=label,
)
return custom_property_schema_select_option