# coding: utf-8

"""
    Lookup/Ibis web service API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.2
    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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class AttributeScheme(BaseModel):
    """
    Class representing an attribute scheme. This may apply to attributes of people or institutions.
    """ # noqa: E501
    schemeid: Optional[StrictStr] = Field(default=None, description="The unique identifier of the attribute scheme.")
    precedence: Optional[StrictInt] = Field(default=None, description="The attribute scheme's precedence. Methods that return or display attributes sort the results primarily in order of increasing values of attribute scheme precedence.")
    ldap_name: Optional[StrictStr] = Field(default=None, description="The name of the attribute scheme in LDAP, if it is exported to LDAP. Note that many attributes are not exported to LDAP, in which case this name is typically just equal to the scheme's ID.", alias="ldapName")
    display_name: Optional[StrictStr] = Field(default=None, description="The display name for labelling attributes in this scheme.", alias="displayName")
    data_type: Optional[StrictStr] = Field(default=None, description="The attribute scheme's datatype.", alias="dataType")
    multi_valued: Optional[StrictBool] = Field(default=None, description="Flag indicating whether attributes in this scheme can be multi-valued.", alias="multiValued")
    multi_lined: Optional[StrictBool] = Field(default=None, description="Flag for textual attributes schemes indicating whether they are multi-lined.", alias="multiLined")
    searchable: Optional[StrictBool] = Field(default=None, description="Flag indicating whether attributes of this scheme are searched by the default search functionality.")
    regexp: Optional[StrictStr] = Field(default=None, description="For textual attributes, an optional regular expression that all attributes in this scheme match.")
    __properties: ClassVar[List[str]] = ["schemeid", "precedence", "ldapName", "displayName", "dataType", "multiValued", "multiLined", "searchable", "regexp"]

    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 AttributeScheme 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "schemeid": obj.get("schemeid"),
            "precedence": obj.get("precedence"),
            "ldapName": obj.get("ldapName"),
            "displayName": obj.get("displayName"),
            "dataType": obj.get("dataType"),
            "multiValued": obj.get("multiValued"),
            "multiLined": obj.get("multiLined"),
            "searchable": obj.get("searchable"),
            "regexp": obj.get("regexp")
        })
        return _obj


