# 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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class Attribute(BaseModel):
    """
    Class representing an attribute of a person or institution returned by the web service API. Note that for institution attributes, the instid, visibility and owningGroupid fields will be `null`.
    """ # noqa: E501
    attrid: Optional[StrictInt] = Field(default=None, description="The unique internal identifier of the attribute.")
    scheme: Optional[StrictStr] = Field(default=None, description="The attribute's scheme.")
    value: Optional[StrictStr] = Field(default=None, description="The attribute's value (except for binary attributes).")
    comment: Optional[StrictStr] = Field(default=None, description="Any comment associated with the attribute.")
    instid: Optional[StrictStr] = Field(default=None, description="For a person attribute, the optional institution that the attribute is associated with. This will not be set for institution attributes.")
    visibility: Optional[StrictStr] = Field(default=None, description="For a person attribute, it's visibility (`\"private\"`, `\"institution\"`, `\"university\"` or `\"world\"`). This will not be set for institution attributes.")
    effective_from: Optional[datetime] = Field(default=None, description="For time-limited attributes, the date from which it takes effect.", alias="effectiveFrom")
    effective_to: Optional[datetime] = Field(default=None, description="For time-limited attributes, the date after which it is no longer effective.", alias="effectiveTo")
    owning_groupid: Optional[StrictStr] = Field(default=None, description="For a person attribute, the ID of the group that owns it (typically the user agent group that created it).", alias="owningGroupid")
    __properties: ClassVar[List[str]] = ["attrid", "scheme", "value", "comment", "instid", "visibility", "effectiveFrom", "effectiveTo", "owningGroupid"]

    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 Attribute 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 Attribute from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "attrid": obj.get("attrid"),
            "scheme": obj.get("scheme"),
            "value": obj.get("value"),
            "comment": obj.get("comment"),
            "instid": obj.get("instid"),
            "visibility": obj.get("visibility"),
            "effectiveFrom": obj.get("effectiveFrom"),
            "effectiveTo": obj.get("effectiveTo"),
            "owningGroupid": obj.get("owningGroupid")
        })
        return _obj


