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