from __future__ import annotations
import datetime
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Optional, TYPE_CHECKING, Union
from uuid import UUID

@dataclass
class IssueRootCauseCategoriesGetResponse_results_rootCauses(Parsable):
    # The date and time the issue root cause was created, in the following format: YYYY-MM-DDThh:mm:ss.sz.
    created_at: Optional[datetime.datetime] = None
    # The Autodesk ID of the user who created the issue root cause.
    created_by: Optional[str] = None
    # The date and time the issue root cause was deleted, in the following format: YYYY-MM-DDThh:mm:ss.sz.
    deleted_at: Optional[datetime.datetime] = None
    # The Autodesk ID of the user who deleted the issue root cause.
    deleted_by: Optional[str] = None
    # The ID of the issue root cause.
    id: Optional[UUID] = None
    # States whether the root cause is active.
    is_active: Optional[bool] = None
    # Not relevant
    permitted_actions: Optional[list[str]] = None
    # Not relevant
    permitted_attributes: Optional[list[str]] = None
    # The ID of the parent issue root cause category.
    root_cause_category_id: Optional[UUID] = None
    # The title of the issue root cause.Max length: 100
    title: Optional[str] = None
    # The last date and time the issue root cause was updated, in the following format: YYYY-MM-DDThh:mm:ss.sz.
    updated_at: Optional[datetime.datetime] = None
    # The Autodesk ID of the user who last updated the issue root cause.
    updated_by: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> IssueRootCauseCategoriesGetResponse_results_rootCauses:
        """
        Creates a new instance of the appropriate class based on discriminator value
        param parse_node: The parse node to use to read the discriminator value and create the object
        Returns: IssueRootCauseCategoriesGetResponse_results_rootCauses
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return IssueRootCauseCategoriesGetResponse_results_rootCauses()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        fields: dict[str, Callable[[Any], None]] = {
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "createdBy": lambda n : setattr(self, 'created_by', n.get_str_value()),
            "deletedAt": lambda n : setattr(self, 'deleted_at', n.get_datetime_value()),
            "deletedBy": lambda n : setattr(self, 'deleted_by', n.get_str_value()),
            "id": lambda n : setattr(self, 'id', n.get_uuid_value()),
            "isActive": lambda n : setattr(self, 'is_active', n.get_bool_value()),
            "permittedActions": lambda n : setattr(self, 'permitted_actions', n.get_collection_of_primitive_values(str)),
            "permittedAttributes": lambda n : setattr(self, 'permitted_attributes', n.get_collection_of_primitive_values(str)),
            "rootCauseCategoryId": lambda n : setattr(self, 'root_cause_category_id', n.get_uuid_value()),
            "title": lambda n : setattr(self, 'title', n.get_str_value()),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_value()),
            "updatedBy": lambda n : setattr(self, 'updated_by', n.get_str_value()),
        }
        return fields
    
    def serialize(self,writer: SerializationWriter) -> None:
        """
        Serializes information the current object
        param writer: Serialization writer to use to serialize this model
        Returns: None
        """
        if writer is None:
            raise TypeError("writer cannot be null.")
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_str_value("createdBy", self.created_by)
        writer.write_datetime_value("deletedAt", self.deleted_at)
        writer.write_str_value("deletedBy", self.deleted_by)
        writer.write_uuid_value("id", self.id)
        writer.write_bool_value("isActive", self.is_active)
        writer.write_collection_of_primitive_values("permittedActions", self.permitted_actions)
        writer.write_collection_of_primitive_values("permittedAttributes", self.permitted_attributes)
        writer.write_uuid_value("rootCauseCategoryId", self.root_cause_category_id)
        writer.write_str_value("title", self.title)
        writer.write_datetime_value("updatedAt", self.updated_at)
        writer.write_str_value("updatedBy", self.updated_by)
    

