from __future__ import annotations
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

if TYPE_CHECKING:
    from .properties_get_response_type import PropertiesGetResponse_type

@dataclass
class PropertiesGetResponse(Parsable):
    # A true/false flag to indicate whether this is a pre-defined attribute or not.
    built_in: Optional[bool] = None
    # Not relevant
    category: Optional[str] = None
    # Custom attribute belongs to the component template
    component_template_id: Optional[str] = None
    # Default value of the attribute definition.
    default_value: Optional[str] = None
    # A true/false flag to indicate whether this attribute should be shown in the BIM 360 Cost Management or generated documents by default.
    default_visibility: Optional[bool] = None
    # Unique identifier (UUID) of the attribute definition.
    id: Optional[UUID] = None
    # Name of a attribute definition.Max length: 1024
    name: Optional[str] = None
    # List of items for an ``options`` type attribute.
    options: Optional[list[str]] = None
    # The position of the attribute definition as displayed in BIM 360 Cost Management.
    position: Optional[float] = None
    # Type of the attribute definition.Possible values: ``text``, ``multiline``, ``richtext``, ``options``, ``boolean``, ``integer``, ``percent``, ``currency``, ``number``, ``datetime``
    type: Optional[PropertiesGetResponse_type] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> PropertiesGetResponse:
        """
        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: PropertiesGetResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return PropertiesGetResponse()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .properties_get_response_type import PropertiesGetResponse_type

        from .properties_get_response_type import PropertiesGetResponse_type

        fields: dict[str, Callable[[Any], None]] = {
            "builtIn": lambda n : setattr(self, 'built_in', n.get_bool_value()),
            "category": lambda n : setattr(self, 'category', n.get_str_value()),
            "componentTemplateId": lambda n : setattr(self, 'component_template_id', n.get_str_value()),
            "defaultValue": lambda n : setattr(self, 'default_value', n.get_str_value()),
            "defaultVisibility": lambda n : setattr(self, 'default_visibility', n.get_bool_value()),
            "id": lambda n : setattr(self, 'id', n.get_uuid_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "options": lambda n : setattr(self, 'options', n.get_collection_of_primitive_values(str)),
            "position": lambda n : setattr(self, 'position', n.get_float_value()),
            "type": lambda n : setattr(self, 'type', n.get_enum_value(PropertiesGetResponse_type)),
        }
        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_bool_value("builtIn", self.built_in)
        writer.write_str_value("category", self.category)
        writer.write_str_value("componentTemplateId", self.component_template_id)
        writer.write_str_value("defaultValue", self.default_value)
        writer.write_bool_value("defaultVisibility", self.default_visibility)
        writer.write_uuid_value("id", self.id)
        writer.write_str_value("name", self.name)
        writer.write_collection_of_primitive_values("options", self.options)
        writer.write_float_value("position", self.position)
        writer.write_enum_value("type", self.type)
    

