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

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

WidgetDataOutput(*args, **kwargs)
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)

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):
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
@classmethod
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> typing_extensions.Self:
169    @classmethod
170    def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
171        return cls.from_json(json.dumps(obj))
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

Returns the object represented by the json string

def to_json(self) -> str:
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)

Returns the JSON representation of the actual instance

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

Returns the dict representation of the actual instance

def to_str(self) -> str:
288    def to_str(self) -> str:
289        """Returns the string representation of the actual instance"""
290        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