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 .metadata_get_response_versions_status import MetadataGetResponse_versions_status

@dataclass
class MetadataGetResponse_versions(Parsable):
    # The date and time the version was created in ISO8601 format. For example, ``2023-01-17T09:54:27.000Z``.
    created_at: Optional[str] = None
    # ``true`` if this is the current version``false`` if this is not the current version
    current_version: Optional[bool] = None
    # The ID of the AutoSpecs version, generated by AutoSpecs when creating the new version.
    id: Optional[str] = None
    # The version name provided by the user when creating the version.
    name: Optional[str] = None
    # The status of the specification extraction. Note that Smart Register data (GET smartRegster) is only available when the status is ``Completed``.Note that we do not currently support webhooks for the AutoSpecs API.Possible values: ``Completed``, ``In Progress``, ``Failed``
    status: Optional[MetadataGetResponse_versions_status] = None
    # The last date and time the version was updated in in ISO8601. For example ``2023-01-17T09:54:27.000Z``.
    updated_at: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> MetadataGetResponse_versions:
        """
        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: MetadataGetResponse_versions
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return MetadataGetResponse_versions()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .metadata_get_response_versions_status import MetadataGetResponse_versions_status

        from .metadata_get_response_versions_status import MetadataGetResponse_versions_status

        fields: dict[str, Callable[[Any], None]] = {
            "createdAt": lambda n : setattr(self, 'created_at', n.get_str_value()),
            "currentVersion": lambda n : setattr(self, 'current_version', n.get_bool_value()),
            "id": lambda n : setattr(self, 'id', n.get_str_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "status": lambda n : setattr(self, 'status', n.get_enum_value(MetadataGetResponse_versions_status)),
            "updatedAt": lambda n : setattr(self, 'updated_at', 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("createdAt", self.created_at)
        writer.write_bool_value("currentVersion", self.current_version)
        writer.write_str_value("id", self.id)
        writer.write_str_value("name", self.name)
        writer.write_enum_value("status", self.status)
        writer.write_str_value("updatedAt", self.updated_at)
    

