miro_api.models.widget_data_output_platform
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 33WIDGETDATAOUTPUTPLATFORM_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 WidgetDataOutputPlatform(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[ 71 AppCardData, 72 CardData, 73 DocumentData, 74 EmbedData, 75 FrameData, 76 ImageData, 77 ShapeData, 78 StickyNoteData, 79 TextData, 80 ] 81 ] = None 82 one_of_schemas: List[str] = Field( 83 default=Literal[ 84 "AppCardData", 85 "CardData", 86 "DocumentData", 87 "EmbedData", 88 "FrameData", 89 "ImageData", 90 "ShapeData", 91 "StickyNoteData", 92 "TextData", 93 ] 94 ) 95 96 model_config = { 97 "validate_assignment": True, 98 "protected_namespaces": (), 99 } 100 101 def __init__(self, *args, **kwargs) -> None: 102 if args: 103 if len(args) > 1: 104 raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") 105 if kwargs: 106 raise ValueError("If a position argument is used, keyword arguments cannot be used.") 107 super().__init__(actual_instance=args[0]) 108 else: 109 super().__init__(**kwargs) 110 111 def __getattr__(self, attr: str): 112 return getattr(self.actual_instance, attr) 113 114 @field_validator("actual_instance") 115 def actual_instance_must_validate_oneof(cls, v): 116 instance = WidgetDataOutputPlatform.model_construct() 117 error_messages = [] 118 match = 0 119 # validate data type: TextData 120 if not isinstance(v, TextData): 121 error_messages.append(f"Error! Input type `{type(v)}` is not `TextData`") 122 else: 123 match += 1 124 # validate data type: EmbedData 125 if not isinstance(v, EmbedData): 126 error_messages.append(f"Error! Input type `{type(v)}` is not `EmbedData`") 127 else: 128 match += 1 129 # validate data type: CardData 130 if not isinstance(v, CardData): 131 error_messages.append(f"Error! Input type `{type(v)}` is not `CardData`") 132 else: 133 match += 1 134 # validate data type: AppCardData 135 if not isinstance(v, AppCardData): 136 error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardData`") 137 else: 138 match += 1 139 # validate data type: ImageData 140 if not isinstance(v, ImageData): 141 error_messages.append(f"Error! Input type `{type(v)}` is not `ImageData`") 142 else: 143 match += 1 144 # validate data type: DocumentData 145 if not isinstance(v, DocumentData): 146 error_messages.append(f"Error! Input type `{type(v)}` is not `DocumentData`") 147 else: 148 match += 1 149 # validate data type: ShapeData 150 if not isinstance(v, ShapeData): 151 error_messages.append(f"Error! Input type `{type(v)}` is not `ShapeData`") 152 else: 153 match += 1 154 # validate data type: FrameData 155 if not isinstance(v, FrameData): 156 error_messages.append(f"Error! Input type `{type(v)}` is not `FrameData`") 157 else: 158 match += 1 159 # validate data type: StickyNoteData 160 if not isinstance(v, StickyNoteData): 161 error_messages.append(f"Error! Input type `{type(v)}` is not `StickyNoteData`") 162 else: 163 match += 1 164 if match > 1: 165 # more than 1 match 166 raise ValueError( 167 "Multiple matches found when setting `actual_instance` in WidgetDataOutputPlatform with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: " 168 + ", ".join(error_messages) 169 ) 170 elif match == 0: 171 # no match 172 raise ValueError( 173 "No match found when setting `actual_instance` in WidgetDataOutputPlatform with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: " 174 + ", ".join(error_messages) 175 ) 176 else: 177 return v 178 179 @classmethod 180 def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: 181 return cls.from_json(json.dumps(obj)) 182 183 @classmethod 184 def from_json(cls, json_str: str) -> Union[ 185 AppCardData, 186 CardData, 187 DocumentData, 188 EmbedData, 189 FrameData, 190 ImageData, 191 ShapeData, 192 StickyNoteData, 193 TextData, 194 ]: 195 """Returns the object represented by the json string""" 196 instance = cls.model_construct() 197 error_messages = [] 198 matches = [] 199 200 # deserialize data into TextData 201 try: 202 instance.actual_instance = TextData.from_json(json_str) 203 matches.append(instance.actual_instance) 204 except (ValidationError, ValueError) as e: 205 error_messages.append(str(e)) 206 # deserialize data into EmbedData 207 try: 208 instance.actual_instance = EmbedData.from_json(json_str) 209 matches.append(instance.actual_instance) 210 except (ValidationError, ValueError) as e: 211 error_messages.append(str(e)) 212 # deserialize data into CardData 213 try: 214 instance.actual_instance = CardData.from_json(json_str) 215 matches.append(instance.actual_instance) 216 except (ValidationError, ValueError) as e: 217 error_messages.append(str(e)) 218 # deserialize data into AppCardData 219 try: 220 instance.actual_instance = AppCardData.from_json(json_str) 221 matches.append(instance.actual_instance) 222 except (ValidationError, ValueError) as e: 223 error_messages.append(str(e)) 224 # deserialize data into ImageData 225 try: 226 instance.actual_instance = ImageData.from_json(json_str) 227 matches.append(instance.actual_instance) 228 except (ValidationError, ValueError) as e: 229 error_messages.append(str(e)) 230 # deserialize data into DocumentData 231 try: 232 instance.actual_instance = DocumentData.from_json(json_str) 233 matches.append(instance.actual_instance) 234 except (ValidationError, ValueError) as e: 235 error_messages.append(str(e)) 236 # deserialize data into ShapeData 237 try: 238 instance.actual_instance = ShapeData.from_json(json_str) 239 matches.append(instance.actual_instance) 240 except (ValidationError, ValueError) as e: 241 error_messages.append(str(e)) 242 # deserialize data into FrameData 243 try: 244 instance.actual_instance = FrameData.from_json(json_str) 245 matches.append(instance.actual_instance) 246 except (ValidationError, ValueError) as e: 247 error_messages.append(str(e)) 248 # deserialize data into StickyNoteData 249 try: 250 instance.actual_instance = StickyNoteData.from_json(json_str) 251 matches.append(instance.actual_instance) 252 except (ValidationError, ValueError) as e: 253 error_messages.append(str(e)) 254 255 if not matches: 256 # no match 257 raise ValueError( 258 "No match found when deserializing the JSON string into WidgetDataOutputPlatform with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: " 259 + ", ".join(error_messages) 260 ) 261 262 # Return one match that has least additional_properties 263 if len(matches) > 1: 264 instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0] 265 266 return instance 267 268 def to_json(self) -> str: 269 """Returns the JSON representation of the actual instance""" 270 if self.actual_instance is None: 271 return "null" 272 273 if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): 274 return self.actual_instance.to_json() 275 else: 276 return json.dumps(self.actual_instance) 277 278 def to_dict( 279 self, 280 ) -> Optional[ 281 Union[ 282 Dict[str, Any], 283 AppCardData, 284 CardData, 285 DocumentData, 286 EmbedData, 287 FrameData, 288 ImageData, 289 ShapeData, 290 StickyNoteData, 291 TextData, 292 ] 293 ]: 294 """Returns the dict representation of the actual instance""" 295 if self.actual_instance is None: 296 return None 297 298 if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): 299 return self.actual_instance.to_dict() 300 else: 301 # primitive type 302 return self.actual_instance 303 304 def to_str(self) -> str: 305 """Returns the string representation of the actual instance""" 306 return pprint.pformat(self.model_dump())
47class WidgetDataOutputPlatform(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[ 72 AppCardData, 73 CardData, 74 DocumentData, 75 EmbedData, 76 FrameData, 77 ImageData, 78 ShapeData, 79 StickyNoteData, 80 TextData, 81 ] 82 ] = None 83 one_of_schemas: List[str] = Field( 84 default=Literal[ 85 "AppCardData", 86 "CardData", 87 "DocumentData", 88 "EmbedData", 89 "FrameData", 90 "ImageData", 91 "ShapeData", 92 "StickyNoteData", 93 "TextData", 94 ] 95 ) 96 97 model_config = { 98 "validate_assignment": True, 99 "protected_namespaces": (), 100 } 101 102 def __init__(self, *args, **kwargs) -> None: 103 if args: 104 if len(args) > 1: 105 raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") 106 if kwargs: 107 raise ValueError("If a position argument is used, keyword arguments cannot be used.") 108 super().__init__(actual_instance=args[0]) 109 else: 110 super().__init__(**kwargs) 111 112 def __getattr__(self, attr: str): 113 return getattr(self.actual_instance, attr) 114 115 @field_validator("actual_instance") 116 def actual_instance_must_validate_oneof(cls, v): 117 instance = WidgetDataOutputPlatform.model_construct() 118 error_messages = [] 119 match = 0 120 # validate data type: TextData 121 if not isinstance(v, TextData): 122 error_messages.append(f"Error! Input type `{type(v)}` is not `TextData`") 123 else: 124 match += 1 125 # validate data type: EmbedData 126 if not isinstance(v, EmbedData): 127 error_messages.append(f"Error! Input type `{type(v)}` is not `EmbedData`") 128 else: 129 match += 1 130 # validate data type: CardData 131 if not isinstance(v, CardData): 132 error_messages.append(f"Error! Input type `{type(v)}` is not `CardData`") 133 else: 134 match += 1 135 # validate data type: AppCardData 136 if not isinstance(v, AppCardData): 137 error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardData`") 138 else: 139 match += 1 140 # validate data type: ImageData 141 if not isinstance(v, ImageData): 142 error_messages.append(f"Error! Input type `{type(v)}` is not `ImageData`") 143 else: 144 match += 1 145 # validate data type: DocumentData 146 if not isinstance(v, DocumentData): 147 error_messages.append(f"Error! Input type `{type(v)}` is not `DocumentData`") 148 else: 149 match += 1 150 # validate data type: ShapeData 151 if not isinstance(v, ShapeData): 152 error_messages.append(f"Error! Input type `{type(v)}` is not `ShapeData`") 153 else: 154 match += 1 155 # validate data type: FrameData 156 if not isinstance(v, FrameData): 157 error_messages.append(f"Error! Input type `{type(v)}` is not `FrameData`") 158 else: 159 match += 1 160 # validate data type: StickyNoteData 161 if not isinstance(v, StickyNoteData): 162 error_messages.append(f"Error! Input type `{type(v)}` is not `StickyNoteData`") 163 else: 164 match += 1 165 if match > 1: 166 # more than 1 match 167 raise ValueError( 168 "Multiple matches found when setting `actual_instance` in WidgetDataOutputPlatform with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: " 169 + ", ".join(error_messages) 170 ) 171 elif match == 0: 172 # no match 173 raise ValueError( 174 "No match found when setting `actual_instance` in WidgetDataOutputPlatform with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: " 175 + ", ".join(error_messages) 176 ) 177 else: 178 return v 179 180 @classmethod 181 def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: 182 return cls.from_json(json.dumps(obj)) 183 184 @classmethod 185 def from_json(cls, json_str: str) -> Union[ 186 AppCardData, 187 CardData, 188 DocumentData, 189 EmbedData, 190 FrameData, 191 ImageData, 192 ShapeData, 193 StickyNoteData, 194 TextData, 195 ]: 196 """Returns the object represented by the json string""" 197 instance = cls.model_construct() 198 error_messages = [] 199 matches = [] 200 201 # deserialize data into TextData 202 try: 203 instance.actual_instance = TextData.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 EmbedData 208 try: 209 instance.actual_instance = EmbedData.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 CardData 214 try: 215 instance.actual_instance = CardData.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 AppCardData 220 try: 221 instance.actual_instance = AppCardData.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 ImageData 226 try: 227 instance.actual_instance = ImageData.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 DocumentData 232 try: 233 instance.actual_instance = DocumentData.from_json(json_str) 234 matches.append(instance.actual_instance) 235 except (ValidationError, ValueError) as e: 236 error_messages.append(str(e)) 237 # deserialize data into ShapeData 238 try: 239 instance.actual_instance = ShapeData.from_json(json_str) 240 matches.append(instance.actual_instance) 241 except (ValidationError, ValueError) as e: 242 error_messages.append(str(e)) 243 # deserialize data into FrameData 244 try: 245 instance.actual_instance = FrameData.from_json(json_str) 246 matches.append(instance.actual_instance) 247 except (ValidationError, ValueError) as e: 248 error_messages.append(str(e)) 249 # deserialize data into StickyNoteData 250 try: 251 instance.actual_instance = StickyNoteData.from_json(json_str) 252 matches.append(instance.actual_instance) 253 except (ValidationError, ValueError) as e: 254 error_messages.append(str(e)) 255 256 if not matches: 257 # no match 258 raise ValueError( 259 "No match found when deserializing the JSON string into WidgetDataOutputPlatform with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: " 260 + ", ".join(error_messages) 261 ) 262 263 # Return one match that has least additional_properties 264 if len(matches) > 1: 265 instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0] 266 267 return instance 268 269 def to_json(self) -> str: 270 """Returns the JSON representation of the actual instance""" 271 if self.actual_instance is None: 272 return "null" 273 274 if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): 275 return self.actual_instance.to_json() 276 else: 277 return json.dumps(self.actual_instance) 278 279 def to_dict( 280 self, 281 ) -> Optional[ 282 Union[ 283 Dict[str, Any], 284 AppCardData, 285 CardData, 286 DocumentData, 287 EmbedData, 288 FrameData, 289 ImageData, 290 ShapeData, 291 StickyNoteData, 292 TextData, 293 ] 294 ]: 295 """Returns the dict representation of the actual instance""" 296 if self.actual_instance is None: 297 return None 298 299 if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): 300 return self.actual_instance.to_dict() 301 else: 302 # primitive type 303 return self.actual_instance 304 305 def to_str(self) -> str: 306 """Returns the string representation of the actual instance""" 307 return pprint.pformat(self.model_dump())
Contains the item data, such as the item title, content, or description.
102 def __init__(self, *args, **kwargs) -> None: 103 if args: 104 if len(args) > 1: 105 raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") 106 if kwargs: 107 raise ValueError("If a position argument is used, keyword arguments cannot be used.") 108 super().__init__(actual_instance=args[0]) 109 else: 110 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.
115 @field_validator("actual_instance") 116 def actual_instance_must_validate_oneof(cls, v): 117 instance = WidgetDataOutputPlatform.model_construct() 118 error_messages = [] 119 match = 0 120 # validate data type: TextData 121 if not isinstance(v, TextData): 122 error_messages.append(f"Error! Input type `{type(v)}` is not `TextData`") 123 else: 124 match += 1 125 # validate data type: EmbedData 126 if not isinstance(v, EmbedData): 127 error_messages.append(f"Error! Input type `{type(v)}` is not `EmbedData`") 128 else: 129 match += 1 130 # validate data type: CardData 131 if not isinstance(v, CardData): 132 error_messages.append(f"Error! Input type `{type(v)}` is not `CardData`") 133 else: 134 match += 1 135 # validate data type: AppCardData 136 if not isinstance(v, AppCardData): 137 error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardData`") 138 else: 139 match += 1 140 # validate data type: ImageData 141 if not isinstance(v, ImageData): 142 error_messages.append(f"Error! Input type `{type(v)}` is not `ImageData`") 143 else: 144 match += 1 145 # validate data type: DocumentData 146 if not isinstance(v, DocumentData): 147 error_messages.append(f"Error! Input type `{type(v)}` is not `DocumentData`") 148 else: 149 match += 1 150 # validate data type: ShapeData 151 if not isinstance(v, ShapeData): 152 error_messages.append(f"Error! Input type `{type(v)}` is not `ShapeData`") 153 else: 154 match += 1 155 # validate data type: FrameData 156 if not isinstance(v, FrameData): 157 error_messages.append(f"Error! Input type `{type(v)}` is not `FrameData`") 158 else: 159 match += 1 160 # validate data type: StickyNoteData 161 if not isinstance(v, StickyNoteData): 162 error_messages.append(f"Error! Input type `{type(v)}` is not `StickyNoteData`") 163 else: 164 match += 1 165 if match > 1: 166 # more than 1 match 167 raise ValueError( 168 "Multiple matches found when setting `actual_instance` in WidgetDataOutputPlatform with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: " 169 + ", ".join(error_messages) 170 ) 171 elif match == 0: 172 # no match 173 raise ValueError( 174 "No match found when setting `actual_instance` in WidgetDataOutputPlatform with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: " 175 + ", ".join(error_messages) 176 ) 177 else: 178 return v
184 @classmethod 185 def from_json(cls, json_str: str) -> Union[ 186 AppCardData, 187 CardData, 188 DocumentData, 189 EmbedData, 190 FrameData, 191 ImageData, 192 ShapeData, 193 StickyNoteData, 194 TextData, 195 ]: 196 """Returns the object represented by the json string""" 197 instance = cls.model_construct() 198 error_messages = [] 199 matches = [] 200 201 # deserialize data into TextData 202 try: 203 instance.actual_instance = TextData.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 EmbedData 208 try: 209 instance.actual_instance = EmbedData.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 CardData 214 try: 215 instance.actual_instance = CardData.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 AppCardData 220 try: 221 instance.actual_instance = AppCardData.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 ImageData 226 try: 227 instance.actual_instance = ImageData.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 DocumentData 232 try: 233 instance.actual_instance = DocumentData.from_json(json_str) 234 matches.append(instance.actual_instance) 235 except (ValidationError, ValueError) as e: 236 error_messages.append(str(e)) 237 # deserialize data into ShapeData 238 try: 239 instance.actual_instance = ShapeData.from_json(json_str) 240 matches.append(instance.actual_instance) 241 except (ValidationError, ValueError) as e: 242 error_messages.append(str(e)) 243 # deserialize data into FrameData 244 try: 245 instance.actual_instance = FrameData.from_json(json_str) 246 matches.append(instance.actual_instance) 247 except (ValidationError, ValueError) as e: 248 error_messages.append(str(e)) 249 # deserialize data into StickyNoteData 250 try: 251 instance.actual_instance = StickyNoteData.from_json(json_str) 252 matches.append(instance.actual_instance) 253 except (ValidationError, ValueError) as e: 254 error_messages.append(str(e)) 255 256 if not matches: 257 # no match 258 raise ValueError( 259 "No match found when deserializing the JSON string into WidgetDataOutputPlatform with oneOf schemas: AppCardData, CardData, DocumentData, EmbedData, FrameData, ImageData, ShapeData, StickyNoteData, TextData. Details: " 260 + ", ".join(error_messages) 261 ) 262 263 # Return one match that has least additional_properties 264 if len(matches) > 1: 265 instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0] 266 267 return instance
Returns the object represented by the json string
269 def to_json(self) -> str: 270 """Returns the JSON representation of the actual instance""" 271 if self.actual_instance is None: 272 return "null" 273 274 if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): 275 return self.actual_instance.to_json() 276 else: 277 return json.dumps(self.actual_instance)
Returns the JSON representation of the actual instance
279 def to_dict( 280 self, 281 ) -> Optional[ 282 Union[ 283 Dict[str, Any], 284 AppCardData, 285 CardData, 286 DocumentData, 287 EmbedData, 288 FrameData, 289 ImageData, 290 ShapeData, 291 StickyNoteData, 292 TextData, 293 ] 294 ]: 295 """Returns the dict representation of the actual instance""" 296 if self.actual_instance is None: 297 return None 298 299 if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): 300 return self.actual_instance.to_dict() 301 else: 302 # primitive type 303 return self.actual_instance
Returns the dict representation of the actual instance
305 def to_str(self) -> str: 306 """Returns the string representation of the actual instance""" 307 return pprint.pformat(self.model_dump())
Returns the string representation of the actual instance
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