miro_api.models.item_data_create

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 json
 16import pprint
 17from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator
 18from typing import Any, List, Optional
 19from miro_api.models.app_card_data import AppCardData
 20from miro_api.models.card_data import CardData
 21from miro_api.models.document_url_data import DocumentUrlData
 22from miro_api.models.embed_url_data import EmbedUrlData
 23from miro_api.models.image_url_data import ImageUrlData
 24from miro_api.models.shape_data import ShapeData
 25from miro_api.models.sticky_note_data import StickyNoteData
 26from miro_api.models.text_data import TextData
 27from pydantic import StrictStr, Field
 28from typing import Union, List, Optional, Dict
 29from typing_extensions import Literal, Self
 30
 31ITEMDATACREATE_ONE_OF_SCHEMAS = [
 32    "AppCardData",
 33    "CardData",
 34    "DocumentUrlData",
 35    "EmbedUrlData",
 36    "ImageUrlData",
 37    "ShapeData",
 38    "StickyNoteData",
 39    "TextData",
 40]
 41
 42
 43class ItemDataCreate(BaseModel):
 44    """
 45    Contains data information applicable for each item type.
 46    """
 47
 48    # data type: AppCardData
 49    oneof_schema_1_validator: Optional[AppCardData] = None
 50    # data type: CardData
 51    oneof_schema_2_validator: Optional[CardData] = None
 52    # data type: DocumentUrlData
 53    oneof_schema_3_validator: Optional[DocumentUrlData] = None
 54    # data type: EmbedUrlData
 55    oneof_schema_4_validator: Optional[EmbedUrlData] = None
 56    # data type: ImageUrlData
 57    oneof_schema_5_validator: Optional[ImageUrlData] = None
 58    # data type: ShapeData
 59    oneof_schema_6_validator: Optional[ShapeData] = None
 60    # data type: StickyNoteData
 61    oneof_schema_7_validator: Optional[StickyNoteData] = None
 62    # data type: TextData
 63    oneof_schema_8_validator: Optional[TextData] = None
 64    actual_instance: Optional[
 65        Union[AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData]
 66    ] = None
 67    one_of_schemas: List[str] = Field(
 68        default=Literal[
 69            "AppCardData",
 70            "CardData",
 71            "DocumentUrlData",
 72            "EmbedUrlData",
 73            "ImageUrlData",
 74            "ShapeData",
 75            "StickyNoteData",
 76            "TextData",
 77        ]
 78    )
 79
 80    model_config = {
 81        "validate_assignment": True,
 82        "protected_namespaces": (),
 83    }
 84
 85    def __init__(self, *args, **kwargs) -> None:
 86        if args:
 87            if len(args) > 1:
 88                raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
 89            if kwargs:
 90                raise ValueError("If a position argument is used, keyword arguments cannot be used.")
 91            super().__init__(actual_instance=args[0])
 92        else:
 93            super().__init__(**kwargs)
 94
 95    def __getattr__(self, attr: str):
 96        return getattr(self.actual_instance, attr)
 97
 98    @field_validator("actual_instance")
 99    def actual_instance_must_validate_oneof(cls, v):
100        instance = ItemDataCreate.model_construct()
101        error_messages = []
102        match = 0
103        # validate data type: AppCardData
104        if not isinstance(v, AppCardData):
105            error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardData`")
106        else:
107            match += 1
108        # validate data type: CardData
109        if not isinstance(v, CardData):
110            error_messages.append(f"Error! Input type `{type(v)}` is not `CardData`")
111        else:
112            match += 1
113        # validate data type: DocumentUrlData
114        if not isinstance(v, DocumentUrlData):
115            error_messages.append(f"Error! Input type `{type(v)}` is not `DocumentUrlData`")
116        else:
117            match += 1
118        # validate data type: EmbedUrlData
119        if not isinstance(v, EmbedUrlData):
120            error_messages.append(f"Error! Input type `{type(v)}` is not `EmbedUrlData`")
121        else:
122            match += 1
123        # validate data type: ImageUrlData
124        if not isinstance(v, ImageUrlData):
125            error_messages.append(f"Error! Input type `{type(v)}` is not `ImageUrlData`")
126        else:
127            match += 1
128        # validate data type: ShapeData
129        if not isinstance(v, ShapeData):
130            error_messages.append(f"Error! Input type `{type(v)}` is not `ShapeData`")
131        else:
132            match += 1
133        # validate data type: StickyNoteData
134        if not isinstance(v, StickyNoteData):
135            error_messages.append(f"Error! Input type `{type(v)}` is not `StickyNoteData`")
136        else:
137            match += 1
138        # validate data type: TextData
139        if not isinstance(v, TextData):
140            error_messages.append(f"Error! Input type `{type(v)}` is not `TextData`")
141        else:
142            match += 1
143        if match > 1:
144            # more than 1 match
145            raise ValueError(
146                "Multiple matches found when setting `actual_instance` in ItemDataCreate with oneOf schemas: AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData. Details: "
147                + ", ".join(error_messages)
148            )
149        elif match == 0:
150            # no match
151            raise ValueError(
152                "No match found when setting `actual_instance` in ItemDataCreate with oneOf schemas: AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData. Details: "
153                + ", ".join(error_messages)
154            )
155        else:
156            return v
157
158    @classmethod
159    def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
160        return cls.from_json(json.dumps(obj))
161
162    @classmethod
163    def from_json(
164        cls, json_str: str
165    ) -> Union[AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData]:
166        """Returns the object represented by the json string"""
167        instance = cls.model_construct()
168        error_messages = []
169        matches = []
170
171        # deserialize data into AppCardData
172        try:
173            instance.actual_instance = AppCardData.from_json(json_str)
174            matches.append(instance.actual_instance)
175        except (ValidationError, ValueError) as e:
176            error_messages.append(str(e))
177        # deserialize data into CardData
178        try:
179            instance.actual_instance = CardData.from_json(json_str)
180            matches.append(instance.actual_instance)
181        except (ValidationError, ValueError) as e:
182            error_messages.append(str(e))
183        # deserialize data into DocumentUrlData
184        try:
185            instance.actual_instance = DocumentUrlData.from_json(json_str)
186            matches.append(instance.actual_instance)
187        except (ValidationError, ValueError) as e:
188            error_messages.append(str(e))
189        # deserialize data into EmbedUrlData
190        try:
191            instance.actual_instance = EmbedUrlData.from_json(json_str)
192            matches.append(instance.actual_instance)
193        except (ValidationError, ValueError) as e:
194            error_messages.append(str(e))
195        # deserialize data into ImageUrlData
196        try:
197            instance.actual_instance = ImageUrlData.from_json(json_str)
198            matches.append(instance.actual_instance)
199        except (ValidationError, ValueError) as e:
200            error_messages.append(str(e))
201        # deserialize data into ShapeData
202        try:
203            instance.actual_instance = ShapeData.from_json(json_str)
204            matches.append(instance.actual_instance)
205        except (ValidationError, ValueError) as e:
206            error_messages.append(str(e))
207        # deserialize data into StickyNoteData
208        try:
209            instance.actual_instance = StickyNoteData.from_json(json_str)
210            matches.append(instance.actual_instance)
211        except (ValidationError, ValueError) as e:
212            error_messages.append(str(e))
213        # deserialize data into TextData
214        try:
215            instance.actual_instance = TextData.from_json(json_str)
216            matches.append(instance.actual_instance)
217        except (ValidationError, ValueError) as e:
218            error_messages.append(str(e))
219
220        if not matches:
221            # no match
222            raise ValueError(
223                "No match found when deserializing the JSON string into ItemDataCreate with oneOf schemas: AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData. Details: "
224                + ", ".join(error_messages)
225            )
226
227        # Return one match that has least additional_properties
228        if len(matches) > 1:
229            instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0]
230
231        return instance
232
233    def to_json(self) -> str:
234        """Returns the JSON representation of the actual instance"""
235        if self.actual_instance is None:
236            return "null"
237
238        if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
239            return self.actual_instance.to_json()
240        else:
241            return json.dumps(self.actual_instance)
242
243    def to_dict(
244        self,
245    ) -> Optional[
246        Union[
247            Dict[str, Any],
248            AppCardData,
249            CardData,
250            DocumentUrlData,
251            EmbedUrlData,
252            ImageUrlData,
253            ShapeData,
254            StickyNoteData,
255            TextData,
256        ]
257    ]:
258        """Returns the dict representation of the actual instance"""
259        if self.actual_instance is None:
260            return None
261
262        if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
263            return self.actual_instance.to_dict()
264        else:
265            # primitive type
266            return self.actual_instance
267
268    def to_str(self) -> str:
269        """Returns the string representation of the actual instance"""
270        return pprint.pformat(self.model_dump())
ITEMDATACREATE_ONE_OF_SCHEMAS = ['AppCardData', 'CardData', 'DocumentUrlData', 'EmbedUrlData', 'ImageUrlData', 'ShapeData', 'StickyNoteData', 'TextData']
class ItemDataCreate(pydantic.main.BaseModel):
 44class ItemDataCreate(BaseModel):
 45    """
 46    Contains data information applicable for each item type.
 47    """
 48
 49    # data type: AppCardData
 50    oneof_schema_1_validator: Optional[AppCardData] = None
 51    # data type: CardData
 52    oneof_schema_2_validator: Optional[CardData] = None
 53    # data type: DocumentUrlData
 54    oneof_schema_3_validator: Optional[DocumentUrlData] = None
 55    # data type: EmbedUrlData
 56    oneof_schema_4_validator: Optional[EmbedUrlData] = None
 57    # data type: ImageUrlData
 58    oneof_schema_5_validator: Optional[ImageUrlData] = None
 59    # data type: ShapeData
 60    oneof_schema_6_validator: Optional[ShapeData] = None
 61    # data type: StickyNoteData
 62    oneof_schema_7_validator: Optional[StickyNoteData] = None
 63    # data type: TextData
 64    oneof_schema_8_validator: Optional[TextData] = None
 65    actual_instance: Optional[
 66        Union[AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData]
 67    ] = None
 68    one_of_schemas: List[str] = Field(
 69        default=Literal[
 70            "AppCardData",
 71            "CardData",
 72            "DocumentUrlData",
 73            "EmbedUrlData",
 74            "ImageUrlData",
 75            "ShapeData",
 76            "StickyNoteData",
 77            "TextData",
 78        ]
 79    )
 80
 81    model_config = {
 82        "validate_assignment": True,
 83        "protected_namespaces": (),
 84    }
 85
 86    def __init__(self, *args, **kwargs) -> None:
 87        if args:
 88            if len(args) > 1:
 89                raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
 90            if kwargs:
 91                raise ValueError("If a position argument is used, keyword arguments cannot be used.")
 92            super().__init__(actual_instance=args[0])
 93        else:
 94            super().__init__(**kwargs)
 95
 96    def __getattr__(self, attr: str):
 97        return getattr(self.actual_instance, attr)
 98
 99    @field_validator("actual_instance")
100    def actual_instance_must_validate_oneof(cls, v):
101        instance = ItemDataCreate.model_construct()
102        error_messages = []
103        match = 0
104        # validate data type: AppCardData
105        if not isinstance(v, AppCardData):
106            error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardData`")
107        else:
108            match += 1
109        # validate data type: CardData
110        if not isinstance(v, CardData):
111            error_messages.append(f"Error! Input type `{type(v)}` is not `CardData`")
112        else:
113            match += 1
114        # validate data type: DocumentUrlData
115        if not isinstance(v, DocumentUrlData):
116            error_messages.append(f"Error! Input type `{type(v)}` is not `DocumentUrlData`")
117        else:
118            match += 1
119        # validate data type: EmbedUrlData
120        if not isinstance(v, EmbedUrlData):
121            error_messages.append(f"Error! Input type `{type(v)}` is not `EmbedUrlData`")
122        else:
123            match += 1
124        # validate data type: ImageUrlData
125        if not isinstance(v, ImageUrlData):
126            error_messages.append(f"Error! Input type `{type(v)}` is not `ImageUrlData`")
127        else:
128            match += 1
129        # validate data type: ShapeData
130        if not isinstance(v, ShapeData):
131            error_messages.append(f"Error! Input type `{type(v)}` is not `ShapeData`")
132        else:
133            match += 1
134        # validate data type: StickyNoteData
135        if not isinstance(v, StickyNoteData):
136            error_messages.append(f"Error! Input type `{type(v)}` is not `StickyNoteData`")
137        else:
138            match += 1
139        # validate data type: TextData
140        if not isinstance(v, TextData):
141            error_messages.append(f"Error! Input type `{type(v)}` is not `TextData`")
142        else:
143            match += 1
144        if match > 1:
145            # more than 1 match
146            raise ValueError(
147                "Multiple matches found when setting `actual_instance` in ItemDataCreate with oneOf schemas: AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData. Details: "
148                + ", ".join(error_messages)
149            )
150        elif match == 0:
151            # no match
152            raise ValueError(
153                "No match found when setting `actual_instance` in ItemDataCreate with oneOf schemas: AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData. Details: "
154                + ", ".join(error_messages)
155            )
156        else:
157            return v
158
159    @classmethod
160    def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
161        return cls.from_json(json.dumps(obj))
162
163    @classmethod
164    def from_json(
165        cls, json_str: str
166    ) -> Union[AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData]:
167        """Returns the object represented by the json string"""
168        instance = cls.model_construct()
169        error_messages = []
170        matches = []
171
172        # deserialize data into AppCardData
173        try:
174            instance.actual_instance = AppCardData.from_json(json_str)
175            matches.append(instance.actual_instance)
176        except (ValidationError, ValueError) as e:
177            error_messages.append(str(e))
178        # deserialize data into CardData
179        try:
180            instance.actual_instance = CardData.from_json(json_str)
181            matches.append(instance.actual_instance)
182        except (ValidationError, ValueError) as e:
183            error_messages.append(str(e))
184        # deserialize data into DocumentUrlData
185        try:
186            instance.actual_instance = DocumentUrlData.from_json(json_str)
187            matches.append(instance.actual_instance)
188        except (ValidationError, ValueError) as e:
189            error_messages.append(str(e))
190        # deserialize data into EmbedUrlData
191        try:
192            instance.actual_instance = EmbedUrlData.from_json(json_str)
193            matches.append(instance.actual_instance)
194        except (ValidationError, ValueError) as e:
195            error_messages.append(str(e))
196        # deserialize data into ImageUrlData
197        try:
198            instance.actual_instance = ImageUrlData.from_json(json_str)
199            matches.append(instance.actual_instance)
200        except (ValidationError, ValueError) as e:
201            error_messages.append(str(e))
202        # deserialize data into ShapeData
203        try:
204            instance.actual_instance = ShapeData.from_json(json_str)
205            matches.append(instance.actual_instance)
206        except (ValidationError, ValueError) as e:
207            error_messages.append(str(e))
208        # deserialize data into StickyNoteData
209        try:
210            instance.actual_instance = StickyNoteData.from_json(json_str)
211            matches.append(instance.actual_instance)
212        except (ValidationError, ValueError) as e:
213            error_messages.append(str(e))
214        # deserialize data into TextData
215        try:
216            instance.actual_instance = TextData.from_json(json_str)
217            matches.append(instance.actual_instance)
218        except (ValidationError, ValueError) as e:
219            error_messages.append(str(e))
220
221        if not matches:
222            # no match
223            raise ValueError(
224                "No match found when deserializing the JSON string into ItemDataCreate with oneOf schemas: AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData. Details: "
225                + ", ".join(error_messages)
226            )
227
228        # Return one match that has least additional_properties
229        if len(matches) > 1:
230            instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0]
231
232        return instance
233
234    def to_json(self) -> str:
235        """Returns the JSON representation of the actual instance"""
236        if self.actual_instance is None:
237            return "null"
238
239        if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
240            return self.actual_instance.to_json()
241        else:
242            return json.dumps(self.actual_instance)
243
244    def to_dict(
245        self,
246    ) -> Optional[
247        Union[
248            Dict[str, Any],
249            AppCardData,
250            CardData,
251            DocumentUrlData,
252            EmbedUrlData,
253            ImageUrlData,
254            ShapeData,
255            StickyNoteData,
256            TextData,
257        ]
258    ]:
259        """Returns the dict representation of the actual instance"""
260        if self.actual_instance is None:
261            return None
262
263        if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
264            return self.actual_instance.to_dict()
265        else:
266            # primitive type
267            return self.actual_instance
268
269    def to_str(self) -> str:
270        """Returns the string representation of the actual instance"""
271        return pprint.pformat(self.model_dump())

Contains data information applicable for each item type.

ItemDataCreate(*args, **kwargs)
86    def __init__(self, *args, **kwargs) -> None:
87        if args:
88            if len(args) > 1:
89                raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
90            if kwargs:
91                raise ValueError("If a position argument is used, keyword arguments cannot be used.")
92            super().__init__(actual_instance=args[0])
93        else:
94            super().__init__(**kwargs)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

oneof_schema_1_validator: Optional[miro_api.models.app_card_data.AppCardData]
oneof_schema_2_validator: Optional[miro_api.models.card_data.CardData]
oneof_schema_3_validator: Optional[miro_api.models.document_url_data.DocumentUrlData]
oneof_schema_4_validator: Optional[miro_api.models.embed_url_data.EmbedUrlData]
oneof_schema_5_validator: Optional[miro_api.models.image_url_data.ImageUrlData]
oneof_schema_6_validator: Optional[miro_api.models.shape_data.ShapeData]
oneof_schema_7_validator: Optional[miro_api.models.sticky_note_data.StickyNoteData]
oneof_schema_8_validator: Optional[miro_api.models.text_data.TextData]
one_of_schemas: List[str]
model_config = {'validate_assignment': True, 'protected_namespaces': ()}
@field_validator('actual_instance')
def actual_instance_must_validate_oneof(cls, v):
 99    @field_validator("actual_instance")
100    def actual_instance_must_validate_oneof(cls, v):
101        instance = ItemDataCreate.model_construct()
102        error_messages = []
103        match = 0
104        # validate data type: AppCardData
105        if not isinstance(v, AppCardData):
106            error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardData`")
107        else:
108            match += 1
109        # validate data type: CardData
110        if not isinstance(v, CardData):
111            error_messages.append(f"Error! Input type `{type(v)}` is not `CardData`")
112        else:
113            match += 1
114        # validate data type: DocumentUrlData
115        if not isinstance(v, DocumentUrlData):
116            error_messages.append(f"Error! Input type `{type(v)}` is not `DocumentUrlData`")
117        else:
118            match += 1
119        # validate data type: EmbedUrlData
120        if not isinstance(v, EmbedUrlData):
121            error_messages.append(f"Error! Input type `{type(v)}` is not `EmbedUrlData`")
122        else:
123            match += 1
124        # validate data type: ImageUrlData
125        if not isinstance(v, ImageUrlData):
126            error_messages.append(f"Error! Input type `{type(v)}` is not `ImageUrlData`")
127        else:
128            match += 1
129        # validate data type: ShapeData
130        if not isinstance(v, ShapeData):
131            error_messages.append(f"Error! Input type `{type(v)}` is not `ShapeData`")
132        else:
133            match += 1
134        # validate data type: StickyNoteData
135        if not isinstance(v, StickyNoteData):
136            error_messages.append(f"Error! Input type `{type(v)}` is not `StickyNoteData`")
137        else:
138            match += 1
139        # validate data type: TextData
140        if not isinstance(v, TextData):
141            error_messages.append(f"Error! Input type `{type(v)}` is not `TextData`")
142        else:
143            match += 1
144        if match > 1:
145            # more than 1 match
146            raise ValueError(
147                "Multiple matches found when setting `actual_instance` in ItemDataCreate with oneOf schemas: AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData. Details: "
148                + ", ".join(error_messages)
149            )
150        elif match == 0:
151            # no match
152            raise ValueError(
153                "No match found when setting `actual_instance` in ItemDataCreate with oneOf schemas: AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData. Details: "
154                + ", ".join(error_messages)
155            )
156        else:
157            return v
@classmethod
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> typing_extensions.Self:
159    @classmethod
160    def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
161        return cls.from_json(json.dumps(obj))
163    @classmethod
164    def from_json(
165        cls, json_str: str
166    ) -> Union[AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData]:
167        """Returns the object represented by the json string"""
168        instance = cls.model_construct()
169        error_messages = []
170        matches = []
171
172        # deserialize data into AppCardData
173        try:
174            instance.actual_instance = AppCardData.from_json(json_str)
175            matches.append(instance.actual_instance)
176        except (ValidationError, ValueError) as e:
177            error_messages.append(str(e))
178        # deserialize data into CardData
179        try:
180            instance.actual_instance = CardData.from_json(json_str)
181            matches.append(instance.actual_instance)
182        except (ValidationError, ValueError) as e:
183            error_messages.append(str(e))
184        # deserialize data into DocumentUrlData
185        try:
186            instance.actual_instance = DocumentUrlData.from_json(json_str)
187            matches.append(instance.actual_instance)
188        except (ValidationError, ValueError) as e:
189            error_messages.append(str(e))
190        # deserialize data into EmbedUrlData
191        try:
192            instance.actual_instance = EmbedUrlData.from_json(json_str)
193            matches.append(instance.actual_instance)
194        except (ValidationError, ValueError) as e:
195            error_messages.append(str(e))
196        # deserialize data into ImageUrlData
197        try:
198            instance.actual_instance = ImageUrlData.from_json(json_str)
199            matches.append(instance.actual_instance)
200        except (ValidationError, ValueError) as e:
201            error_messages.append(str(e))
202        # deserialize data into ShapeData
203        try:
204            instance.actual_instance = ShapeData.from_json(json_str)
205            matches.append(instance.actual_instance)
206        except (ValidationError, ValueError) as e:
207            error_messages.append(str(e))
208        # deserialize data into StickyNoteData
209        try:
210            instance.actual_instance = StickyNoteData.from_json(json_str)
211            matches.append(instance.actual_instance)
212        except (ValidationError, ValueError) as e:
213            error_messages.append(str(e))
214        # deserialize data into TextData
215        try:
216            instance.actual_instance = TextData.from_json(json_str)
217            matches.append(instance.actual_instance)
218        except (ValidationError, ValueError) as e:
219            error_messages.append(str(e))
220
221        if not matches:
222            # no match
223            raise ValueError(
224                "No match found when deserializing the JSON string into ItemDataCreate with oneOf schemas: AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData. Details: "
225                + ", ".join(error_messages)
226            )
227
228        # Return one match that has least additional_properties
229        if len(matches) > 1:
230            instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0]
231
232        return instance

Returns the object represented by the json string

def to_json(self) -> str:
234    def to_json(self) -> str:
235        """Returns the JSON representation of the actual instance"""
236        if self.actual_instance is None:
237            return "null"
238
239        if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
240            return self.actual_instance.to_json()
241        else:
242            return json.dumps(self.actual_instance)

Returns the JSON representation of the actual instance

244    def to_dict(
245        self,
246    ) -> Optional[
247        Union[
248            Dict[str, Any],
249            AppCardData,
250            CardData,
251            DocumentUrlData,
252            EmbedUrlData,
253            ImageUrlData,
254            ShapeData,
255            StickyNoteData,
256            TextData,
257        ]
258    ]:
259        """Returns the dict representation of the actual instance"""
260        if self.actual_instance is None:
261            return None
262
263        if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
264            return self.actual_instance.to_dict()
265        else:
266            # primitive type
267            return self.actual_instance

Returns the dict representation of the actual instance

def to_str(self) -> str:
269    def to_str(self) -> str:
270        """Returns the string representation of the actual instance"""
271        return pprint.pformat(self.model_dump())

Returns the string representation of the actual instance

model_fields = {'oneof_schema_1_validator': FieldInfo(annotation=Union[AppCardData, NoneType], required=False), 'oneof_schema_2_validator': FieldInfo(annotation=Union[CardData, NoneType], required=False), 'oneof_schema_3_validator': FieldInfo(annotation=Union[DocumentUrlData, NoneType], required=False), 'oneof_schema_4_validator': FieldInfo(annotation=Union[EmbedUrlData, NoneType], required=False), 'oneof_schema_5_validator': FieldInfo(annotation=Union[ImageUrlData, NoneType], required=False), 'oneof_schema_6_validator': FieldInfo(annotation=Union[ShapeData, NoneType], required=False), 'oneof_schema_7_validator': FieldInfo(annotation=Union[StickyNoteData, NoneType], required=False), 'oneof_schema_8_validator': FieldInfo(annotation=Union[TextData, NoneType], required=False), 'actual_instance': FieldInfo(annotation=Union[AppCardData, CardData, DocumentUrlData, EmbedUrlData, ImageUrlData, ShapeData, StickyNoteData, TextData, NoneType], required=False), 'one_of_schemas': FieldInfo(annotation=List[str], required=False, default=typing_extensions.Literal['AppCardData', 'CardData', 'DocumentUrlData', 'EmbedUrlData', 'ImageUrlData', 'ShapeData', 'StickyNoteData', 'TextData'])}
model_computed_fields = {}
Inherited Members
pydantic.main.BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs