# coding: utf-8

"""
    Moodle Webservice API

    Auto-generated OpenAPI spec for Moodle's Webservice API.

    The version of the OpenAPI document: 5.0.3 (Build: 20251006)
    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 poodle_async_full.models.core_webservice_get_site_info_response_advancedfeatures_inner import CoreWebserviceGetSiteInfoResponseAdvancedfeaturesInner
from poodle_async_full.models.core_webservice_get_site_info_response_functions_inner import CoreWebserviceGetSiteInfoResponseFunctionsInner
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class CoreWebserviceGetSiteInfoResponse(BaseModel):
    """
    CoreWebserviceGetSiteInfoResponse
    """ # noqa: E501
    advancedfeatures: Optional[List[CoreWebserviceGetSiteInfoResponseAdvancedfeaturesInner]] = Field(default=None, description="Advanced features availability")
    downloadfiles: Optional[StrictInt] = Field(default=None, description="1 if users are allowed to download files, 0 if not")
    firstname: Optional[StrictStr] = Field(description="first name")
    fullname: Optional[StrictStr] = Field(description="user full name")
    functions: List[CoreWebserviceGetSiteInfoResponseFunctionsInner]
    lang: Optional[StrictStr] = Field(description="Current language.")
    lastname: Optional[StrictStr] = Field(description="last name")
    limitconcurrentlogins: Optional[StrictInt] = Field(default=None, description="Number of concurrent sessions allowed")
    mobilecssurl: Optional[StrictStr] = Field(default=None, description="Mobile custom CSS theme")
    policyagreed: Optional[StrictInt] = Field(default=None, description="Whether user accepted all the policies.")
    release: Optional[StrictStr] = Field(default=None, description="Moodle release number")
    sitecalendartype: Optional[StrictStr] = Field(default=None, description="Calendar type set in the site.")
    siteid: Optional[StrictInt] = Field(default=None, description="Site course ID")
    sitename: Optional[StrictStr] = Field(description="site name")
    siteurl: Optional[StrictStr] = Field(description="site url")
    theme: Optional[StrictStr] = Field(default=None, description="Current theme for the user.")
    uploadfiles: Optional[StrictInt] = Field(default=None, description="1 if users are allowed to upload files, 0 if not")
    usercalendartype: Optional[StrictStr] = Field(default=None, description="Calendar typed used by the user.")
    usercanmanageownfiles: Optional[StrictBool] = Field(default=None, description="true if the user can manage his own files")
    userhomepage: Optional[StrictInt] = Field(default=None, description="the default home page for the user: 0 for the site home, 1 for dashboard")
    userhomepageurl: Optional[StrictStr] = Field(default=None, description="The URL of default home page when userhomepage is 4 (HOMEPAGE_URL).")
    userid: Optional[StrictInt] = Field(description="user id")
    userissiteadmin: Optional[StrictBool] = Field(default=None, description="Whether the user is a site admin or not.")
    usermaxuploadfilesize: Optional[StrictInt] = Field(default=None, description="user max upload file size (bytes). -1 means the user can ignore the upload file size")
    username: Optional[StrictStr] = Field(description="username")
    userpictureurl: Optional[StrictStr] = Field(description="the user profile picture.                     Warning: this url is the public URL that only works when forcelogin is set to NO and guestaccess is set to YES.                     In order to retrieve user profile pictures independently of the Moodle config, replace \"pluginfile.php\" by                     \"webservice/pluginfile.php?token=WSTOKEN&file=\"                     Of course the user can only see profile picture depending                     on his/her permissions. Moreover it is recommended to use HTTPS too.")
    userprivateaccesskey: Optional[StrictStr] = Field(default=None, description="Private user access key for fetching files.")
    userquota: Optional[StrictInt] = Field(default=None, description="user quota (bytes). 0 means user can ignore the quota")
    usersessionscount: Optional[StrictInt] = Field(default=None, description="Number of active sessions for current user.                     Only returned when limitconcurrentlogins is used.")
    version: Optional[StrictStr] = Field(default=None, description="Moodle version number")
    __properties: ClassVar[List[str]] = ["advancedfeatures", "downloadfiles", "firstname", "fullname", "functions", "lang", "lastname", "limitconcurrentlogins", "mobilecssurl", "policyagreed", "release", "sitecalendartype", "siteid", "sitename", "siteurl", "theme", "uploadfiles", "usercalendartype", "usercanmanageownfiles", "userhomepage", "userhomepageurl", "userid", "userissiteadmin", "usermaxuploadfilesize", "username", "userpictureurl", "userprivateaccesskey", "userquota", "usersessionscount", "version"]

    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 CoreWebserviceGetSiteInfoResponse 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 advancedfeatures (list)
        _items = []
        if self.advancedfeatures:
            for _item_advancedfeatures in self.advancedfeatures:
                if _item_advancedfeatures:
                    _items.append(_item_advancedfeatures.to_dict())
            _dict['advancedfeatures'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in functions (list)
        _items = []
        if self.functions:
            for _item_functions in self.functions:
                if _item_functions:
                    _items.append(_item_functions.to_dict())
            _dict['functions'] = _items
        # set to None if downloadfiles (nullable) is None
        # and model_fields_set contains the field
        if self.downloadfiles is None and "downloadfiles" in self.model_fields_set:
            _dict['downloadfiles'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

        relaxed = settings.relaxe_all_models or "CoreWebserviceGetSiteInfoResponse" in settings.relaxed_models

        if not isinstance(obj, dict):
            return cls.model_construct(**obj) if relaxed else cls.model_validate(obj)

        data = {
            "advancedfeatures": [CoreWebserviceGetSiteInfoResponseAdvancedfeaturesInner.from_dict(_item) for _item in obj["advancedfeatures"]] if obj.get("advancedfeatures") is not None else None,
            "downloadfiles": obj.get("downloadfiles"),
            "firstname": obj.get("firstname"),
            "fullname": obj.get("fullname"),
            "functions": [CoreWebserviceGetSiteInfoResponseFunctionsInner.from_dict(_item) for _item in obj["functions"]] if obj.get("functions") is not None else None,
            "lang": obj.get("lang"),
            "lastname": obj.get("lastname"),
            "limitconcurrentlogins": obj.get("limitconcurrentlogins"),
            "mobilecssurl": obj.get("mobilecssurl"),
            "policyagreed": obj.get("policyagreed"),
            "release": obj.get("release"),
            "sitecalendartype": obj.get("sitecalendartype"),
            "siteid": obj.get("siteid"),
            "sitename": obj.get("sitename"),
            "siteurl": obj.get("siteurl"),
            "theme": obj.get("theme"),
            "uploadfiles": obj.get("uploadfiles"),
            "usercalendartype": obj.get("usercalendartype"),
            "usercanmanageownfiles": obj.get("usercanmanageownfiles"),
            "userhomepage": obj.get("userhomepage"),
            "userhomepageurl": obj.get("userhomepageurl"),
            "userid": obj.get("userid"),
            "userissiteadmin": obj.get("userissiteadmin"),
            "usermaxuploadfilesize": obj.get("usermaxuploadfilesize"),
            "username": obj.get("username"),
            "userpictureurl": obj.get("userpictureurl"),
            "userprivateaccesskey": obj.get("userprivateaccesskey"),
            "userquota": obj.get("userquota"),
            "usersessionscount": obj.get("usersessionscount"),
            "version": obj.get("version")
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


