# coding: utf-8

"""
    Onboarding Buddy API

    This document details all the available operations in the Onboarding Buddy API specification

    The version of the OpenAPI document: v1
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from onboarding_buddy_client.models.file_record_meta_data_m import FileRecordMetaDataM
from typing import Optional, Set
from typing_extensions import Self

class SearchFileRecordM(BaseModel):
    """
    SearchFileRecordM
    """ # noqa: E501
    global_id: Optional[StrictStr] = Field(default=None, alias="globalId")
    organisation_global_id: Optional[StrictStr] = Field(default=None, alias="organisationGlobalId")
    application_global_id: Optional[StrictStr] = Field(default=None, alias="applicationGlobalId")
    file_name: Optional[StrictStr] = Field(default=None, alias="fileName")
    mime_type: Optional[StrictStr] = Field(default=None, alias="mimeType")
    origin_type: Optional[StrictStr] = Field(default=None, alias="originType")
    original_file_name: Optional[StrictStr] = Field(default=None, alias="originalFileName")
    file_size: Optional[StrictInt] = Field(default=None, alias="fileSize")
    file_status: Optional[StrictStr] = Field(default=None, alias="fileStatus")
    title: Optional[StrictStr] = None
    description: Optional[StrictStr] = None
    tags: Optional[StrictStr] = None
    reasoning: Optional[StrictStr] = None
    created_date: Optional[datetime] = Field(default=None, alias="createdDate")
    distance: Optional[Union[StrictFloat, StrictInt]] = None
    document: Optional[StrictStr] = None
    meta_data: Optional[FileRecordMetaDataM] = Field(default=None, alias="metaData")
    __properties: ClassVar[List[str]] = ["globalId", "organisationGlobalId", "applicationGlobalId", "fileName", "mimeType", "originType", "originalFileName", "fileSize", "fileStatus", "title", "description", "tags", "reasoning", "createdDate", "distance", "document", "metaData"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of SearchFileRecordM from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of meta_data
        if self.meta_data:
            _dict['metaData'] = self.meta_data.to_dict()
        # set to None if global_id (nullable) is None
        # and model_fields_set contains the field
        if self.global_id is None and "global_id" in self.model_fields_set:
            _dict['globalId'] = None

        # set to None if organisation_global_id (nullable) is None
        # and model_fields_set contains the field
        if self.organisation_global_id is None and "organisation_global_id" in self.model_fields_set:
            _dict['organisationGlobalId'] = None

        # set to None if application_global_id (nullable) is None
        # and model_fields_set contains the field
        if self.application_global_id is None and "application_global_id" in self.model_fields_set:
            _dict['applicationGlobalId'] = None

        # set to None if file_name (nullable) is None
        # and model_fields_set contains the field
        if self.file_name is None and "file_name" in self.model_fields_set:
            _dict['fileName'] = None

        # set to None if mime_type (nullable) is None
        # and model_fields_set contains the field
        if self.mime_type is None and "mime_type" in self.model_fields_set:
            _dict['mimeType'] = None

        # set to None if origin_type (nullable) is None
        # and model_fields_set contains the field
        if self.origin_type is None and "origin_type" in self.model_fields_set:
            _dict['originType'] = None

        # set to None if original_file_name (nullable) is None
        # and model_fields_set contains the field
        if self.original_file_name is None and "original_file_name" in self.model_fields_set:
            _dict['originalFileName'] = None

        # set to None if file_status (nullable) is None
        # and model_fields_set contains the field
        if self.file_status is None and "file_status" in self.model_fields_set:
            _dict['fileStatus'] = None

        # set to None if title (nullable) is None
        # and model_fields_set contains the field
        if self.title is None and "title" in self.model_fields_set:
            _dict['title'] = None

        # set to None if description (nullable) is None
        # and model_fields_set contains the field
        if self.description is None and "description" in self.model_fields_set:
            _dict['description'] = None

        # set to None if tags (nullable) is None
        # and model_fields_set contains the field
        if self.tags is None and "tags" in self.model_fields_set:
            _dict['tags'] = None

        # set to None if reasoning (nullable) is None
        # and model_fields_set contains the field
        if self.reasoning is None and "reasoning" in self.model_fields_set:
            _dict['reasoning'] = None

        # set to None if created_date (nullable) is None
        # and model_fields_set contains the field
        if self.created_date is None and "created_date" in self.model_fields_set:
            _dict['createdDate'] = None

        # set to None if distance (nullable) is None
        # and model_fields_set contains the field
        if self.distance is None and "distance" in self.model_fields_set:
            _dict['distance'] = None

        # set to None if document (nullable) is None
        # and model_fields_set contains the field
        if self.document is None and "document" in self.model_fields_set:
            _dict['document'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of SearchFileRecordM from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "globalId": obj.get("globalId"),
            "organisationGlobalId": obj.get("organisationGlobalId"),
            "applicationGlobalId": obj.get("applicationGlobalId"),
            "fileName": obj.get("fileName"),
            "mimeType": obj.get("mimeType"),
            "originType": obj.get("originType"),
            "originalFileName": obj.get("originalFileName"),
            "fileSize": obj.get("fileSize"),
            "fileStatus": obj.get("fileStatus"),
            "title": obj.get("title"),
            "description": obj.get("description"),
            "tags": obj.get("tags"),
            "reasoning": obj.get("reasoning"),
            "createdDate": obj.get("createdDate"),
            "distance": obj.get("distance"),
            "document": obj.get("document"),
            "metaData": FileRecordMetaDataM.from_dict(obj["metaData"]) if obj.get("metaData") is not None else None
        })
        return _obj


