# coding: utf-8

"""
    Teambition Open API

    Teambition Open API

    The version of the OpenAPI document: 1.0.0
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from teambition_oapi_sdk.model.list_all_form_space_nodes_v3_response_result_inner_resource import ListAllFormSpaceNodesV3ResponseResultInnerResource
from typing import Optional, Set
from typing_extensions import Self

class ListAllFormSpaceNodesV3ResponseResultInner(BaseModel):
    """
    ListAllFormSpaceNodesV3ResponseResultInner
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="id")
    space_id: Optional[StrictStr] = Field(default=None, description="表单空间ID", alias="spaceId")
    ancestor_ids: Optional[List[StrictStr]] = Field(default=None, description="祖先节点ID数组，最后一个为父节点，倒数第二个为父节点的父节点，以此类推", alias="ancestorIds")
    resource_type: Optional[StrictStr] = Field(default=None, description="节点挂载资源类型，表单|表单分组|页面", alias="resourceType")
    resource_id: Optional[StrictStr] = Field(default=None, description="节点挂载资源ID", alias="resourceId")
    pos: Optional[StrictStr] = None
    creator_id: Optional[StrictStr] = Field(default=None, alias="creatorId")
    icon: Optional[StrictStr] = None
    payload: Optional[StrictStr] = None
    updated: Optional[datetime] = None
    created: Optional[datetime] = None
    is_deleted: Optional[StrictBool] = Field(default=None, alias="isDeleted")
    resource: Optional[ListAllFormSpaceNodesV3ResponseResultInnerResource] = None
    __properties: ClassVar[List[str]] = ["id", "spaceId", "ancestorIds", "resourceType", "resourceId", "pos", "creatorId", "icon", "payload", "updated", "created", "isDeleted", "resource"]

    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 ListAllFormSpaceNodesV3ResponseResultInner 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 resource
        if self.resource:
            _dict['resource'] = self.resource.to_dict()
        return _dict

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

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "spaceId": obj.get("spaceId"),
            "ancestorIds": obj.get("ancestorIds"),
            "resourceType": obj.get("resourceType"),
            "resourceId": obj.get("resourceId"),
            "pos": obj.get("pos"),
            "creatorId": obj.get("creatorId"),
            "icon": obj.get("icon"),
            "payload": obj.get("payload"),
            "updated": obj.get("updated"),
            "created": obj.get("created"),
            "isDeleted": obj.get("isDeleted"),
            "resource": ListAllFormSpaceNodesV3ResponseResultInnerResource.from_dict(obj["resource"]) if obj.get("resource") is not None else None
        })
        return _obj


