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 .sub_cost_items_copy_post_request_body_from import SubCostItemsCopyPostRequestBody_from
    from .sub_cost_items_copy_post_request_body_source import SubCostItemsCopyPostRequestBody_source
    from .sub_cost_items_copy_post_request_body_to import SubCostItemsCopyPostRequestBody_to

@dataclass
class SubCostItemsCopyPostRequestBody(Parsable):
    # The type of the sub cost items being copied. Note that ``contract`` and ``budget`` can only be used as a source type, not a destination. Possible values: ``contract``, ``budget``, ``estimated``, ``proposed``, ``submitted``, ``approved``, ``committed``.
    from_: Optional[SubCostItemsCopyPostRequestBody_from] = None
    # The source object defining where sub-cost items are copied from. When copying from a ``budget`` or ``contract``, this must include one or more source IDs.
    source: Optional[list[SubCostItemsCopyPostRequestBody_source]] = None
    # The type to which the sub cost items are copied. Note that ``contract`` and ``budget`` cannot be used as a destination. Possible values: ``estimated``, ``proposed``, ``submitted``, ``approved``, ``committed``.
    to: Optional[SubCostItemsCopyPostRequestBody_to] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> SubCostItemsCopyPostRequestBody:
        """
        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: SubCostItemsCopyPostRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return SubCostItemsCopyPostRequestBody()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .sub_cost_items_copy_post_request_body_from import SubCostItemsCopyPostRequestBody_from
        from .sub_cost_items_copy_post_request_body_source import SubCostItemsCopyPostRequestBody_source
        from .sub_cost_items_copy_post_request_body_to import SubCostItemsCopyPostRequestBody_to

        from .sub_cost_items_copy_post_request_body_from import SubCostItemsCopyPostRequestBody_from
        from .sub_cost_items_copy_post_request_body_source import SubCostItemsCopyPostRequestBody_source
        from .sub_cost_items_copy_post_request_body_to import SubCostItemsCopyPostRequestBody_to

        fields: dict[str, Callable[[Any], None]] = {
            "from": lambda n : setattr(self, 'from_', n.get_enum_value(SubCostItemsCopyPostRequestBody_from)),
            "source": lambda n : setattr(self, 'source', n.get_collection_of_object_values(SubCostItemsCopyPostRequestBody_source)),
            "to": lambda n : setattr(self, 'to', n.get_enum_value(SubCostItemsCopyPostRequestBody_to)),
        }
        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("from", self.from_)
        writer.write_collection_of_object_values("source", self.source)
        writer.write_enum_value("to", self.to)
    

