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 .assets_get_response_results_custom_attributes import AssetsGetResponse_results_customAttributes

@dataclass
class AssetsGetResponse_results(Parsable):
    # A string that lists a barcode value that may be assigned to the asset. The string uses whatever format your barcode system supports.
    barcode: Optional[str] = None
    # The ID of the category to which the asset belongs.
    category_id: Optional[str] = None
    # An identifying name for the asset such as ``laundry 220V outlet``. The name need not be unique, and shouldn't be confused with the asset 'id' field, which is created and assigned when the asset is created. This value appears as ``Asset ID`` in the Assets UI, and may sometimes be called ``Name`` in asset exports.
    client_asset_id: Optional[str] = None
    # The ID of the company to which the creating user belongs in the project.
    company_id: Optional[UUID] = None
    # The time when the component was created (ISO8601 Date time format in UTC).
    created_at: Optional[str] = None
    # The actor that created the component. This is an Autodesk / Oxygen ID.
    created_by: Optional[str] = None
    # An optional JSON dictionary specifying one or more custom attributes and values to be assigned to theasset. The custom attributes must belong to the set of custom attributes specified by the asset's category.The dictionary is a set of key:value pairs that each starts with the unique custom attribute name (not tobe confused with the custom attribute's display name) followed by the attribute value. The value must usethe data type defined by the attribute:For ``text``, the value is a string.For ``date``, the value is an ISO8601 date string with no time, for example, ``2020-04-10``.For ``select``, the value is a valid ID from the list of values defined for this custom attribute.For ``multi-select``, the value is an array of valid IDs from the list of values defined for this custom attribute.For ``boolean``, the value is a boolean.For ``numeric``, the value is a string that parses as a valid floating point number (not localized).
    custom_attributes: Optional[AssetsGetResponse_results_customAttributes] = None
    # The time when the component was deleted at (ISO8601 Date time format in UTC).
    deleted_at: Optional[str] = None
    # The actor that deleted the component. This is an Autodesk / Oxygen ID.
    deleted_by: Optional[str] = None
    # A brief description of the asset. Currently limited to ``1000`` characters.
    description: Optional[str] = None
    # The ID of the component.
    id: Optional[str] = None
    # A flag indicating whether the component is active or inactive (``isActive`` is ``true`` if-and-only-if ``deletedAt`` is empty).
    is_active: Optional[bool] = None
    # The ID of the location of the asset. This value is supplied through the Locations API.
    location_id: Optional[UUID] = None
    # The ID of the status assigned to the asset. The status must belong to the status set specified by the asset's category.
    status_id: Optional[UUID] = None
    # The time when the component was last updated (ISO8601 Date time format in UTC).
    updated_at: Optional[str] = None
    # The actor that last updated the component. This is an Autodesk / Oxygen ID.
    updated_by: Optional[str] = None
    # A global sequence number that is incremented any time a component of this type is created, updated, or deleted. If you cache components, you can use the version value to compare the cached component to the same component online to see if the component has been updated. If the online component has a higher version value, it has been updated.
    version: Optional[int] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> AssetsGetResponse_results:
        """
        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: AssetsGetResponse_results
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return AssetsGetResponse_results()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .assets_get_response_results_custom_attributes import AssetsGetResponse_results_customAttributes

        from .assets_get_response_results_custom_attributes import AssetsGetResponse_results_customAttributes

        fields: dict[str, Callable[[Any], None]] = {
            "barcode": lambda n : setattr(self, 'barcode', n.get_str_value()),
            "categoryId": lambda n : setattr(self, 'category_id', n.get_str_value()),
            "clientAssetId": lambda n : setattr(self, 'client_asset_id', n.get_str_value()),
            "companyId": lambda n : setattr(self, 'company_id', n.get_uuid_value()),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_str_value()),
            "createdBy": lambda n : setattr(self, 'created_by', n.get_str_value()),
            "customAttributes": lambda n : setattr(self, 'custom_attributes', n.get_object_value(AssetsGetResponse_results_customAttributes)),
            "deletedAt": lambda n : setattr(self, 'deleted_at', n.get_str_value()),
            "deletedBy": lambda n : setattr(self, 'deleted_by', n.get_str_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "id": lambda n : setattr(self, 'id', n.get_str_value()),
            "isActive": lambda n : setattr(self, 'is_active', n.get_bool_value()),
            "locationId": lambda n : setattr(self, 'location_id', n.get_uuid_value()),
            "statusId": lambda n : setattr(self, 'status_id', n.get_uuid_value()),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_str_value()),
            "updatedBy": lambda n : setattr(self, 'updated_by', n.get_str_value()),
            "version": lambda n : setattr(self, 'version', n.get_int_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("barcode", self.barcode)
        writer.write_str_value("categoryId", self.category_id)
        writer.write_str_value("clientAssetId", self.client_asset_id)
        writer.write_uuid_value("companyId", self.company_id)
        writer.write_str_value("createdAt", self.created_at)
        writer.write_str_value("createdBy", self.created_by)
        writer.write_object_value("customAttributes", self.custom_attributes)
        writer.write_str_value("deletedAt", self.deleted_at)
        writer.write_str_value("deletedBy", self.deleted_by)
        writer.write_str_value("description", self.description)
        writer.write_str_value("id", self.id)
        writer.write_bool_value("isActive", self.is_active)
        writer.write_uuid_value("locationId", self.location_id)
        writer.write_uuid_value("statusId", self.status_id)
        writer.write_str_value("updatedAt", self.updated_at)
        writer.write_str_value("updatedBy", self.updated_by)
        writer.write_int_value("version", self.version)
    

