from __future__ import annotations
import datetime
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_response_association_type import AttachmentsPostResponse_associationType
    from .attachments_post_response_type import AttachmentsPostResponse_type

@dataclass
class AttachmentsPostResponse(Parsable):
    # The object ID of the item associated with the actions, such as a budget, contract, or cost item.
    association_id: Optional[UUID] = None
    # The type of item to which it is associated.Possible values: ``Budget``, ``Contract``, ``ScheduleOfValue``, ``FormInstance``, ``CostItem``, ``Payment``, ``MainContract``, ``BudgetPayment``, ``Expense``, ``CostPayment``, ``ExpenseItem``, ``PaymentItem``, ``OCO``, ``RCO``, ``SCO``, ``PCO``, ``RFQ``, ``DistributionItem``, ``BudgetTransfer``, ``Fee``
    association_type: Optional[AttachmentsPostResponse_associationType] = None
    # The date and time that the item was created, in ISO 8601 format.
    created_at: Optional[datetime.datetime] = None
    # The unique identifier (UUID) of the folder named ``attachment-folder`` where the attachment is stored. This ID is automatically retrieved by the backend and returned in the response.
    folder_id: Optional[UUID] = None
    # The unique auto-generated identifier of the attachment.
    id: Optional[UUID] = None
    # The name of the attachment.Max length: 1024
    name: Optional[str] = None
    # Not relevant
    pdf_oss_urn: Optional[str] = None
    # Not relevant
    pdf_urn: Optional[str] = None
    # Determines whether an existing attachment with a matching name should be replaced.
    replace_if_exists: Optional[bool] = None
    # The status of the attachment.Max length: 1024
    status: Optional[str] = None
    # The type of attachment.Possible values:``Upload``: is a locally uploaded file.``DocsFile`` is a file referenced from BIM 360 Docs.``Reference`` is a file referenced form report.``Document`` is for document generation.Max length: 64
    type: Optional[AttachmentsPostResponse_type] = None
    # The date and time that the item was last updated, in ISO 8601 format.
    updated_at: Optional[datetime.datetime] = None
    # The object version URN of the attachment in the Autodesk Data Management service.
    urn: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> AttachmentsPostResponse:
        """
        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: AttachmentsPostResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return AttachmentsPostResponse()
    
    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_response_association_type import AttachmentsPostResponse_associationType
        from .attachments_post_response_type import AttachmentsPostResponse_type

        from .attachments_post_response_association_type import AttachmentsPostResponse_associationType
        from .attachments_post_response_type import AttachmentsPostResponse_type

        fields: dict[str, Callable[[Any], None]] = {
            "associationId": lambda n : setattr(self, 'association_id', n.get_uuid_value()),
            "associationType": lambda n : setattr(self, 'association_type', n.get_enum_value(AttachmentsPostResponse_associationType)),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "folderId": lambda n : setattr(self, 'folder_id', n.get_uuid_value()),
            "id": lambda n : setattr(self, 'id', n.get_uuid_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "pdfOssUrn": lambda n : setattr(self, 'pdf_oss_urn', n.get_str_value()),
            "pdfUrn": lambda n : setattr(self, 'pdf_urn', n.get_str_value()),
            "replaceIfExists": lambda n : setattr(self, 'replace_if_exists', n.get_bool_value()),
            "status": lambda n : setattr(self, 'status', n.get_str_value()),
            "type": lambda n : setattr(self, 'type', n.get_enum_value(AttachmentsPostResponse_type)),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_value()),
            "urn": lambda n : setattr(self, 'urn', 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_uuid_value("associationId", self.association_id)
        writer.write_enum_value("associationType", self.association_type)
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_uuid_value("folderId", self.folder_id)
        writer.write_uuid_value("id", self.id)
        writer.write_str_value("name", self.name)
        writer.write_str_value("pdfOssUrn", self.pdf_oss_urn)
        writer.write_str_value("pdfUrn", self.pdf_urn)
        writer.write_bool_value("replaceIfExists", self.replace_if_exists)
        writer.write_str_value("status", self.status)
        writer.write_enum_value("type", self.type)
        writer.write_datetime_value("updatedAt", self.updated_at)
        writer.write_str_value("urn", self.urn)
    

