# 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
from typing import Any, ClassVar, Dict, List, Optional
from poodle_async_full.models.auth_email_get_signup_settings_response_warnings_inner import AuthEmailGetSignupSettingsResponseWarningsInner
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class ModForumGetForumAccessInformationResponse(BaseModel):
    """
    ModForumGetForumAccessInformationResponse
    """ # noqa: E501
    canaddinstance: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:addinstance allowed.")
    canaddnews: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:addnews allowed.")
    canaddquestion: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:addquestion allowed.")
    canallowforcesubscribe: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:allowforcesubscribe allowed.")
    cancanmailnow: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:canmailnow allowed.")
    cancanoverridecutoff: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:canoverridecutoff allowed.")
    cancanoverridediscussionlock: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:canoverridediscussionlock allowed.")
    cancanposttomygroups: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:canposttomygroups allowed.")
    cancantogglefavourite: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:cantogglefavourite allowed.")
    cancreateattachment: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:createattachment allowed.")
    candeleteanypost: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:deleteanypost allowed.")
    candeleteownpost: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:deleteownpost allowed.")
    caneditanypost: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:editanypost allowed.")
    canexportdiscussion: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:exportdiscussion allowed.")
    canexportforum: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:exportforum allowed.")
    canexportownpost: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:exportownpost allowed.")
    canexportpost: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:exportpost allowed.")
    cangrade: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:grade allowed.")
    canmanagesubscriptions: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:managesubscriptions allowed.")
    canmovediscussions: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:movediscussions allowed.")
    canpindiscussions: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:pindiscussions allowed.")
    canpostprivatereply: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:postprivatereply allowed.")
    canpostwithoutthrottling: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:postwithoutthrottling allowed.")
    canrate: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:rate allowed.")
    canreadprivatereplies: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:readprivatereplies allowed.")
    canreplynews: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:replynews allowed.")
    canreplypost: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:replypost allowed.")
    cansplitdiscussions: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:splitdiscussions allowed.")
    canstartdiscussion: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:startdiscussion allowed.")
    canviewallratings: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:viewallratings allowed.")
    canviewanyrating: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:viewanyrating allowed.")
    canviewdiscussion: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:viewdiscussion allowed.")
    canviewhiddentimedposts: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:viewhiddentimedposts allowed.")
    canviewqandawithoutposting: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:viewqandawithoutposting allowed.")
    canviewrating: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:viewrating allowed.")
    canviewsubscribers: Optional[StrictBool] = Field(default=None, description="Whether the user has the capability mod/forum:viewsubscribers allowed.")
    warnings: Optional[List[AuthEmailGetSignupSettingsResponseWarningsInner]] = Field(default=None, description="list of warnings")
    __properties: ClassVar[List[str]] = ["canaddinstance", "canaddnews", "canaddquestion", "canallowforcesubscribe", "cancanmailnow", "cancanoverridecutoff", "cancanoverridediscussionlock", "cancanposttomygroups", "cancantogglefavourite", "cancreateattachment", "candeleteanypost", "candeleteownpost", "caneditanypost", "canexportdiscussion", "canexportforum", "canexportownpost", "canexportpost", "cangrade", "canmanagesubscriptions", "canmovediscussions", "canpindiscussions", "canpostprivatereply", "canpostwithoutthrottling", "canrate", "canreadprivatereplies", "canreplynews", "canreplypost", "cansplitdiscussions", "canstartdiscussion", "canviewallratings", "canviewanyrating", "canviewdiscussion", "canviewhiddentimedposts", "canviewqandawithoutposting", "canviewrating", "canviewsubscribers", "warnings"]

    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 ModForumGetForumAccessInformationResponse 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 warnings (list)
        _items = []
        if self.warnings:
            for _item_warnings in self.warnings:
                if _item_warnings:
                    _items.append(_item_warnings.to_dict())
            _dict['warnings'] = _items
        # set to None if canaddinstance (nullable) is None
        # and model_fields_set contains the field
        if self.canaddinstance is None and "canaddinstance" in self.model_fields_set:
            _dict['canaddinstance'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

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

        data = {
            "canaddinstance": obj.get("canaddinstance"),
            "canaddnews": obj.get("canaddnews"),
            "canaddquestion": obj.get("canaddquestion"),
            "canallowforcesubscribe": obj.get("canallowforcesubscribe"),
            "cancanmailnow": obj.get("cancanmailnow"),
            "cancanoverridecutoff": obj.get("cancanoverridecutoff"),
            "cancanoverridediscussionlock": obj.get("cancanoverridediscussionlock"),
            "cancanposttomygroups": obj.get("cancanposttomygroups"),
            "cancantogglefavourite": obj.get("cancantogglefavourite"),
            "cancreateattachment": obj.get("cancreateattachment"),
            "candeleteanypost": obj.get("candeleteanypost"),
            "candeleteownpost": obj.get("candeleteownpost"),
            "caneditanypost": obj.get("caneditanypost"),
            "canexportdiscussion": obj.get("canexportdiscussion"),
            "canexportforum": obj.get("canexportforum"),
            "canexportownpost": obj.get("canexportownpost"),
            "canexportpost": obj.get("canexportpost"),
            "cangrade": obj.get("cangrade"),
            "canmanagesubscriptions": obj.get("canmanagesubscriptions"),
            "canmovediscussions": obj.get("canmovediscussions"),
            "canpindiscussions": obj.get("canpindiscussions"),
            "canpostprivatereply": obj.get("canpostprivatereply"),
            "canpostwithoutthrottling": obj.get("canpostwithoutthrottling"),
            "canrate": obj.get("canrate"),
            "canreadprivatereplies": obj.get("canreadprivatereplies"),
            "canreplynews": obj.get("canreplynews"),
            "canreplypost": obj.get("canreplypost"),
            "cansplitdiscussions": obj.get("cansplitdiscussions"),
            "canstartdiscussion": obj.get("canstartdiscussion"),
            "canviewallratings": obj.get("canviewallratings"),
            "canviewanyrating": obj.get("canviewanyrating"),
            "canviewdiscussion": obj.get("canviewdiscussion"),
            "canviewhiddentimedposts": obj.get("canviewhiddentimedposts"),
            "canviewqandawithoutposting": obj.get("canviewqandawithoutposting"),
            "canviewrating": obj.get("canviewrating"),
            "canviewsubscribers": obj.get("canviewsubscribers"),
            "warnings": [AuthEmailGetSignupSettingsResponseWarningsInner.from_dict(_item) for _item in obj["warnings"]] if obj.get("warnings") is not None else None
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


