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 .linked_files_get_response_host_file import LinkedFilesGetResponse_hostFile
    from .linked_files_get_response_linked_files import LinkedFilesGetResponse_linkedFiles

@dataclass
class LinkedFilesGetResponse(Parsable):
    # Metadata about the host model (the main Revit model that contains linked files). This object is only returned in the response when ``includeHost`` is set to ``true``.
    host_file: Optional[LinkedFilesGetResponse_hostFile] = None
    # A list of linked Revit (RVT) models associated with the requested published model version.This object contains a list of linked files and pagination details.
    linked_files: Optional[list[LinkedFilesGetResponse_linkedFiles]] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> LinkedFilesGetResponse:
        """
        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: LinkedFilesGetResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return LinkedFilesGetResponse()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .linked_files_get_response_host_file import LinkedFilesGetResponse_hostFile
        from .linked_files_get_response_linked_files import LinkedFilesGetResponse_linkedFiles

        from .linked_files_get_response_host_file import LinkedFilesGetResponse_hostFile
        from .linked_files_get_response_linked_files import LinkedFilesGetResponse_linkedFiles

        fields: dict[str, Callable[[Any], None]] = {
            "hostFile": lambda n : setattr(self, 'host_file', n.get_object_value(LinkedFilesGetResponse_hostFile)),
            "linkedFiles": lambda n : setattr(self, 'linked_files', n.get_collection_of_object_values(LinkedFilesGetResponse_linkedFiles)),
        }
        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("hostFile", self.host_file)
        writer.write_collection_of_object_values("linkedFiles", self.linked_files)
    

