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 .attachments_post_request_body_attachments import AttachmentsPostRequestBody_attachments

@dataclass
class AttachmentsPostRequestBody(Parsable):
    # A list of attachments to add to the issue.
    attachments: Optional[list[AttachmentsPostRequestBody_attachments]] = None
    # The unique identifier of the issue to which the attachments will be added.
    domain_entity_id: Optional[UUID] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> AttachmentsPostRequestBody:
        """
        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: AttachmentsPostRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return AttachmentsPostRequestBody()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .attachments_post_request_body_attachments import AttachmentsPostRequestBody_attachments

        from .attachments_post_request_body_attachments import AttachmentsPostRequestBody_attachments

        fields: dict[str, Callable[[Any], None]] = {
            "attachments": lambda n : setattr(self, 'attachments', n.get_collection_of_object_values(AttachmentsPostRequestBody_attachments)),
            "domainEntityId": lambda n : setattr(self, 'domain_entity_id', n.get_uuid_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_collection_of_object_values("attachments", self.attachments)
        writer.write_uuid_value("domainEntityId", self.domain_entity_id)
    

