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_category_id import AttachmentsPostRequestBody_categoryId
    from .attachments_post_request_body_urn_type_id import AttachmentsPostRequestBody_urnTypeId

@dataclass
class AttachmentsPostRequestBody(Parsable):
    # Specifies the workflow state of the submittal item associated with the attachment. If omitted, the system assigns one based on the current state.Note that you can only set category IDs ``1``-``4`` when adding an attachment. Category IDs ``5``-``8`` are system-generated and appear in responses for historical records.In some cases, you must manually set ``categoryId``:1. Subcontractor Submissions:When a subcontractor creates an item in the ``Open (Submitted) - (mgr-1)`` state,  set ``categoryId`` to ``1`` (**Submission**) instead of ``2`` (**For Review**).2. Final Response in Non-Standard Closures:When closing an item from a state other than ``Open (Reviewed) - (mgr-2)``, set ``categoryId`` to ``4`` (**Final Response**) if uploading a final response.Possible values:- ``1``: **Submission** – Initial submission.- ``2``: **For Review** – Submitted and awaiting review.- ``3``: **Review Response** – A response provided during review.- ``4``: **Final Response** – The final response in the submittal workflow.To retrieve the list of available category ID values, call `GET metadata </en/docs/acc/v1/reference/http/submittals-metadata-GET/>`_ and refer to the attachment categories list in the response.
    category_id: Optional[AttachmentsPostRequestBody_categoryId] = None
    # Specifies whether the attachment upload has been completed. This value controls how the system processes the attachment.- ``true``: if the attachment is complete.- ``false``: if the attachment is still in progress.Behavior:- For local file uploads: The system initially considers the file as not uploaded (``false``). After completing the upload, you must set ``isFileUploaded: true`` using `PATCH attachments/:id </en/docs/acc/v1/reference/http/submittals-attachments-attachmentId-PATCH/>`_ to allow the system to process the attachment.- For Files tool attachments: Always set to ``true`` since the file was uploaded earlier.This field cannot be explicitly set to ``false`` in the request. If omitted, it defaults to ``false``.
    is_file_uploaded: Optional[bool] = None
    # The user-defined name for the attachment. This value does not need to match the actual file name. For example, ``design-review.pdf`` or ``Design Review``.- Spaces are allowed in the name.- The following characters are not supported: ``/``, ``n``, ``r``, ``t``, ``0``, ``f``, ``?``, ``*``, ````, ``<``, ``>``, ``|``, ``:``.
    name: Optional[str] = None
    # The ID of the task within the review step that the attachment is associated with. The task ID identifies the specific task in the review process where the attachment belongs.This field is only required when the submittal item is in the **Review (``rev``)** state.To retrieve the task ID, call `Get tasks </en/docs/acc/v1/reference/http/submittals-tasks-GET/>`_.
    task_id: Optional[UUID] = None
    # The unique identifier for the file version in the Files tool. This field is required for referencing a specific file version when attaching a file from the Files tool.This field is not applicable for local file uploads.When attaching a file from the Files tool, both ``urn`` and ``urnTypeId`` must be provided.
    urn: Optional[str] = None
    # Specifies the type of URN associated with the attachment.Possible values: ``2``
    urn_type_id: Optional[AttachmentsPostRequestBody_urnTypeId] = 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_category_id import AttachmentsPostRequestBody_categoryId
        from .attachments_post_request_body_urn_type_id import AttachmentsPostRequestBody_urnTypeId

        from .attachments_post_request_body_category_id import AttachmentsPostRequestBody_categoryId
        from .attachments_post_request_body_urn_type_id import AttachmentsPostRequestBody_urnTypeId

        fields: dict[str, Callable[[Any], None]] = {
            "categoryId": lambda n : setattr(self, 'category_id', n.get_enum_value(AttachmentsPostRequestBody_categoryId)),
            "isFileUploaded": lambda n : setattr(self, 'is_file_uploaded', n.get_bool_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "taskId": lambda n : setattr(self, 'task_id', n.get_uuid_value()),
            "urn": lambda n : setattr(self, 'urn', n.get_str_value()),
            "urnTypeId": lambda n : setattr(self, 'urn_type_id', n.get_enum_value(AttachmentsPostRequestBody_urnTypeId)),
        }
        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("categoryId", self.category_id)
        writer.write_bool_value("isFileUploaded", self.is_file_uploaded)
        writer.write_str_value("name", self.name)
        writer.write_uuid_value("taskId", self.task_id)
        writer.write_str_value("urn", self.urn)
        writer.write_enum_value("urnTypeId", self.urn_type_id)
    

