miro_api.models.parent_with_links

Miro Developer Platform

### Miro Developer Platform concepts - New to the Miro Developer Platform? Interested in learning more about platform concepts?? Read our introduction page and familiarize yourself with the Miro Developer Platform capabilities in a few minutes. ### Getting started with the Miro REST API - Quickstart (video): try the REST API in less than 3 minutes. - Quickstart (article): get started and try the REST API in less than 3 minutes. ### Miro REST API tutorials Check out our how-to articles with step-by-step instructions and code examples so you can: - Get started with OAuth 2.0 and Miro ### Miro App Examples Clone our Miro App Examples repository to get inspiration, customize, and explore apps built on top of Miro's Developer Platform 2.0.

The version of the OpenAPI document: v2.0 Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.

  1# coding: utf-8
  2
  3"""
  4Miro Developer Platform
  5
  6<img src=\"https://content.pstmn.io/47449ea6-0ef7-4af2-bac1-e58a70e61c58/aW1hZ2UucG5n\" width=\"1685\" height=\"593\">  ### Miro Developer Platform concepts  - New to the Miro Developer Platform? Interested in learning more about platform concepts?? [Read our introduction page](https://beta.developers.miro.com/docs/introduction) and familiarize yourself with the Miro Developer Platform capabilities in a few minutes.   ### Getting started with the Miro REST API  - [Quickstart (video):](https://beta.developers.miro.com/docs/try-out-the-rest-api-in-less-than-3-minutes) try the REST API in less than 3 minutes. - [Quickstart (article):](https://beta.developers.miro.com/docs/build-your-first-hello-world-app-1) get started and try the REST API in less than 3 minutes.   ### Miro REST API tutorials  Check out our how-to articles with step-by-step instructions and code examples so you can:  - [Get started with OAuth 2.0 and Miro](https://beta.developers.miro.com/docs/getting-started-with-oauth)   ### Miro App Examples  Clone our [Miro App Examples repository](https://github.com/miroapp/app-examples) to get inspiration, customize, and explore apps built on top of Miro's Developer Platform 2.0.
  7
  8The version of the OpenAPI document: v2.0
  9Generated by OpenAPI Generator (https://openapi-generator.tech)
 10
 11Do not edit the class manually.
 12"""  # noqa: E501
 13
 14from __future__ import annotations
 15import pprint
 16import re  # noqa: F401
 17import json
 18
 19from pydantic import BaseModel, Field, StrictStr
 20from typing import Any, ClassVar, Dict, List, Optional
 21from miro_api.models.self_link import SelfLink
 22from typing import Optional, Set
 23from typing_extensions import Self
 24
 25
 26class ParentWithLinks(BaseModel):
 27    """
 28    Contains information about the parent this item attached to.
 29    """  # noqa: E501
 30
 31    id: Optional[StrictStr] = Field(default=None, description="Unique identifier (ID) of a container item.")
 32    links: Optional[SelfLink] = None
 33    additional_properties: Dict[str, Any] = {}
 34    __properties: ClassVar[List[str]] = ["id", "links"]
 35
 36    model_config = {
 37        "populate_by_name": True,
 38        "validate_assignment": True,
 39        "protected_namespaces": (),
 40    }
 41
 42    def to_str(self) -> str:
 43        """Returns the string representation of the model using alias"""
 44        return pprint.pformat(self.model_dump(by_alias=True))
 45
 46    def to_json(self) -> str:
 47        """Returns the JSON representation of the model using alias"""
 48        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
 49        return json.dumps(self.to_dict())
 50
 51    @classmethod
 52    def from_json(cls, json_str: str) -> Optional[Self]:
 53        """Create an instance of ParentWithLinks from a JSON string"""
 54        return cls.from_dict(json.loads(json_str))
 55
 56    def to_dict(self) -> Dict[str, Any]:
 57        """Return the dictionary representation of the model using alias.
 58
 59        This has the following differences from calling pydantic's
 60        `self.model_dump(by_alias=True)`:
 61
 62        * `None` is only added to the output dict for nullable fields that
 63          were set at model initialization. Other fields with value `None`
 64          are ignored.
 65        * Fields in `self.additional_properties` are added to the output dict.
 66        """
 67        excluded_fields: Set[str] = set(
 68            [
 69                "additional_properties",
 70            ]
 71        )
 72
 73        _dict = self.model_dump(
 74            by_alias=True,
 75            exclude=excluded_fields,
 76            exclude_none=True,
 77        )
 78        # override the default output from pydantic by calling `to_dict()` of links
 79        if self.links:
 80            _dict["links"] = self.links.to_dict()
 81        # puts key-value pairs in additional_properties in the top level
 82        if self.additional_properties is not None:
 83            for _key, _value in self.additional_properties.items():
 84                _dict[_key] = _value
 85
 86        return _dict
 87
 88    @classmethod
 89    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
 90        """Create an instance of ParentWithLinks from a dict"""
 91        if obj is None:
 92            return None
 93
 94        if not isinstance(obj, dict):
 95            return cls.model_validate(obj)
 96
 97        _obj = cls.model_validate(
 98            {"id": obj.get("id"), "links": SelfLink.from_dict(obj["links"]) if obj.get("links") is not None else None}
 99        )
100        # store additional fields in additional_properties
101        for _key in obj.keys():
102            if _key not in cls.__properties:
103                _obj.additional_properties[_key] = obj.get(_key)
104
105        return _obj