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

if TYPE_CHECKING:
    from .me_get_response_permitted_actions_fields import MeGetResponse_permittedActions_fields
    from .me_get_response_permitted_actions_transitions import MeGetResponse_permittedActions_transitions

@dataclass
class MeGetResponse_permittedActions(Parsable):
    # A mapping of field names to lists of possible values for each field, specific to the associated action. An empty array indicates that there is no specific set of values for those fields.For example, in the action ``Spec::create``, fields might contain mapping for title (``title``) and identifier (``identifier``).
    fields: Optional[MeGetResponse_permittedActions_fields] = None
    # ID of the action in the format ``type_of_object::action``. For example, ``item::create``, ``Spec::create``.
    id: Optional[str] = None
    # A subset of fields (``fields``) that are required to perform specific actions, such as creating or transitioning a submittal item. The required fields depend on the user’s role and the action.For example, creating a submittal item in the ``mgr-1`` state as a manager or in the ``sbc-1`` state as a subcontractor requires different fields. For example, [``stateId``, ``specId``, ``title``, ``typeId``, ``manager``, ``managerType``].
    mandatory_fields: Optional[list[str]] = None
    # list of possible transitions
    transitions: Optional[list[MeGetResponse_permittedActions_transitions]] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> MeGetResponse_permittedActions:
        """
        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: MeGetResponse_permittedActions
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return MeGetResponse_permittedActions()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .me_get_response_permitted_actions_fields import MeGetResponse_permittedActions_fields
        from .me_get_response_permitted_actions_transitions import MeGetResponse_permittedActions_transitions

        from .me_get_response_permitted_actions_fields import MeGetResponse_permittedActions_fields
        from .me_get_response_permitted_actions_transitions import MeGetResponse_permittedActions_transitions

        fields: dict[str, Callable[[Any], None]] = {
            "fields": lambda n : setattr(self, 'fields', n.get_object_value(MeGetResponse_permittedActions_fields)),
            "id": lambda n : setattr(self, 'id', n.get_str_value()),
            "mandatoryFields": lambda n : setattr(self, 'mandatory_fields', n.get_collection_of_primitive_values(str)),
            "transitions": lambda n : setattr(self, 'transitions', n.get_collection_of_object_values(MeGetResponse_permittedActions_transitions)),
        }
        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("fields", self.fields)
        writer.write_str_value("id", self.id)
        writer.write_collection_of_primitive_values("mandatoryFields", self.mandatory_fields)
        writer.write_collection_of_object_values("transitions", self.transitions)
    

