miro_api.models.widget_data_output

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

Contains the item data, such as the item title, content, or description.

WidgetDataOutput(*args, **kwargs)
 92    def __init__(self, *args, **kwargs) -> None:
 93        if args:
 94            if len(args) > 1:
 95                raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
 96            if kwargs:
 97                raise ValueError("If a position argument is used, keyword arguments cannot be used.")
 98            super().__init__(actual_instance=args[0])
 99        else:
100            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.text_data.TextData]
oneof_schema_2_validator: Optional[miro_api.models.embed_data.EmbedData]
oneof_schema_3_validator: Optional[miro_api.models.card_data.CardData]
oneof_schema_4_validator: Optional[miro_api.models.app_card_data.AppCardData]
oneof_schema_5_validator: Optional[miro_api.models.image_data.ImageData]
oneof_schema_6_validator: Optional[miro_api.models.document_data.DocumentData]
oneof_schema_7_validator: Optional[miro_api.models.shape_data.ShapeData]
oneof_schema_8_validator: Optional[miro_api.models.frame_data.FrameData]
oneof_schema_9_validator: Optional[miro_api.models.sticky_note_data.StickyNoteData]
one_of_schemas: List[str]
model_config = {'validate_assignment': True, 'protected_namespaces': ()}
@field_validator('actual_instance')
def actual_instance_must_validate_oneof(cls, v):
105    @field_validator("actual_instance")
106    def actual_instance_must_validate_oneof(cls, v):
107        instance = WidgetDataOutput.model_construct()
108        error_messages = []
109        match = 0
110        # validate data type: TextData
111        if not isinstance(v, TextData):
112            error_messages.append(f"Error! Input type `{type(v)}` is not `TextData`")
113        else:
114            match += 1
115        # validate data type: EmbedData
116        if not isinstance(v, EmbedData):
117            error_messages.append(f"Error! Input type `{type(v)}` is not `EmbedData`")
118        else:
119            match += 1
120        # validate data type: CardData
121        if not isinstance(v, CardData):
122            error_messages.append(f"Error! Input type `{type(v)}` is not `CardData`")
123        else:
124            match += 1
125        # validate data type: AppCardData
126        if not isinstance(v, AppCardData):
127            error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardData`")
128        else:
129            match += 1
130        # validate data type: ImageData
131        if not isinstance(v, ImageData):
132            error_messages.append(f"Error! Input type `{type(v)}` is not `ImageData`")
133        else:
134            match += 1
135        # validate data type: DocumentData
136        if not isinstance(v, DocumentData):
137            error_messages.append(f"Error! Input type `{type(v)}` is not `DocumentData`")
138        else:
139            match += 1
140        # validate data type: ShapeData
141        if not isinstance(v, ShapeData):
142            error_messages.append(f"Error! Input type `{type(v)}` is not `ShapeData`")
143        else:
144            match += 1
145        # validate data type: FrameData
146        if not isinstance(v, FrameData):
147            error_messages.append(f"Error! Input type `{type(v)}` is not `FrameData`")
148        else:
149            match += 1
150        # validate data type: StickyNoteData
151        if not isinstance(v, StickyNoteData):
152            error_messages.append(f"Error! Input type `{type(v)}` is not `StickyNoteData`")
153        else:
154            match += 1
155        if match > 1:
156            # more than 1 match
157            raise ValueError(
158                "Multiple matches found when setting `actual_instance` in WidgetDataOutput with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: "
159                + ", ".join(error_messages)
160            )
161        elif match == 0:
162            # no match
163            raise ValueError(
164                "No match found when setting `actual_instance` in WidgetDataOutput with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: "
165                + ", ".join(error_messages)
166            )
167        else:
168            return v
@classmethod
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> typing_extensions.Self:
170    @classmethod
171    def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
172        return cls.from_json(json.dumps(obj))
174    @classmethod
175    def from_json(
176        cls, json_str: str
177    ) -> Union[
178        AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData
179    ]:
180        """Returns the object represented by the json string"""
181        instance = cls.model_construct()
182        error_messages = []
183        matches = []
184
185        # deserialize data into TextData
186        try:
187            instance.actual_instance = TextData.from_json(json_str)
188            matches.append(instance.actual_instance)
189        except (ValidationError, ValueError) as e:
190            error_messages.append(str(e))
191        # deserialize data into EmbedData
192        try:
193            instance.actual_instance = EmbedData.from_json(json_str)
194            matches.append(instance.actual_instance)
195        except (ValidationError, ValueError) as e:
196            error_messages.append(str(e))
197        # deserialize data into CardData
198        try:
199            instance.actual_instance = CardData.from_json(json_str)
200            matches.append(instance.actual_instance)
201        except (ValidationError, ValueError) as e:
202            error_messages.append(str(e))
203        # deserialize data into AppCardData
204        try:
205            instance.actual_instance = AppCardData.from_json(json_str)
206            matches.append(instance.actual_instance)
207        except (ValidationError, ValueError) as e:
208            error_messages.append(str(e))
209        # deserialize data into ImageData
210        try:
211            instance.actual_instance = ImageData.from_json(json_str)
212            matches.append(instance.actual_instance)
213        except (ValidationError, ValueError) as e:
214            error_messages.append(str(e))
215        # deserialize data into DocumentData
216        try:
217            instance.actual_instance = DocumentData.from_json(json_str)
218            matches.append(instance.actual_instance)
219        except (ValidationError, ValueError) as e:
220            error_messages.append(str(e))
221        # deserialize data into ShapeData
222        try:
223            instance.actual_instance = ShapeData.from_json(json_str)
224            matches.append(instance.actual_instance)
225        except (ValidationError, ValueError) as e:
226            error_messages.append(str(e))
227        # deserialize data into FrameData
228        try:
229            instance.actual_instance = FrameData.from_json(json_str)
230            matches.append(instance.actual_instance)
231        except (ValidationError, ValueError) as e:
232            error_messages.append(str(e))
233        # deserialize data into StickyNoteData
234        try:
235            instance.actual_instance = StickyNoteData.from_json(json_str)
236            matches.append(instance.actual_instance)
237        except (ValidationError, ValueError) as e:
238            error_messages.append(str(e))
239
240        if not matches:
241            # no match
242            raise ValueError(
243                "No match found when deserializing the JSON string into WidgetDataOutput with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: "
244                + ", ".join(error_messages)
245            )
246
247        # Return one match that has least additional_properties
248        if len(matches) > 1:
249            instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0]
250
251        return instance

Returns the object represented by the json string

def to_json(self) -> str:
253    def to_json(self) -> str:
254        """Returns the JSON representation of the actual instance"""
255        if self.actual_instance is None:
256            return "null"
257
258        if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
259            return self.actual_instance.to_json()
260        else:
261            return json.dumps(self.actual_instance)

Returns the JSON representation of the actual instance

263    def to_dict(
264        self,
265    ) -> Optional[
266        Union[
267            Dict[str, Any],
268            AppCardData,
269            CardData,
270            DocumentData,
271            EmbedData,
272            FrameData,
273            ImageData,
274            ShapeData,
275            StickyNoteData,
276            TextData,
277        ]
278    ]:
279        """Returns the dict representation of the actual instance"""
280        if self.actual_instance is None:
281            return None
282
283        if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
284            return self.actual_instance.to_dict()
285        else:
286            # primitive type
287            return self.actual_instance

Returns the dict representation of the actual instance

def to_str(self) -> str:
289    def to_str(self) -> str:
290        """Returns the string representation of the actual instance"""
291        return pprint.pformat(self.model_dump())

Returns the string representation of the actual instance

model_fields = {'oneof_schema_1_validator': FieldInfo(annotation=Union[TextData, NoneType], required=False), 'oneof_schema_2_validator': FieldInfo(annotation=Union[EmbedData, NoneType], required=False), 'oneof_schema_3_validator': FieldInfo(annotation=Union[CardData, NoneType], required=False), 'oneof_schema_4_validator': FieldInfo(annotation=Union[AppCardData, NoneType], required=False), 'oneof_schema_5_validator': FieldInfo(annotation=Union[ImageData, NoneType], required=False), 'oneof_schema_6_validator': FieldInfo(annotation=Union[DocumentData, NoneType], required=False), 'oneof_schema_7_validator': FieldInfo(annotation=Union[ShapeData, NoneType], required=False), 'oneof_schema_8_validator': FieldInfo(annotation=Union[FrameData, NoneType], required=False), 'oneof_schema_9_validator': FieldInfo(annotation=Union[StickyNoteData, NoneType], required=False), 'actual_instance': FieldInfo(annotation=Union[AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData, NoneType], required=False), 'one_of_schemas': FieldInfo(annotation=List[str], required=False, default=typing_extensions.Literal['AppCardData', 'CardData', 'DocumentData', 'EmbedData', 'FrameData', 'ImageData', '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