# 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 ModWorkshopGetWorkshopAccessInformationResponse(BaseModel):
    """
    ModWorkshopGetWorkshopAccessInformationResponse
    """ # noqa: E501
    assessingallowed: Optional[StrictBool] = Field(description="Is the user allowed to create/edit his assessments?")
    assessingexamplesallowed: Optional[StrictBool] = Field(description="Are reviewers allowed to create/edit their assessments of the example submissions?.")
    canaddinstance: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:addinstance allowed.")
    canallocate: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:allocate allowed.")
    candeletesubmissions: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:deletesubmissions allowed.")
    caneditdimensions: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:editdimensions allowed.")
    canexportsubmissions: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:exportsubmissions allowed.")
    canignoredeadlines: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:ignoredeadlines allowed.")
    canmanageexamples: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:manageexamples allowed.")
    canoverridegrades: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:overridegrades allowed.")
    canpeerassess: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:peerassess allowed.")
    canpublishsubmissions: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:publishsubmissions allowed.")
    cansubmit: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:submit allowed.")
    canswitchphase: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:switchphase allowed.")
    canview: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:view allowed.")
    canviewallassessments: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:viewallassessments allowed.")
    canviewallsubmissions: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:viewallsubmissions allowed.")
    canviewauthornames: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:viewauthornames allowed.")
    canviewauthorpublished: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:viewauthorpublished allowed.")
    canviewpublishedsubmissions: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:viewpublishedsubmissions allowed.")
    canviewreviewernames: Optional[StrictBool] = Field(description="Whether the user has the capability mod/workshop:viewreviewernames allowed.")
    creatingsubmissionallowed: Optional[StrictBool] = Field(description="Is the given user allowed to create their submission?")
    examplesassessedbeforeassessment: Optional[StrictBool] = Field(description="Whether the given user has assessed all his required examples before assessment                 (always true if there are not examples to assessor not configured to check before assessment).")
    examplesassessedbeforesubmission: Optional[StrictBool] = Field(description="Whether the given user has assessed all his required examples before submission                 (always true if there are not examples to assess or not configured to check before submission).")
    modifyingsubmissionallowed: Optional[StrictBool] = Field(description="Is the user allowed to modify his existing submission?")
    warnings: Optional[List[AuthEmailGetSignupSettingsResponseWarningsInner]] = Field(default=None, description="list of warnings")
    __properties: ClassVar[List[str]] = ["assessingallowed", "assessingexamplesallowed", "canaddinstance", "canallocate", "candeletesubmissions", "caneditdimensions", "canexportsubmissions", "canignoredeadlines", "canmanageexamples", "canoverridegrades", "canpeerassess", "canpublishsubmissions", "cansubmit", "canswitchphase", "canview", "canviewallassessments", "canviewallsubmissions", "canviewauthornames", "canviewauthorpublished", "canviewpublishedsubmissions", "canviewreviewernames", "creatingsubmissionallowed", "examplesassessedbeforeassessment", "examplesassessedbeforesubmission", "modifyingsubmissionallowed", "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 ModWorkshopGetWorkshopAccessInformationResponse 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 assessingallowed (nullable) is None
        # and model_fields_set contains the field
        if self.assessingallowed is None and "assessingallowed" in self.model_fields_set:
            _dict['assessingallowed'] = None

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

        # 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 canallocate (nullable) is None
        # and model_fields_set contains the field
        if self.canallocate is None and "canallocate" in self.model_fields_set:
            _dict['canallocate'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

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

        data = {
            "assessingallowed": obj.get("assessingallowed"),
            "assessingexamplesallowed": obj.get("assessingexamplesallowed"),
            "canaddinstance": obj.get("canaddinstance"),
            "canallocate": obj.get("canallocate"),
            "candeletesubmissions": obj.get("candeletesubmissions"),
            "caneditdimensions": obj.get("caneditdimensions"),
            "canexportsubmissions": obj.get("canexportsubmissions"),
            "canignoredeadlines": obj.get("canignoredeadlines"),
            "canmanageexamples": obj.get("canmanageexamples"),
            "canoverridegrades": obj.get("canoverridegrades"),
            "canpeerassess": obj.get("canpeerassess"),
            "canpublishsubmissions": obj.get("canpublishsubmissions"),
            "cansubmit": obj.get("cansubmit"),
            "canswitchphase": obj.get("canswitchphase"),
            "canview": obj.get("canview"),
            "canviewallassessments": obj.get("canviewallassessments"),
            "canviewallsubmissions": obj.get("canviewallsubmissions"),
            "canviewauthornames": obj.get("canviewauthornames"),
            "canviewauthorpublished": obj.get("canviewauthorpublished"),
            "canviewpublishedsubmissions": obj.get("canviewpublishedsubmissions"),
            "canviewreviewernames": obj.get("canviewreviewernames"),
            "creatingsubmissionallowed": obj.get("creatingsubmissionallowed"),
            "examplesassessedbeforeassessment": obj.get("examplesassessedbeforeassessment"),
            "examplesassessedbeforesubmission": obj.get("examplesassessedbeforesubmission"),
            "modifyingsubmissionallowed": obj.get("modifyingsubmissionallowed"),
            "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


