# 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.mod_bigbluebuttonbn_meeting_info_response_features_inner import ModBigbluebuttonbnMeetingInfoResponseFeaturesInner
from poodle_async_full.models.mod_bigbluebuttonbn_meeting_info_response_presentations_inner import ModBigbluebuttonbnMeetingInfoResponsePresentationsInner
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class ModBigbluebuttonbnMeetingInfoResponse(BaseModel):
    """
    ModBigbluebuttonbnMeetingInfoResponse
    """ # noqa: E501
    bigbluebuttonbnid: Optional[StrictStr] = Field(description="bigbluebuttonbn instance id")
    canjoin: Optional[StrictBool] = Field(description="Can join")
    closingtime: Optional[StrictInt] = Field(default=None, description="Closing time")
    cmid: Optional[StrictInt] = Field(description="CM id")
    features: Optional[List[ModBigbluebuttonbnMeetingInfoResponseFeaturesInner]] = Field(default=None, description="List of features for the instance")
    groupid: Optional[StrictInt] = Field(default=0, description="bigbluebuttonbn group id")
    guestaccessenabled: Optional[StrictBool] = Field(default=None, description="Guest access enabled")
    guestjoinurl: Optional[StrictStr] = Field(default=None, description="Guest URL")
    guestpassword: Optional[StrictStr] = Field(default=None, description="Guest join password")
    ismoderator: Optional[StrictBool] = Field(description="Is moderator")
    joinurl: Optional[StrictStr] = Field(description="Join URL")
    meetingid: Optional[StrictStr] = Field(description="Meeting id")
    moderatorcount: Optional[StrictInt] = Field(default=None, description="Moderator count")
    moderatorplural: Optional[StrictBool] = Field(default=None, description="Several moderators ?")
    openingtime: Optional[StrictInt] = Field(default=None, description="Opening time")
    participantcount: Optional[StrictInt] = Field(default=None, description="Participant count")
    participantplural: Optional[StrictBool] = Field(default=None, description="Several participants ?")
    presentations: List[ModBigbluebuttonbnMeetingInfoResponsePresentationsInner]
    showpresentations: Optional[StrictBool] = Field(default=None, description="Show presentation file")
    startedat: Optional[StrictInt] = Field(default=None, description="Started at")
    statusclosed: Optional[StrictBool] = Field(default=None, description="Status closed")
    statusmessage: Optional[StrictStr] = Field(default=None, description="Status message")
    statusopen: Optional[StrictBool] = Field(default=None, description="Status open")
    statusrunning: Optional[StrictBool] = Field(default=None, description="Status running")
    userlimit: Optional[StrictInt] = Field(description="User limit")
    __properties: ClassVar[List[str]] = ["bigbluebuttonbnid", "canjoin", "closingtime", "cmid", "features", "groupid", "guestaccessenabled", "guestjoinurl", "guestpassword", "ismoderator", "joinurl", "meetingid", "moderatorcount", "moderatorplural", "openingtime", "participantcount", "participantplural", "presentations", "showpresentations", "startedat", "statusclosed", "statusmessage", "statusopen", "statusrunning", "userlimit"]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

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

        data = {
            "bigbluebuttonbnid": obj.get("bigbluebuttonbnid"),
            "canjoin": obj.get("canjoin"),
            "closingtime": obj.get("closingtime"),
            "cmid": obj.get("cmid"),
            "features": [ModBigbluebuttonbnMeetingInfoResponseFeaturesInner.from_dict(_item) for _item in obj["features"]] if obj.get("features") is not None else None,
            "groupid": obj.get("groupid") if obj.get("groupid") is not None else 0,
            "guestaccessenabled": obj.get("guestaccessenabled"),
            "guestjoinurl": obj.get("guestjoinurl"),
            "guestpassword": obj.get("guestpassword"),
            "ismoderator": obj.get("ismoderator"),
            "joinurl": obj.get("joinurl"),
            "meetingid": obj.get("meetingid"),
            "moderatorcount": obj.get("moderatorcount"),
            "moderatorplural": obj.get("moderatorplural"),
            "openingtime": obj.get("openingtime"),
            "participantcount": obj.get("participantcount"),
            "participantplural": obj.get("participantplural"),
            "presentations": [ModBigbluebuttonbnMeetingInfoResponsePresentationsInner.from_dict(_item) for _item in obj["presentations"]] if obj.get("presentations") is not None else None,
            "showpresentations": obj.get("showpresentations"),
            "startedat": obj.get("startedat"),
            "statusclosed": obj.get("statusclosed"),
            "statusmessage": obj.get("statusmessage"),
            "statusopen": obj.get("statusopen"),
            "statusrunning": obj.get("statusrunning"),
            "userlimit": obj.get("userlimit")
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


