# coding: utf-8

"""
    Gitea API

    This documentation describes the Gitea API.

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

class User(BaseModel):
    """
    User represents a user
    """ # noqa: E501
    active: Optional[StrictBool] = Field(default=None, description="Is user active")
    avatar_url: Optional[StrictStr] = Field(default=None, description="URL to the user's avatar")
    created: Optional[datetime] = None
    description: Optional[StrictStr] = Field(default=None, description="the user's description")
    email: Optional[StrictStr] = None
    followers_count: Optional[StrictInt] = Field(default=None, description="user counts")
    following_count: Optional[StrictInt] = None
    full_name: Optional[StrictStr] = Field(default=None, description="the user's full name")
    html_url: Optional[StrictStr] = Field(default=None, description="URL to the user's gitea page")
    id: Optional[StrictInt] = Field(default=None, description="the user's id")
    is_admin: Optional[StrictBool] = Field(default=None, description="Is the user an administrator")
    language: Optional[StrictStr] = Field(default=None, description="User locale")
    last_login: Optional[datetime] = None
    location: Optional[StrictStr] = Field(default=None, description="the user's location")
    login: Optional[StrictStr] = Field(default=None, description="the user's username")
    login_name: Optional[StrictStr] = Field(default='empty', description="the user's authentication sign-in name.")
    prohibit_login: Optional[StrictBool] = Field(default=None, description="Is user login prohibited")
    restricted: Optional[StrictBool] = Field(default=None, description="Is user restricted")
    source_id: Optional[StrictInt] = Field(default=None, description="The ID of the user's Authentication Source")
    starred_repos_count: Optional[StrictInt] = None
    visibility: Optional[StrictStr] = Field(default=None, description="User visibility level option: public, limited, private")
    website: Optional[StrictStr] = Field(default=None, description="the user's website")
    __properties: ClassVar[List[str]] = ["active", "avatar_url", "created", "description", "email", "followers_count", "following_count", "full_name", "html_url", "id", "is_admin", "language", "last_login", "location", "login", "login_name", "prohibit_login", "restricted", "source_id", "starred_repos_count", "visibility", "website"]

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

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

        _obj = cls.model_validate({
            "active": obj.get("active"),
            "avatar_url": obj.get("avatar_url"),
            "created": obj.get("created"),
            "description": obj.get("description"),
            "email": obj.get("email"),
            "followers_count": obj.get("followers_count"),
            "following_count": obj.get("following_count"),
            "full_name": obj.get("full_name"),
            "html_url": obj.get("html_url"),
            "id": obj.get("id"),
            "is_admin": obj.get("is_admin"),
            "language": obj.get("language"),
            "last_login": obj.get("last_login"),
            "location": obj.get("location"),
            "login": obj.get("login"),
            "login_name": obj.get("login_name") if obj.get("login_name") is not None else 'empty',
            "prohibit_login": obj.get("prohibit_login"),
            "restricted": obj.get("restricted"),
            "source_id": obj.get("source_id"),
            "starred_repos_count": obj.get("starred_repos_count"),
            "visibility": obj.get("visibility"),
            "website": obj.get("website")
        })
        return _obj


