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