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 .with_export_get_response_result_error import WithExportGetResponse_result_error
    from .with_export_get_response_result_output import WithExportGetResponse_result_output

@dataclass
class WithExportGetResponse_result(Parsable):
    """
    The result of a completed export job.- If the ``status`` is ``successful``, a downloadable signed URL will be included in the ``result.output`` object.- If the ``status`` value is ``failed`` (e.g., because some files were deleted), the ``result.error`` object will include details of the error.
    """
    # Information about the error.
    error: Optional[WithExportGetResponse_result_error] = None
    # Details about the downloadable signed URL.
    output: Optional[WithExportGetResponse_result_output] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithExportGetResponse_result:
        """
        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: WithExportGetResponse_result
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithExportGetResponse_result()
    
    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_export_get_response_result_error import WithExportGetResponse_result_error
        from .with_export_get_response_result_output import WithExportGetResponse_result_output

        from .with_export_get_response_result_error import WithExportGetResponse_result_error
        from .with_export_get_response_result_output import WithExportGetResponse_result_output

        fields: dict[str, Callable[[Any], None]] = {
            "error": lambda n : setattr(self, 'error', n.get_object_value(WithExportGetResponse_result_error)),
            "output": lambda n : setattr(self, 'output', n.get_object_value(WithExportGetResponse_result_output)),
        }
        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("error", self.error)
        writer.write_object_value("output", self.output)
    

