Source code for pydelfini.delfini_core.models.cdes_new_cdeset_body

from typing import Any
from typing import Dict
from typing import Type
from typing import TypeVar
from typing import Union

from attrs import define as _attrs_define

from ..models.cdeset_state import CdesetState
from ..types import UNSET
from ..types import Unset


T = TypeVar("T", bound="CdesNewCdesetBody")


[docs] @_attrs_define class CdesNewCdesetBody: """CdesNewCdesetBody model Attributes: description (str): name (str): display_name (Union[Unset, str]): is_default (Union[Unset, bool]): state (Union[Unset, CdesetState]): Lifecycle state of a CDE set: - `active`: listed everywhere and recommended for use (the default) - `deprecated`: still usable, but no longer recommended - `system`: hidden from the public CDE listing, but still available as a data element source (e.g. for metadata fields) """ description: str name: str display_name: Union[Unset, str] = UNSET is_default: Union[Unset, bool] = UNSET state: Union[Unset, CdesetState] = UNSET
[docs] def to_dict(self) -> Dict[str, Any]: """Convert to a dict""" description = self.description name = self.name display_name = self.display_name is_default = self.is_default state: Union[Unset, str] = UNSET if not isinstance(self.state, Unset): state = self.state.value field_dict: Dict[str, Any] = {} field_dict.update( { "description": description, "name": name, } ) if display_name is not UNSET: field_dict["display_name"] = display_name if is_default is not UNSET: field_dict["is_default"] = is_default if state is not UNSET: field_dict["state"] = state return field_dict
[docs] @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: """Create an instance of :py:class:`CdesNewCdesetBody` from a dict""" d = src_dict.copy() description = d.pop("description") name = d.pop("name") display_name = d.pop("display_name", UNSET) is_default = d.pop("is_default", UNSET) _state = d.pop("state", UNSET) state: Union[Unset, CdesetState] if isinstance(_state, Unset): state = UNSET else: state = CdesetState(_state) cdes_new_cdeset_body = cls( description=description, name=name, display_name=display_name, is_default=is_default, state=state, ) return cdes_new_cdeset_body