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 .with_custom_attribute_patch_request_body_data_type import WithCustomAttributePatchRequestBody_dataType
    from .with_custom_attribute_patch_request_body_default_value import WithCustomAttributePatchRequestBody_defaultValue

@dataclass
class WithCustomAttributePatchRequestBody(Parsable):
    # The data type that this custom attribute's value must take. Once set, the data type can't be changed.Possible values:- ``boolean``: ``true`` or ``false``- ``text``: a string- ``numeric``: a string that parses as a valid floating point number (not localized)- ``date``: an ISO8601 date string with no time, for example, ``2021-04-01``.- ``select``: a valid ID from the list of values defined by ``enumValues``.- ``multi_select``: an array of valid IDs from the list of values defined by ``enumValues``.
    data_type: Optional[WithCustomAttributePatchRequestBody_dataType] = None
    # The default value for this custom attribute if no value is specified on asset creation. If this field is notspecified, the custom attribute does not have a default value. The default value it takes can be any one ofthree possible value types, defined below.
    default_value: Optional[WithCustomAttributePatchRequestBody_defaultValue] = None
    # A description of the Asset custom attribute.Max length: 1000
    description: Optional[str] = None
    # The human-readable display name for the Asset custom attribute. This name appears when viewing the customattribute in the Assets UI, and must be unique within a project.Max length: 100
    display_name: Optional[str] = None
    # An array of string values that defines possible values that may be supplied when this custom attributes datatype (defined by ``dataType``) is set to ``select`` or ``multi_select``. This field is required when the datatype is set to ``select`` or ``multi_select``.
    enum_values: Optional[list[str]] = None
    # The maximum length that a text value can be for this custom attribute when creating or editing an asset.Setting a value for this field does not guarantee that existing or imported assets with this customattribute will have this attribute's value limited to this length. This field only applies when datatypeis set to ``text``. Default is ``250``, which is the maximum value this field can be set to.
    max_length_on_ingress: Optional[int] = None
    # Specifies whether or not this custom attribute is required when creating or editing an asset. If ``true``, thecustom attribute is required. If ``false``, it is not required. Setting this field to ``true`` does not guaranteethat existing or imported assets will have this custom attribute.
    required_on_ingress: Optional[bool] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithCustomAttributePatchRequestBody:
        """
        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: WithCustomAttributePatchRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithCustomAttributePatchRequestBody()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .with_custom_attribute_patch_request_body_data_type import WithCustomAttributePatchRequestBody_dataType
        from .with_custom_attribute_patch_request_body_default_value import WithCustomAttributePatchRequestBody_defaultValue

        from .with_custom_attribute_patch_request_body_data_type import WithCustomAttributePatchRequestBody_dataType
        from .with_custom_attribute_patch_request_body_default_value import WithCustomAttributePatchRequestBody_defaultValue

        fields: dict[str, Callable[[Any], None]] = {
            "dataType": lambda n : setattr(self, 'data_type', n.get_enum_value(WithCustomAttributePatchRequestBody_dataType)),
            "defaultValue": lambda n : setattr(self, 'default_value', n.get_object_value(WithCustomAttributePatchRequestBody_defaultValue)),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "displayName": lambda n : setattr(self, 'display_name', n.get_str_value()),
            "enumValues": lambda n : setattr(self, 'enum_values', n.get_collection_of_primitive_values(str)),
            "maxLengthOnIngress": lambda n : setattr(self, 'max_length_on_ingress', n.get_int_value()),
            "requiredOnIngress": lambda n : setattr(self, 'required_on_ingress', n.get_bool_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_enum_value("dataType", self.data_type)
        writer.write_object_value("defaultValue", self.default_value)
        writer.write_str_value("description", self.description)
        writer.write_str_value("displayName", self.display_name)
        writer.write_collection_of_primitive_values("enumValues", self.enum_values)
        writer.write_int_value("maxLengthOnIngress", self.max_length_on_ingress)
        writer.write_bool_value("requiredOnIngress", self.required_on_ingress)
    

