# coding: utf-8

"""
    Eazyrent IAM API

    EazyRent IAM API ==================  Description -------------  The EazyRent IAM API provides robust identity and access management capabilities, enabling efficient account management and permission controls across the platform. Tailored for the SaaS environment, this API allows administrators to handle user authentication, manage roles, and define permissions to secure access to various resources. By centralizing user accounts and access rules, the IAM API ensures a secure, organized, and scalable approach to managing tenant and staff permissions.  Target Audience ------------------   * **Real Estate Agencies and Social Housing Providers:** Organizations requiring a secure, structured way to manage access for staff and tenants, ensuring that only authorized users can access specific resources and functionalities.   * **Rent Guarantee Insurers:** Companies that need to manage and restrict access to sensitive information, allowing only certain roles to handle tenant verification and risk assessment data.  Purpose --------  The purpose of the EazyRent IAM API is to centralize identity and permission management for platform users. Through this API, businesses can handle account creation, manage user roles, assign permissions, and track access to critical resources, all while ensuring compliance and data security. This results in streamlined operations, allowing clients to configure role-based access in alignment with organizational policies and requirements.  How to use this API -----------------------  To start using the EazyRent IAM API, consult our detailed documentation, which provides information on authentication, endpoint definitions, and integration best practices. This documentation covers the steps required to manage user identities, roles, and permissions within your existing systems, ensuring secure and efficient access control across the platform.

    The version of the OpenAPI document: 1
    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, StrictStr
from typing import Any, ClassVar, Dict, List
from eazyrent.iam.v1.models.validation_error_loc_inner import ValidationErrorLocInner
from typing import Optional, Set
from typing_extensions import Self


class ValidationError(BaseModel):
    """
    ValidationError
    """  # noqa: E501

    loc: List[ValidationErrorLocInner]
    msg: StrictStr
    type: StrictStr
    __properties: ClassVar[List[str]] = ["loc", "msg", "type"]

    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 ValidationError 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 each item in loc (list)
        _items = []
        if self.loc:
            for _item_loc in self.loc:
                if _item_loc:
                    _items.append(_item_loc.to_dict())
            _dict["loc"] = _items
        return _dict

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

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

        _obj = cls.model_validate(
            {
                "loc": [
                    ValidationErrorLocInner.from_dict(_item) for _item in obj["loc"]
                ]
                if obj.get("loc") is not None
                else None,
                "msg": obj.get("msg"),
                "type": obj.get("type"),
            }
        )
        return _obj
