Source code for maptekblastlogic.models.person_model

from __future__ import annotations

import datetime
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="PersonModel")


[docs] @_attrs_define class PersonModel: """A person and their responsibilities.""" personnel_id: int | Unset = UNSET """ The unique identifier of this person. """ etag: None | str | Unset = UNSET """ The person's ETag. Ignored when creating and editing. """ created_by: None | str | Unset = UNSET """ Username of the person who created this person. Ignored when creating and editing. """ created_time: datetime.datetime | None | Unset = UNSET """ When this person was last updated (UTC). Ignored when creating and editing. """ last_modified_by: None | str | Unset = UNSET """ Username of the person who last updated this person. Ignored when creating and editing. """ last_modified_time: datetime.datetime | None | Unset = UNSET """ When this person was last updated (UTC). Ignored when creating and editing. """ name: None | str | Unset = UNSET """ The name of this person. """ is_backfilling_supervisor: bool | Unset = UNSET """ Whether this person can supervise backfilling activities. """ is_dipping_supervisor: bool | Unset = UNSET """ Whether this person can supervise dipping activities. """ is_loading_truck_operator: bool | Unset = UNSET """ Whether this person can operate loading trucks. """ is_shot_firer: bool | Unset = UNSET """ Whether this person can perform shotfirer duties. """
[docs] def to_dict(self) -> dict[str, Any]: personnel_id = self.personnel_id etag: None | str | Unset if isinstance(self.etag, Unset): etag = UNSET else: etag = self.etag created_by: None | str | Unset if isinstance(self.created_by, Unset): created_by = UNSET else: created_by = self.created_by created_time: None | str | Unset if isinstance(self.created_time, Unset): created_time = UNSET elif isinstance(self.created_time, datetime.datetime): created_time = self.created_time.isoformat() else: created_time = self.created_time last_modified_by: None | str | Unset if isinstance(self.last_modified_by, Unset): last_modified_by = UNSET else: last_modified_by = self.last_modified_by last_modified_time: None | str | Unset if isinstance(self.last_modified_time, Unset): last_modified_time = UNSET elif isinstance(self.last_modified_time, datetime.datetime): last_modified_time = self.last_modified_time.isoformat() else: last_modified_time = self.last_modified_time name: None | str | Unset if isinstance(self.name, Unset): name = UNSET else: name = self.name is_backfilling_supervisor = self.is_backfilling_supervisor is_dipping_supervisor = self.is_dipping_supervisor is_loading_truck_operator = self.is_loading_truck_operator is_shot_firer = self.is_shot_firer field_dict: dict[str, Any] = {} field_dict.update({}) if personnel_id is not UNSET: field_dict["personnelId"] = personnel_id if etag is not UNSET: field_dict["etag"] = etag if created_by is not UNSET: field_dict["createdBy"] = created_by if created_time is not UNSET: field_dict["createdTime"] = created_time if last_modified_by is not UNSET: field_dict["lastModifiedBy"] = last_modified_by if last_modified_time is not UNSET: field_dict["lastModifiedTime"] = last_modified_time if name is not UNSET: field_dict["name"] = name if is_backfilling_supervisor is not UNSET: field_dict["isBackfillingSupervisor"] = is_backfilling_supervisor if is_dipping_supervisor is not UNSET: field_dict["isDippingSupervisor"] = is_dipping_supervisor if is_loading_truck_operator is not UNSET: field_dict["isLoadingTruckOperator"] = is_loading_truck_operator if is_shot_firer is not UNSET: field_dict["isShotFirer"] = is_shot_firer return field_dict
[docs] @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) personnel_id = d.pop("personnelId", UNSET) def _parse_etag(data: object) -> None | str | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(None | str | Unset, data) etag = _parse_etag(d.pop("etag", UNSET)) def _parse_created_by(data: object) -> None | str | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(None | str | Unset, data) created_by = _parse_created_by(d.pop("createdBy", UNSET)) def _parse_created_time(data: object) -> datetime.datetime | None | Unset: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, str): raise TypeError() created_time_type_0 = datetime.datetime.fromisoformat(data) return created_time_type_0 except (TypeError, ValueError, AttributeError, KeyError): pass return cast(datetime.datetime | None | Unset, data) created_time = _parse_created_time(d.pop("createdTime", UNSET)) def _parse_last_modified_by(data: object) -> None | str | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(None | str | Unset, data) last_modified_by = _parse_last_modified_by(d.pop("lastModifiedBy", UNSET)) def _parse_last_modified_time(data: object) -> datetime.datetime | None | Unset: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, str): raise TypeError() last_modified_time_type_0 = datetime.datetime.fromisoformat(data) return last_modified_time_type_0 except (TypeError, ValueError, AttributeError, KeyError): pass return cast(datetime.datetime | None | Unset, data) last_modified_time = _parse_last_modified_time(d.pop("lastModifiedTime", UNSET)) def _parse_name(data: object) -> None | str | Unset: if data is None: return data if isinstance(data, Unset): return data return cast(None | str | Unset, data) name = _parse_name(d.pop("name", UNSET)) is_backfilling_supervisor = d.pop("isBackfillingSupervisor", UNSET) is_dipping_supervisor = d.pop("isDippingSupervisor", UNSET) is_loading_truck_operator = d.pop("isLoadingTruckOperator", UNSET) is_shot_firer = d.pop("isShotFirer", UNSET) person_model = cls( personnel_id=personnel_id, etag=etag, created_by=created_by, created_time=created_time, last_modified_by=last_modified_by, last_modified_time=last_modified_time, name=name, is_backfilling_supervisor=is_backfilling_supervisor, is_dipping_supervisor=is_dipping_supervisor, is_loading_truck_operator=is_loading_truck_operator, is_shot_firer=is_shot_firer, ) return person_model