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_attachments_attachment_type import AttachmentsPostResponse_attachments_attachmentType

@dataclass
class AttachmentsPostResponse_attachments(Parsable):
    # The unique identifier for the attachment, set by the client when creating the attachment reference. This can be any unique GUID, but it is recommended to use the OSS storage GUID.
    attachment_id: Optional[UUID] = None
    # The type of attachment. For issue attachments, this value is always ``issue-attachment``. Will always be: ``issue-attachment``
    attachment_type: Optional[AttachmentsPostResponse_attachments_attachmentType] = None
    # Not relevant
    bubble_urn: Optional[str] = None
    # The ID of the user who created the issue attachment. For details about the user, call `GET users </en/docs/acc/v1/reference/http/admin-projectsprojectId-users-GET/>`_.
    created_by: Optional[str] = None
    # The date and time when the issue attachment was created, in ISO8601 format.
    created_on: Optional[datetime.datetime] = None
    # The ID of the user who deleted the issue attachment, if applicable. For details about the user, call `GET users </en/docs/acc/v1/reference/http/admin-projectsprojectId-users-GET/>`_.
    deleted_by: Optional[str] = None
    # The date and time when the issue attachment was deleted, if applicable.
    deleted_on: Optional[datetime.datetime] = None
    # The human-readable display name for the attachment, including the file extension (for example, ``.pdf``, ``.jpg``, ``.dwg``). This name appears in the ACC web UI and is used when downloading the file from the issue.
    display_name: Optional[str] = None
    # The ID of the issue that owns the attachment.
    domain_entity_id: Optional[UUID] = None
    # The unique filename of the attachment, as stored in Autodesk Docs (OSS).This is the name assigned to the uploaded file in the system, typically formatted as {attachmentId}.{fileExtension}.
    file_name: Optional[str] = None
    # The size of the file in bytes.
    file_size: Optional[int] = None
    # The file extension (without the dot), for example ``pdf`` or ``jpg``.
    file_type: Optional[str] = None
    # ``true``: The attachment has been deleted.``false``: (default) The attachment has not been deleted.
    is_deleted: Optional[bool] = None
    # The document lineage URN for the attachment’s source file.
    lineage_urn: Optional[str] = None
    # Not relevant
    modified_by: Optional[str] = None
    # Not relevant
    modified_on: Optional[datetime.datetime] = None
    # The Object Storage Service (OSS) URN identifying where the attachment file is stored in Autodesk’s cloud infrastructure. Use this value when downloading the file (see the Download Issue Attachment </en/docs/acc/v1/tutorials/issues/download-issue-attachments/>_ tutorial).
    storage_urn: Optional[str] = None
    # The URN for the latest (tip) version of the file.
    tip_version_urn: Optional[str] = None
    # The document version number.
    version: Optional[int] = None
    # The URN for the specific file version that was attached to the issue. This may differ from the latest version URN (``tipVersionUrn``) if a newer version of the file exists in Autodesk Docs.
    version_urn: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> AttachmentsPostResponse_attachments:
        """
        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_attachments
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return AttachmentsPostResponse_attachments()
    
    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_attachments_attachment_type import AttachmentsPostResponse_attachments_attachmentType

        from .attachments_post_response_attachments_attachment_type import AttachmentsPostResponse_attachments_attachmentType

        fields: dict[str, Callable[[Any], None]] = {
            "attachmentId": lambda n : setattr(self, 'attachment_id', n.get_uuid_value()),
            "attachmentType": lambda n : setattr(self, 'attachment_type', n.get_enum_value(AttachmentsPostResponse_attachments_attachmentType)),
            "bubbleUrn": lambda n : setattr(self, 'bubble_urn', n.get_str_value()),
            "createdBy": lambda n : setattr(self, 'created_by', n.get_str_value()),
            "createdOn": lambda n : setattr(self, 'created_on', n.get_datetime_value()),
            "deletedBy": lambda n : setattr(self, 'deleted_by', n.get_str_value()),
            "deletedOn": lambda n : setattr(self, 'deleted_on', n.get_datetime_value()),
            "displayName": lambda n : setattr(self, 'display_name', n.get_str_value()),
            "domainEntityId": lambda n : setattr(self, 'domain_entity_id', n.get_uuid_value()),
            "fileName": lambda n : setattr(self, 'file_name', n.get_str_value()),
            "fileSize": lambda n : setattr(self, 'file_size', n.get_int_value()),
            "fileType": lambda n : setattr(self, 'file_type', n.get_str_value()),
            "isDeleted": lambda n : setattr(self, 'is_deleted', n.get_bool_value()),
            "lineageUrn": lambda n : setattr(self, 'lineage_urn', n.get_str_value()),
            "modifiedBy": lambda n : setattr(self, 'modified_by', n.get_str_value()),
            "modifiedOn": lambda n : setattr(self, 'modified_on', n.get_datetime_value()),
            "storageUrn": lambda n : setattr(self, 'storage_urn', n.get_str_value()),
            "tipVersionUrn": lambda n : setattr(self, 'tip_version_urn', n.get_str_value()),
            "version": lambda n : setattr(self, 'version', n.get_int_value()),
            "versionUrn": lambda n : setattr(self, 'version_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("attachmentId", self.attachment_id)
        writer.write_enum_value("attachmentType", self.attachment_type)
        writer.write_str_value("bubbleUrn", self.bubble_urn)
        writer.write_str_value("createdBy", self.created_by)
        writer.write_datetime_value("createdOn", self.created_on)
        writer.write_str_value("deletedBy", self.deleted_by)
        writer.write_datetime_value("deletedOn", self.deleted_on)
        writer.write_str_value("displayName", self.display_name)
        writer.write_uuid_value("domainEntityId", self.domain_entity_id)
        writer.write_str_value("fileName", self.file_name)
        writer.write_int_value("fileSize", self.file_size)
        writer.write_str_value("fileType", self.file_type)
        writer.write_bool_value("isDeleted", self.is_deleted)
        writer.write_str_value("lineageUrn", self.lineage_urn)
        writer.write_str_value("modifiedBy", self.modified_by)
        writer.write_datetime_value("modifiedOn", self.modified_on)
        writer.write_str_value("storageUrn", self.storage_urn)
        writer.write_str_value("tipVersionUrn", self.tip_version_urn)
        writer.write_int_value("version", self.version)
        writer.write_str_value("versionUrn", self.version_urn)
    

