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 .workflows_post_response_additional_options import WorkflowsPostResponse_additionalOptions
    from .workflows_post_response_approval_status_options import WorkflowsPostResponse_approvalStatusOptions
    from .workflows_post_response_attached_attributes import WorkflowsPostResponse_attachedAttributes
    from .workflows_post_response_copy_files_options import WorkflowsPostResponse_copyFilesOptions
    from .workflows_post_response_status import WorkflowsPostResponse_status
    from .workflows_post_response_steps import WorkflowsPostResponse_steps
    from .workflows_post_response_update_attributes_options import WorkflowsPostResponse_updateAttributesOptions

@dataclass
class WorkflowsPostResponse(Parsable):
    # Workflow-level settings that control whether the initiator can modify certain fields when starting a review.
    additional_options: Optional[WorkflowsPostResponse_additionalOptions] = None
    # A list of approval status options defined for this workflow.It includes two built-in options by default (typically ``APPROVED`` and ``REJECTED``), and may also include custom statuses added by the user.
    approval_status_options: Optional[list[WorkflowsPostResponse_approvalStatusOptions]] = None
    # (``Update Attributes`` in the UI)The list of attributes added in the ``Update Attributes`` action.These attributes will be applied to the approved files in the target folder, or optionally also in the source folder depending on the configuration.
    attached_attributes: Optional[list[WorkflowsPostResponse_attachedAttributes]] = None
    # (``Copy approved files`` in the UI) The configuration for copying approved files to a target folder when the review is complete.
    copy_files_options: Optional[WorkflowsPostResponse_copyFilesOptions] = None
    # The date and time when the workflow was created.
    created_at: Optional[datetime.datetime] = None
    # A description of the workflow.Max length: 4096
    description: Optional[str] = None
    # The unique identifier of the approval workflow returned in the response.This ID can be used in subsequent API calls to reference this workflow.
    id: Optional[UUID] = None
    # The name of the workflow. It must be unique within the project.Max length: 255
    name: Optional[str] = None
    # A custom note associated with the workflow. Visible to all reviewers during the review process.Max length: 4096
    notes: Optional[str] = None
    # The current status of the approval workflow. Possible values:``ACTIVE``: the workflow is active and available for use.``INACTIVE``: the workflow has been deactivated and cannot be used to create new reviews.
    status: Optional[WorkflowsPostResponse_status] = None
    # A list of steps defined in the approval workflow. Each step defines who reviews the files, how long they have, and whether it involves multiple reviewers.
    steps: Optional[list[WorkflowsPostResponse_steps]] = None
    # The configuration for applying attribute updates when a review is completed.This applies only if the workflow includes a file copy action and the ``Update Attributes`` action is enabled.
    update_attributes_options: Optional[WorkflowsPostResponse_updateAttributesOptions] = None
    # The date and time when the workflow was last updated.
    updated_at: Optional[datetime.datetime] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WorkflowsPostResponse:
        """
        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: WorkflowsPostResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WorkflowsPostResponse()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .workflows_post_response_additional_options import WorkflowsPostResponse_additionalOptions
        from .workflows_post_response_approval_status_options import WorkflowsPostResponse_approvalStatusOptions
        from .workflows_post_response_attached_attributes import WorkflowsPostResponse_attachedAttributes
        from .workflows_post_response_copy_files_options import WorkflowsPostResponse_copyFilesOptions
        from .workflows_post_response_status import WorkflowsPostResponse_status
        from .workflows_post_response_steps import WorkflowsPostResponse_steps
        from .workflows_post_response_update_attributes_options import WorkflowsPostResponse_updateAttributesOptions

        from .workflows_post_response_additional_options import WorkflowsPostResponse_additionalOptions
        from .workflows_post_response_approval_status_options import WorkflowsPostResponse_approvalStatusOptions
        from .workflows_post_response_attached_attributes import WorkflowsPostResponse_attachedAttributes
        from .workflows_post_response_copy_files_options import WorkflowsPostResponse_copyFilesOptions
        from .workflows_post_response_status import WorkflowsPostResponse_status
        from .workflows_post_response_steps import WorkflowsPostResponse_steps
        from .workflows_post_response_update_attributes_options import WorkflowsPostResponse_updateAttributesOptions

        fields: dict[str, Callable[[Any], None]] = {
            "additionalOptions": lambda n : setattr(self, 'additional_options', n.get_object_value(WorkflowsPostResponse_additionalOptions)),
            "approvalStatusOptions": lambda n : setattr(self, 'approval_status_options', n.get_collection_of_object_values(WorkflowsPostResponse_approvalStatusOptions)),
            "attachedAttributes": lambda n : setattr(self, 'attached_attributes', n.get_collection_of_object_values(WorkflowsPostResponse_attachedAttributes)),
            "copyFilesOptions": lambda n : setattr(self, 'copy_files_options', n.get_object_value(WorkflowsPostResponse_copyFilesOptions)),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "id": lambda n : setattr(self, 'id', n.get_uuid_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "notes": lambda n : setattr(self, 'notes', n.get_str_value()),
            "status": lambda n : setattr(self, 'status', n.get_enum_value(WorkflowsPostResponse_status)),
            "steps": lambda n : setattr(self, 'steps', n.get_collection_of_object_values(WorkflowsPostResponse_steps)),
            "updateAttributesOptions": lambda n : setattr(self, 'update_attributes_options', n.get_object_value(WorkflowsPostResponse_updateAttributesOptions)),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_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_object_value("additionalOptions", self.additional_options)
        writer.write_collection_of_object_values("approvalStatusOptions", self.approval_status_options)
        writer.write_collection_of_object_values("attachedAttributes", self.attached_attributes)
        writer.write_object_value("copyFilesOptions", self.copy_files_options)
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_str_value("description", self.description)
        writer.write_uuid_value("id", self.id)
        writer.write_str_value("name", self.name)
        writer.write_str_value("notes", self.notes)
        writer.write_enum_value("status", self.status)
        writer.write_collection_of_object_values("steps", self.steps)
        writer.write_object_value("updateAttributesOptions", self.update_attributes_options)
        writer.write_datetime_value("updatedAt", self.updated_at)
    

