# coding: utf-8

"""
    CUA API

    Documentation of API endpoints of CUA

    The version of the OpenAPI document: 1.0.0
    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 pydantic import BaseModel, ConfigDict, Field, StrictInt
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from robotnikai.models.mongo_migration_status_enum import MongoMigrationStatusEnum
from typing import Optional, Set
from typing_extensions import Self

class MongoMigrationRequest(BaseModel):
    """
    MongoMigrationRequest
    """ # noqa: E501
    status: Optional[MongoMigrationStatusEnum] = None
    collection_name: Annotated[str, Field(min_length=1, strict=True, max_length=150)]
    migration_name: Annotated[str, Field(min_length=1, strict=True, max_length=150)]
    old_schema: Optional[Any] = None
    new_schema: Optional[Any] = None
    renamed: Optional[Any] = None
    added: Optional[Any] = None
    removed: Optional[Any] = None
    changed: Optional[Any] = None
    task_id: Optional[Annotated[str, Field(strict=True, max_length=150)]] = None
    type_conversion_policy: Optional[Any] = None
    application: StrictInt
    __properties: ClassVar[List[str]] = ["status", "collection_name", "migration_name", "old_schema", "new_schema", "renamed", "added", "removed", "changed", "task_id", "type_conversion_policy", "application"]

    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 MongoMigrationRequest 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,
        )
        # set to None if old_schema (nullable) is None
        # and model_fields_set contains the field
        if self.old_schema is None and "old_schema" in self.model_fields_set:
            _dict['old_schema'] = None

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "status": obj.get("status"),
            "collection_name": obj.get("collection_name"),
            "migration_name": obj.get("migration_name"),
            "old_schema": obj.get("old_schema"),
            "new_schema": obj.get("new_schema"),
            "renamed": obj.get("renamed"),
            "added": obj.get("added"),
            "removed": obj.get("removed"),
            "changed": obj.get("changed"),
            "task_id": obj.get("task_id"),
            "type_conversion_policy": obj.get("type_conversion_policy"),
            "application": obj.get("application")
        })
        return _obj


