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

if TYPE_CHECKING:
    from .action_histories_get_response_results_operator import ActionHistoriesGetResponse_results_operator
    from .action_histories_get_response_results_options import ActionHistoriesGetResponse_results_options

@dataclass
class ActionHistoriesGetResponse_results(Parsable):
    # The specific action that occurred (e.g., ``review:proceed``, ``submitted``, ``rejected``).
    action: Optional[str] = None
    # The ID of the object associated with the action history.
    association_id: Optional[str] = None
    # The type of object associated with the action history (e.g., ``Contract``, ``SCO``)
    association_type: Optional[str] = None
    # The timestamp when the action occurred.
    created_at: Optional[datetime.datetime] = None
    # Information about the user who performed the action.
    operator: Optional[ActionHistoriesGetResponse_results_operator] = None
    # Additional context for the action. The fields present in this object depend on the action history type.For Approval workflows, the object includes:``stepName`` – the name of the workflow step.``taskDefinitionKey`` – the key that identifies the workflow task.``workflowInstanceId`` – the ID of the workflow instance.These fields provide task-level process information.For Normal workflows, the object may include fields such as to and from that indicate a change in status.
    options: Optional[ActionHistoriesGetResponse_results_options] = None
    # The category of the action history. Possible values: ``Approval``, ``Normal``.
    type: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> ActionHistoriesGetResponse_results:
        """
        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: ActionHistoriesGetResponse_results
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return ActionHistoriesGetResponse_results()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .action_histories_get_response_results_operator import ActionHistoriesGetResponse_results_operator
        from .action_histories_get_response_results_options import ActionHistoriesGetResponse_results_options

        from .action_histories_get_response_results_operator import ActionHistoriesGetResponse_results_operator
        from .action_histories_get_response_results_options import ActionHistoriesGetResponse_results_options

        fields: dict[str, Callable[[Any], None]] = {
            "action": lambda n : setattr(self, 'action', n.get_str_value()),
            "associationId": lambda n : setattr(self, 'association_id', n.get_str_value()),
            "associationType": lambda n : setattr(self, 'association_type', n.get_str_value()),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "operator": lambda n : setattr(self, 'operator', n.get_object_value(ActionHistoriesGetResponse_results_operator)),
            "options": lambda n : setattr(self, 'options', n.get_object_value(ActionHistoriesGetResponse_results_options)),
            "type": lambda n : setattr(self, 'type', 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_str_value("action", self.action)
        writer.write_str_value("associationId", self.association_id)
        writer.write_str_value("associationType", self.association_type)
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_object_value("operator", self.operator)
        writer.write_object_value("options", self.options)
        writer.write_str_value("type", self.type)
    

