# 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_competency_create_plan_response_commentarea import CoreCompetencyCreatePlanResponseCommentarea
from poodle_async_full.models.core_competency_create_plan_response_reviewer import CoreCompetencyCreatePlanResponseReviewer
from poodle_async_full.models.core_competency_create_plan_response_template import CoreCompetencyCreatePlanResponseTemplate
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class CoreCompetencyUpdatePlanResponse(BaseModel):
    """
    CoreCompetencyUpdatePlanResponse
    """ # noqa: E501
    canbeedited: StrictBool = Field(description="canbeedited")
    canmanage: StrictBool = Field(description="canmanage")
    canrequestreview: StrictBool = Field(description="canrequestreview")
    canreview: StrictBool = Field(description="canreview")
    commentarea: CoreCompetencyCreatePlanResponseCommentarea
    description: StrictStr = Field(description="description")
    descriptionformat: Optional[StrictInt] = Field(default=1, description="description format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    duedate: StrictInt = Field(description="duedate")
    duedateformatted: StrictStr = Field(description="duedateformatted")
    id: StrictInt = Field(description="id")
    isactive: StrictBool = Field(description="isactive")
    isapproveallowed: StrictBool = Field(description="isapproveallowed")
    isbasedontemplate: StrictBool = Field(description="isbasedontemplate")
    iscancelreviewrequestallowed: StrictBool = Field(description="iscancelreviewrequestallowed")
    iscompleteallowed: StrictBool = Field(description="iscompleteallowed")
    iscompleted: StrictBool = Field(description="iscompleted")
    isdraft: StrictBool = Field(description="isdraft")
    isinreview: StrictBool = Field(description="isinreview")
    isreopenallowed: StrictBool = Field(description="isreopenallowed")
    isrequestreviewallowed: StrictBool = Field(description="isrequestreviewallowed")
    isstartreviewallowed: StrictBool = Field(description="isstartreviewallowed")
    isstopreviewallowed: StrictBool = Field(description="isstopreviewallowed")
    isunapproveallowed: StrictBool = Field(description="isunapproveallowed")
    isunlinkallowed: StrictBool = Field(description="isunlinkallowed")
    iswaitingforreview: StrictBool = Field(description="iswaitingforreview")
    name: StrictStr = Field(description="name")
    origtemplateid: Optional[StrictInt] = Field(description="origtemplateid")
    reviewer: Optional[CoreCompetencyCreatePlanResponseReviewer] = None
    reviewerid: Optional[StrictInt] = Field(description="reviewerid")
    status: StrictInt = Field(description="status")
    statusname: StrictStr = Field(description="statusname")
    template: Optional[CoreCompetencyCreatePlanResponseTemplate] = None
    templateid: Optional[StrictInt] = Field(description="templateid")
    timecreated: StrictInt = Field(description="timecreated")
    timemodified: StrictInt = Field(description="timemodified")
    url: StrictStr = Field(description="url")
    userid: StrictInt = Field(description="userid")
    usermodified: StrictInt = Field(description="usermodified")
    __properties: ClassVar[List[str]] = ["canbeedited", "canmanage", "canrequestreview", "canreview", "commentarea", "description", "descriptionformat", "duedate", "duedateformatted", "id", "isactive", "isapproveallowed", "isbasedontemplate", "iscancelreviewrequestallowed", "iscompleteallowed", "iscompleted", "isdraft", "isinreview", "isreopenallowed", "isrequestreviewallowed", "isstartreviewallowed", "isstopreviewallowed", "isunapproveallowed", "isunlinkallowed", "iswaitingforreview", "name", "origtemplateid", "reviewer", "reviewerid", "status", "statusname", "template", "templateid", "timecreated", "timemodified", "url", "userid", "usermodified"]

    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 CoreCompetencyUpdatePlanResponse 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 commentarea
        if self.commentarea:
            _dict['commentarea'] = self.commentarea.to_dict()
        # override the default output from pydantic by calling `to_dict()` of reviewer
        if self.reviewer:
            _dict['reviewer'] = self.reviewer.to_dict()
        # override the default output from pydantic by calling `to_dict()` of template
        if self.template:
            _dict['template'] = self.template.to_dict()
        # set to None if descriptionformat (nullable) is None
        # and model_fields_set contains the field
        if self.descriptionformat is None and "descriptionformat" in self.model_fields_set:
            _dict['descriptionformat'] = None

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

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

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

        return _dict

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

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

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

        data = {
            "canbeedited": obj.get("canbeedited") if obj.get("canbeedited") is not None else False,
            "canmanage": obj.get("canmanage") if obj.get("canmanage") is not None else False,
            "canrequestreview": obj.get("canrequestreview") if obj.get("canrequestreview") is not None else False,
            "canreview": obj.get("canreview") if obj.get("canreview") is not None else False,
            "commentarea": CoreCompetencyCreatePlanResponseCommentarea.from_dict(obj["commentarea"]) if obj.get("commentarea") is not None else None,
            "description": obj.get("description") if obj.get("description") is not None else '',
            "descriptionformat": obj.get("descriptionformat") if obj.get("descriptionformat") is not None else 1,
            "duedate": obj.get("duedate") if obj.get("duedate") is not None else 0,
            "duedateformatted": obj.get("duedateformatted") if obj.get("duedateformatted") is not None else '',
            "id": obj.get("id") if obj.get("id") is not None else 0,
            "isactive": obj.get("isactive") if obj.get("isactive") is not None else False,
            "isapproveallowed": obj.get("isapproveallowed") if obj.get("isapproveallowed") is not None else False,
            "isbasedontemplate": obj.get("isbasedontemplate") if obj.get("isbasedontemplate") is not None else False,
            "iscancelreviewrequestallowed": obj.get("iscancelreviewrequestallowed") if obj.get("iscancelreviewrequestallowed") is not None else False,
            "iscompleteallowed": obj.get("iscompleteallowed") if obj.get("iscompleteallowed") is not None else False,
            "iscompleted": obj.get("iscompleted") if obj.get("iscompleted") is not None else False,
            "isdraft": obj.get("isdraft") if obj.get("isdraft") is not None else False,
            "isinreview": obj.get("isinreview") if obj.get("isinreview") is not None else False,
            "isreopenallowed": obj.get("isreopenallowed") if obj.get("isreopenallowed") is not None else False,
            "isrequestreviewallowed": obj.get("isrequestreviewallowed") if obj.get("isrequestreviewallowed") is not None else False,
            "isstartreviewallowed": obj.get("isstartreviewallowed") if obj.get("isstartreviewallowed") is not None else False,
            "isstopreviewallowed": obj.get("isstopreviewallowed") if obj.get("isstopreviewallowed") is not None else False,
            "isunapproveallowed": obj.get("isunapproveallowed") if obj.get("isunapproveallowed") is not None else False,
            "isunlinkallowed": obj.get("isunlinkallowed") if obj.get("isunlinkallowed") is not None else False,
            "iswaitingforreview": obj.get("iswaitingforreview") if obj.get("iswaitingforreview") is not None else False,
            "name": obj.get("name") if obj.get("name") is not None else '',
            "origtemplateid": obj.get("origtemplateid"),
            "reviewer": CoreCompetencyCreatePlanResponseReviewer.from_dict(obj["reviewer"]) if obj.get("reviewer") is not None else None,
            "reviewerid": obj.get("reviewerid"),
            "status": obj.get("status") if obj.get("status") is not None else 0,
            "statusname": obj.get("statusname") if obj.get("statusname") is not None else '',
            "template": CoreCompetencyCreatePlanResponseTemplate.from_dict(obj["template"]) if obj.get("template") is not None else None,
            "templateid": obj.get("templateid"),
            "timecreated": obj.get("timecreated") if obj.get("timecreated") is not None else 0,
            "timemodified": obj.get("timemodified") if obj.get("timemodified") is not None else 0,
            "url": obj.get("url") if obj.get("url") is not None else '',
            "userid": obj.get("userid") if obj.get("userid") is not None else 0,
            "usermodified": obj.get("usermodified") if obj.get("usermodified") is not None else 0
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


