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

if TYPE_CHECKING:
    from .with_index_get_response_errors import WithIndexGetResponse_errors
    from .with_index_get_response_stats import WithIndexGetResponse_stats

@dataclass
class WithIndexGetResponse(Parsable):
    # The errors property
    errors: Optional[list[WithIndexGetResponse_errors]] = None
    # url for downloading the index fields.
    fields_url: Optional[str] = None
    # index id.
    index_id: Optional[str] = None
    # url for downloading the index manifest.
    manifest_url: Optional[str] = None
    # project id.
    project_id: Optional[str] = None
    # url for downloading the index properties.
    properties_url: Optional[str] = None
    # query id.
    query_id: Optional[str] = None
    # url for downloading the query result.
    query_results_url: Optional[str] = None
    # timestamp.
    retry_at: Optional[datetime.datetime] = None
    # unique url for this indexing job status.
    self_url: Optional[str] = None
    # job status.
    state: Optional[str] = None
    # some higher level index statistics.
    stats: Optional[WithIndexGetResponse_stats] = None
    # type.
    type: Optional[str] = None
    # timestamp.
    updated_at: Optional[datetime.datetime] = None
    # list all versions this index depends upon.
    version_urns: Optional[list[str]] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithIndexGetResponse:
        """
        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: WithIndexGetResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithIndexGetResponse()
    
    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_index_get_response_errors import WithIndexGetResponse_errors
        from .with_index_get_response_stats import WithIndexGetResponse_stats

        from .with_index_get_response_errors import WithIndexGetResponse_errors
        from .with_index_get_response_stats import WithIndexGetResponse_stats

        fields: dict[str, Callable[[Any], None]] = {
            "errors": lambda n : setattr(self, 'errors', n.get_collection_of_object_values(WithIndexGetResponse_errors)),
            "fieldsUrl": lambda n : setattr(self, 'fields_url', n.get_str_value()),
            "indexId": lambda n : setattr(self, 'index_id', n.get_str_value()),
            "manifestUrl": lambda n : setattr(self, 'manifest_url', n.get_str_value()),
            "projectId": lambda n : setattr(self, 'project_id', n.get_str_value()),
            "propertiesUrl": lambda n : setattr(self, 'properties_url', n.get_str_value()),
            "queryId": lambda n : setattr(self, 'query_id', n.get_str_value()),
            "queryResultsUrl": lambda n : setattr(self, 'query_results_url', n.get_str_value()),
            "retryAt": lambda n : setattr(self, 'retry_at', n.get_datetime_value()),
            "selfUrl": lambda n : setattr(self, 'self_url', n.get_str_value()),
            "state": lambda n : setattr(self, 'state', n.get_str_value()),
            "stats": lambda n : setattr(self, 'stats', n.get_object_value(WithIndexGetResponse_stats)),
            "type": lambda n : setattr(self, 'type', n.get_str_value()),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_value()),
            "versionUrns": lambda n : setattr(self, 'version_urns', n.get_collection_of_primitive_values(str)),
        }
        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_collection_of_object_values("errors", self.errors)
        writer.write_str_value("fieldsUrl", self.fields_url)
        writer.write_str_value("indexId", self.index_id)
        writer.write_str_value("manifestUrl", self.manifest_url)
        writer.write_str_value("projectId", self.project_id)
        writer.write_str_value("propertiesUrl", self.properties_url)
        writer.write_str_value("queryId", self.query_id)
        writer.write_str_value("queryResultsUrl", self.query_results_url)
        writer.write_datetime_value("retryAt", self.retry_at)
        writer.write_str_value("selfUrl", self.self_url)
        writer.write_str_value("state", self.state)
        writer.write_object_value("stats", self.stats)
        writer.write_str_value("type", self.type)
        writer.write_datetime_value("updatedAt", self.updated_at)
        writer.write_collection_of_primitive_values("versionUrns", self.version_urns)
    

