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 .with_version_set_patch_response_collection import WithVersionSetPatchResponse_collection

@dataclass
class WithVersionSetPatchResponse(Parsable):
    # The collection object, if assigned. If no collection is assigned, this value is ``null``.
    collection: Optional[WithVersionSetPatchResponse_collection] = None
    # The time when the version set was created, in ISO-8601 format (YYYY-MM-DDTHH:mm:ss.SSSZ).
    created_at: Optional[datetime.datetime] = None
    # The ID of the user who created the version set.
    created_by: Optional[str] = None
    # The name of the user who created the version set.
    created_by_name: Optional[str] = None
    # The ID of the version set.
    id: Optional[UUID] = None
    # The issuance date of the version set, in ISO-8601 date format (YYYY-MM-DD).
    issuance_date: Optional[datetime.datetime] = None
    # The name of the version set.
    name: Optional[str] = None
    # The time when the version set was last updated, in ISO-8601 format (YYYY-MM-DDTHH:mm:ss.SSSZ).
    updated_at: Optional[datetime.datetime] = None
    # The ID of the user who last updated the version set.
    updated_by: Optional[str] = None
    # The name of the user who last updated the version set.
    updated_by_name: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithVersionSetPatchResponse:
        """
        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: WithVersionSetPatchResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithVersionSetPatchResponse()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .with_version_set_patch_response_collection import WithVersionSetPatchResponse_collection

        from .with_version_set_patch_response_collection import WithVersionSetPatchResponse_collection

        fields: dict[str, Callable[[Any], None]] = {
            "collection": lambda n : setattr(self, 'collection', n.get_object_value(WithVersionSetPatchResponse_collection)),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "createdBy": lambda n : setattr(self, 'created_by', n.get_str_value()),
            "createdByName": lambda n : setattr(self, 'created_by_name', n.get_str_value()),
            "id": lambda n : setattr(self, 'id', n.get_uuid_value()),
            "issuanceDate": lambda n : setattr(self, 'issuance_date', n.get_datetime_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_value()),
            "updatedBy": lambda n : setattr(self, 'updated_by', n.get_str_value()),
            "updatedByName": lambda n : setattr(self, 'updated_by_name', 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_object_value("collection", self.collection)
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_str_value("createdBy", self.created_by)
        writer.write_str_value("createdByName", self.created_by_name)
        writer.write_uuid_value("id", self.id)
        writer.write_datetime_value("issuanceDate", self.issuance_date)
        writer.write_str_value("name", self.name)
        writer.write_datetime_value("updatedAt", self.updated_at)
        writer.write_str_value("updatedBy", self.updated_by)
        writer.write_str_value("updatedByName", self.updated_by_name)
    

