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

if TYPE_CHECKING:
    from .fields_get_response_type import FieldsGetResponse_type

@dataclass
class FieldsGetResponse(Parsable):
    # The property database attribute category, can be null.
    category: Optional[str] = None
    # The unique identifier for the attribute in file version.
    key: Optional[str] = None
    # The property database attribute name.
    name: Optional[str] = None
    # field data type.Possible values: ``Unknown``, ``Boolean``, ``Integer``, ``Double``, ``Blob``, ``DbKey``, ``String``, ``LocalizableString``, ``DateTime``, ``GeoLocation``, ``Position``
    type: Optional[FieldsGetResponse_type] = None
    # The property database attribute data type context or unit of measurement, e.g., ``m``, ``ft``, ``m^2``, ``kip/inch^2``.
    uom: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> FieldsGetResponse:
        """
        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: FieldsGetResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return FieldsGetResponse()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .fields_get_response_type import FieldsGetResponse_type

        from .fields_get_response_type import FieldsGetResponse_type

        fields: dict[str, Callable[[Any], None]] = {
            "category": lambda n : setattr(self, 'category', n.get_str_value()),
            "key": lambda n : setattr(self, 'key', n.get_str_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "type": lambda n : setattr(self, 'type', n.get_enum_value(FieldsGetResponse_type)),
            "uom": lambda n : setattr(self, 'uom', 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_str_value("category", self.category)
        writer.write_str_value("key", self.key)
        writer.write_str_value("name", self.name)
        writer.write_enum_value("type", self.type)
        writer.write_str_value("uom", self.uom)
    

