# 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_reviewer import CoreCompetencyCreatePlanResponseReviewer
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class ToolDataprivacyGetDataRequestResponseResult(BaseModel):
    """
    ToolDataprivacyGetDataRequestResponseResult
    """ # noqa: E501
    allowfiltering: Optional[StrictBool] = Field(default=False, description="allowfiltering")
    approvedeny: Optional[StrictBool] = Field(default=False, description="approvedeny")
    canmarkcomplete: Optional[StrictBool] = Field(default=False, description="canmarkcomplete")
    canreview: Optional[StrictBool] = Field(default=False, description="canreview")
    comments: StrictStr = Field(description="comments")
    commentsformat: StrictInt = Field(description="commentsformat")
    creationmethod: StrictInt = Field(description="creationmethod")
    downloadlink: Optional[StrictStr] = Field(default='', description="downloadlink")
    dpo: Optional[StrictInt] = Field(description="dpo")
    dpocomment: Optional[StrictStr] = Field(description="dpocomment")
    dpocommentformat: StrictInt = Field(description="dpocommentformat")
    dpouser: Optional[CoreCompetencyCreatePlanResponseReviewer] = None
    foruser: CoreCompetencyCreatePlanResponseReviewer
    id: StrictInt = Field(description="id")
    messagehtml: Optional[StrictStr] = Field(default='', description="messagehtml")
    requestedby: StrictInt = Field(description="requestedby")
    requestedbyuser: Optional[CoreCompetencyCreatePlanResponseReviewer] = None
    status: StrictInt = Field(description="status")
    statuslabel: StrictStr = Field(description="statuslabel")
    statuslabelclass: StrictStr = Field(description="statuslabelclass")
    systemapproved: StrictBool = Field(description="systemapproved")
    timecreated: StrictInt = Field(description="timecreated")
    timemodified: StrictInt = Field(description="timemodified")
    type: StrictInt = Field(description="type")
    typename: StrictStr = Field(description="typename")
    typenameshort: StrictStr = Field(description="typenameshort")
    userid: StrictInt = Field(description="userid")
    usermodified: StrictInt = Field(description="usermodified")
    __properties: ClassVar[List[str]] = ["allowfiltering", "approvedeny", "canmarkcomplete", "canreview", "comments", "commentsformat", "creationmethod", "downloadlink", "dpo", "dpocomment", "dpocommentformat", "dpouser", "foruser", "id", "messagehtml", "requestedby", "requestedbyuser", "status", "statuslabel", "statuslabelclass", "systemapproved", "timecreated", "timemodified", "type", "typename", "typenameshort", "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 ToolDataprivacyGetDataRequestResponseResult 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 dpouser
        if self.dpouser:
            _dict['dpouser'] = self.dpouser.to_dict()
        # override the default output from pydantic by calling `to_dict()` of foruser
        if self.foruser:
            _dict['foruser'] = self.foruser.to_dict()
        # override the default output from pydantic by calling `to_dict()` of requestedbyuser
        if self.requestedbyuser:
            _dict['requestedbyuser'] = self.requestedbyuser.to_dict()
        # set to None if dpo (nullable) is None
        # and model_fields_set contains the field
        if self.dpo is None and "dpo" in self.model_fields_set:
            _dict['dpo'] = None

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

        return _dict

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

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

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

        data = {
            "allowfiltering": obj.get("allowfiltering") if obj.get("allowfiltering") is not None else False,
            "approvedeny": obj.get("approvedeny") if obj.get("approvedeny") is not None else False,
            "canmarkcomplete": obj.get("canmarkcomplete") if obj.get("canmarkcomplete") is not None else False,
            "canreview": obj.get("canreview") if obj.get("canreview") is not None else False,
            "comments": obj.get("comments") if obj.get("comments") is not None else '',
            "commentsformat": obj.get("commentsformat") if obj.get("commentsformat") is not None else 2,
            "creationmethod": obj.get("creationmethod") if obj.get("creationmethod") is not None else 0,
            "downloadlink": obj.get("downloadlink") if obj.get("downloadlink") is not None else '',
            "dpo": obj.get("dpo") if obj.get("dpo") is not None else 0,
            "dpocomment": obj.get("dpocomment") if obj.get("dpocomment") is not None else '',
            "dpocommentformat": obj.get("dpocommentformat") if obj.get("dpocommentformat") is not None else 2,
            "dpouser": CoreCompetencyCreatePlanResponseReviewer.from_dict(obj["dpouser"]) if obj.get("dpouser") is not None else None,
            "foruser": CoreCompetencyCreatePlanResponseReviewer.from_dict(obj["foruser"]) if obj.get("foruser") is not None else None,
            "id": obj.get("id") if obj.get("id") is not None else 0,
            "messagehtml": obj.get("messagehtml") if obj.get("messagehtml") is not None else '',
            "requestedby": obj.get("requestedby") if obj.get("requestedby") is not None else 0,
            "requestedbyuser": CoreCompetencyCreatePlanResponseReviewer.from_dict(obj["requestedbyuser"]) if obj.get("requestedbyuser") is not None else None,
            "status": obj.get("status") if obj.get("status") is not None else 0,
            "statuslabel": obj.get("statuslabel") if obj.get("statuslabel") is not None else '',
            "statuslabelclass": obj.get("statuslabelclass") if obj.get("statuslabelclass") is not None else '',
            "systemapproved": obj.get("systemapproved") if obj.get("systemapproved") is not None else False,
            "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,
            "type": obj.get("type") if obj.get("type") is not None else 0,
            "typename": obj.get("typename") if obj.get("typename") is not None else '',
            "typenameshort": obj.get("typenameshort") if obj.get("typenameshort") 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


