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_async_state import AttachmentsPostResponse_asyncState
    from .attachments_post_response_category_id import AttachmentsPostResponse_categoryId
    from .attachments_post_response_permitted_actions import AttachmentsPostResponse_permittedActions
    from .attachments_post_response_urn_type_id import AttachmentsPostResponse_urnTypeId

@dataclass
class AttachmentsPostResponse(Parsable):
    # Represents the state of the asynchronous process triggered after marking the file upload as complete (``isFileUploaded=true``). The backend initiates this process to generate the ``URN`` for the attachment.Possible values:- ``1`` - Pending (the request is queued and awaiting processing).- ``2`` - Started (the backend process to generate the ``URN`` has begun).- ``3`` - Success (the ``URN`` was successfully created).- ``4`` - Failure (the process failed, and the ``URN`` was not created).
    async_state: Optional[AttachmentsPostResponse_asyncState] = None
    # The workflow state of the submittal item associated with the attachment.- ``Category IDs 1-4``: These represent active workflow states and can be set when creating an attachment.- ``Category IDs 5-8``: These represent historical records of attachments from earlier revisions of the submittal process and are automatically assigned by the system.Possible values:- ``1`` (Submission)- ``2`` (For Review)- ``3`` (Review Response)- ``4`` (Final Response)- ``5`` (Previous Submission)- ``6`` (Previous For Review)- ``7`` (Previous Review Response)- ``8`` (Previous Final Response)
    category_id: Optional[AttachmentsPostResponse_categoryId] = None
    # The date and time when the attachment created, in ISO 8601 format. For example, ``2018-02-01T12:09:24.198466Z``.
    created_at: Optional[datetime.datetime] = None
    # The Autodesk ID of the user who created the attachment.
    created_by: Optional[str] = None
    # The UUID of the source file the attachment was duplicated from. This indicates that the attachment was created as a copy of an existing file, preserving its metadata and association with the original file.
    duplicated_from: Optional[UUID] = None
    # The internal, globally unique identifier (UUID) for the attachment.
    id: Optional[UUID] = None
    # Indicates whether the attachment upload is complete.``true``: the attachment upload is complete.``false``: the upload is still in progress or pending completion.
    is_file_uploaded: Optional[bool] = None
    # The ID of the submittal item associated with the attachment.
    item_id: Optional[UUID] = None
    # The user-defined name of the attachment. This value is specified when the attachment is created and may differ from the original file name.
    name: Optional[str] = None
    # A list of actions that the user is allowed to perform on the attachment.
    permitted_actions: Optional[list[AttachmentsPostResponse_permittedActions]] = None
    # Not relevant
    resource_urns: Optional[str] = None
    # Not relevant
    revision: Optional[int] = None
    # Not relevant
    revision_folder_urn: Optional[str] = None
    # The ID of the task within the review step to which the attachment is associated.- If the attachment was added to a review step, this field contains the task ID that identifies the relevant task.- If the attachment was not part of a review, this field is ``null``.
    task_id: Optional[UUID] = None
    # The date and time the attachment was last updated, in ISO 8601 format. For example, ``2018-02-01T12:09:24.198466Z``.
    updated_at: Optional[datetime.datetime] = None
    # The Autodesk ID of the user who last updated the attachment.
    updated_by: Optional[str] = None
    # The unique identifier for the upload session associated with the attachment applicable only to local file uploads. This value is used to generate a URL for uploading the actual file.
    upload_urn: Optional[str] = None
    # Not relevant
    url: Optional[str] = None
    # The unique identifier for a specific file version in the Files tool.
    urn: Optional[str] = None
    # Not relevant
    urn_page: Optional[str] = None
    # Specifies the type of urn associated with the attachment. This value identifies the storage type for the file reference.Possible values: ``2``This value is always set to ``2`` for both local and Files tool attachments.
    urn_type_id: Optional[AttachmentsPostResponse_urnTypeId] = None
    # The version number of the file in Autodesk Docs.
    urn_version: Optional[int] = 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_async_state import AttachmentsPostResponse_asyncState
        from .attachments_post_response_category_id import AttachmentsPostResponse_categoryId
        from .attachments_post_response_permitted_actions import AttachmentsPostResponse_permittedActions
        from .attachments_post_response_urn_type_id import AttachmentsPostResponse_urnTypeId

        from .attachments_post_response_async_state import AttachmentsPostResponse_asyncState
        from .attachments_post_response_category_id import AttachmentsPostResponse_categoryId
        from .attachments_post_response_permitted_actions import AttachmentsPostResponse_permittedActions
        from .attachments_post_response_urn_type_id import AttachmentsPostResponse_urnTypeId

        fields: dict[str, Callable[[Any], None]] = {
            "asyncState": lambda n : setattr(self, 'async_state', n.get_enum_value(AttachmentsPostResponse_asyncState)),
            "categoryId": lambda n : setattr(self, 'category_id', n.get_enum_value(AttachmentsPostResponse_categoryId)),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "createdBy": lambda n : setattr(self, 'created_by', n.get_str_value()),
            "duplicatedFrom": lambda n : setattr(self, 'duplicated_from', n.get_uuid_value()),
            "id": lambda n : setattr(self, 'id', n.get_uuid_value()),
            "isFileUploaded": lambda n : setattr(self, 'is_file_uploaded', n.get_bool_value()),
            "itemId": lambda n : setattr(self, 'item_id', n.get_uuid_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "permittedActions": lambda n : setattr(self, 'permitted_actions', n.get_collection_of_object_values(AttachmentsPostResponse_permittedActions)),
            "resourceUrns": lambda n : setattr(self, 'resource_urns', n.get_str_value()),
            "revision": lambda n : setattr(self, 'revision', n.get_int_value()),
            "revisionFolderUrn": lambda n : setattr(self, 'revision_folder_urn', n.get_str_value()),
            "taskId": lambda n : setattr(self, 'task_id', n.get_uuid_value()),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_value()),
            "updatedBy": lambda n : setattr(self, 'updated_by', n.get_str_value()),
            "uploadUrn": lambda n : setattr(self, 'upload_urn', n.get_str_value()),
            "url": lambda n : setattr(self, 'url', n.get_str_value()),
            "urn": lambda n : setattr(self, 'urn', n.get_str_value()),
            "urnPage": lambda n : setattr(self, 'urn_page', n.get_str_value()),
            "urnTypeId": lambda n : setattr(self, 'urn_type_id', n.get_enum_value(AttachmentsPostResponse_urnTypeId)),
            "urnVersion": lambda n : setattr(self, 'urn_version', n.get_int_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("asyncState", self.async_state)
        writer.write_enum_value("categoryId", self.category_id)
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_str_value("createdBy", self.created_by)
        writer.write_uuid_value("duplicatedFrom", self.duplicated_from)
        writer.write_uuid_value("id", self.id)
        writer.write_bool_value("isFileUploaded", self.is_file_uploaded)
        writer.write_uuid_value("itemId", self.item_id)
        writer.write_str_value("name", self.name)
        writer.write_collection_of_object_values("permittedActions", self.permitted_actions)
        writer.write_str_value("resourceUrns", self.resource_urns)
        writer.write_int_value("revision", self.revision)
        writer.write_str_value("revisionFolderUrn", self.revision_folder_urn)
        writer.write_uuid_value("taskId", self.task_id)
        writer.write_datetime_value("updatedAt", self.updated_at)
        writer.write_str_value("updatedBy", self.updated_by)
        writer.write_str_value("uploadUrn", self.upload_urn)
        writer.write_str_value("url", self.url)
        writer.write_str_value("urn", self.urn)
        writer.write_str_value("urnPage", self.urn_page)
        writer.write_enum_value("urnTypeId", self.urn_type_id)
        writer.write_int_value("urnVersion", self.urn_version)
    

