miro_api.models.item_data_changes
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.image_url_data_changes import ImageUrlDataChanges 21from pydantic import StrictStr, Field 22from typing import Union, List, Optional, Dict 23from typing_extensions import Literal, Self 24 25ITEMDATACHANGES_ONE_OF_SCHEMAS = ["AppCardData", "ImageUrlDataChanges"] 26 27 28class ItemDataChanges(BaseModel): 29 """ 30 Provides information about item-specific fields for update request. 31 """ 32 33 # data type: AppCardData 34 oneof_schema_1_validator: Optional[AppCardData] = None 35 # data type: ImageUrlDataChanges 36 oneof_schema_2_validator: Optional[ImageUrlDataChanges] = None 37 actual_instance: Optional[Union[AppCardData, ImageUrlDataChanges]] = None 38 one_of_schemas: List[str] = Field(default=Literal["AppCardData", "ImageUrlDataChanges"]) 39 40 model_config = { 41 "validate_assignment": True, 42 "protected_namespaces": (), 43 } 44 45 def __init__(self, *args, **kwargs) -> None: 46 if args: 47 if len(args) > 1: 48 raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") 49 if kwargs: 50 raise ValueError("If a position argument is used, keyword arguments cannot be used.") 51 super().__init__(actual_instance=args[0]) 52 else: 53 super().__init__(**kwargs) 54 55 def __getattr__(self, attr: str): 56 return getattr(self.actual_instance, attr) 57 58 @field_validator("actual_instance") 59 def actual_instance_must_validate_oneof(cls, v): 60 instance = ItemDataChanges.model_construct() 61 error_messages = [] 62 match = 0 63 # validate data type: AppCardData 64 if not isinstance(v, AppCardData): 65 error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardData`") 66 else: 67 match += 1 68 # validate data type: ImageUrlDataChanges 69 if not isinstance(v, ImageUrlDataChanges): 70 error_messages.append(f"Error! Input type `{type(v)}` is not `ImageUrlDataChanges`") 71 else: 72 match += 1 73 if match > 1: 74 # more than 1 match 75 raise ValueError( 76 "Multiple matches found when setting `actual_instance` in ItemDataChanges with oneOf schemas: AppCardData, ImageUrlDataChanges. Details: " 77 + ", ".join(error_messages) 78 ) 79 elif match == 0: 80 # no match 81 raise ValueError( 82 "No match found when setting `actual_instance` in ItemDataChanges with oneOf schemas: AppCardData, ImageUrlDataChanges. Details: " 83 + ", ".join(error_messages) 84 ) 85 else: 86 return v 87 88 @classmethod 89 def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: 90 return cls.from_json(json.dumps(obj)) 91 92 @classmethod 93 def from_json(cls, json_str: str) -> Union[AppCardData, ImageUrlDataChanges]: 94 """Returns the object represented by the json string""" 95 instance = cls.model_construct() 96 error_messages = [] 97 matches = [] 98 99 # deserialize data into AppCardData 100 try: 101 instance.actual_instance = AppCardData.from_json(json_str) 102 matches.append(instance.actual_instance) 103 except (ValidationError, ValueError) as e: 104 error_messages.append(str(e)) 105 # deserialize data into ImageUrlDataChanges 106 try: 107 instance.actual_instance = ImageUrlDataChanges.from_json(json_str) 108 matches.append(instance.actual_instance) 109 except (ValidationError, ValueError) as e: 110 error_messages.append(str(e)) 111 112 if not matches: 113 # no match 114 raise ValueError( 115 "No match found when deserializing the JSON string into ItemDataChanges with oneOf schemas: AppCardData, ImageUrlDataChanges. Details: " 116 + ", ".join(error_messages) 117 ) 118 119 # Return one match that has least additional_properties 120 if len(matches) > 1: 121 instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0] 122 123 return instance 124 125 def to_json(self) -> str: 126 """Returns the JSON representation of the actual instance""" 127 if self.actual_instance is None: 128 return "null" 129 130 if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): 131 return self.actual_instance.to_json() 132 else: 133 return json.dumps(self.actual_instance) 134 135 def to_dict(self) -> Optional[Union[Dict[str, Any], AppCardData, ImageUrlDataChanges]]: 136 """Returns the dict representation of the actual instance""" 137 if self.actual_instance is None: 138 return None 139 140 if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): 141 return self.actual_instance.to_dict() 142 else: 143 # primitive type 144 return self.actual_instance 145 146 def to_str(self) -> str: 147 """Returns the string representation of the actual instance""" 148 return pprint.pformat(self.model_dump())
29class ItemDataChanges(BaseModel): 30 """ 31 Provides information about item-specific fields for update request. 32 """ 33 34 # data type: AppCardData 35 oneof_schema_1_validator: Optional[AppCardData] = None 36 # data type: ImageUrlDataChanges 37 oneof_schema_2_validator: Optional[ImageUrlDataChanges] = None 38 actual_instance: Optional[Union[AppCardData, ImageUrlDataChanges]] = None 39 one_of_schemas: List[str] = Field(default=Literal["AppCardData", "ImageUrlDataChanges"]) 40 41 model_config = { 42 "validate_assignment": True, 43 "protected_namespaces": (), 44 } 45 46 def __init__(self, *args, **kwargs) -> None: 47 if args: 48 if len(args) > 1: 49 raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") 50 if kwargs: 51 raise ValueError("If a position argument is used, keyword arguments cannot be used.") 52 super().__init__(actual_instance=args[0]) 53 else: 54 super().__init__(**kwargs) 55 56 def __getattr__(self, attr: str): 57 return getattr(self.actual_instance, attr) 58 59 @field_validator("actual_instance") 60 def actual_instance_must_validate_oneof(cls, v): 61 instance = ItemDataChanges.model_construct() 62 error_messages = [] 63 match = 0 64 # validate data type: AppCardData 65 if not isinstance(v, AppCardData): 66 error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardData`") 67 else: 68 match += 1 69 # validate data type: ImageUrlDataChanges 70 if not isinstance(v, ImageUrlDataChanges): 71 error_messages.append(f"Error! Input type `{type(v)}` is not `ImageUrlDataChanges`") 72 else: 73 match += 1 74 if match > 1: 75 # more than 1 match 76 raise ValueError( 77 "Multiple matches found when setting `actual_instance` in ItemDataChanges with oneOf schemas: AppCardData, ImageUrlDataChanges. Details: " 78 + ", ".join(error_messages) 79 ) 80 elif match == 0: 81 # no match 82 raise ValueError( 83 "No match found when setting `actual_instance` in ItemDataChanges with oneOf schemas: AppCardData, ImageUrlDataChanges. Details: " 84 + ", ".join(error_messages) 85 ) 86 else: 87 return v 88 89 @classmethod 90 def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: 91 return cls.from_json(json.dumps(obj)) 92 93 @classmethod 94 def from_json(cls, json_str: str) -> Union[AppCardData, ImageUrlDataChanges]: 95 """Returns the object represented by the json string""" 96 instance = cls.model_construct() 97 error_messages = [] 98 matches = [] 99 100 # deserialize data into AppCardData 101 try: 102 instance.actual_instance = AppCardData.from_json(json_str) 103 matches.append(instance.actual_instance) 104 except (ValidationError, ValueError) as e: 105 error_messages.append(str(e)) 106 # deserialize data into ImageUrlDataChanges 107 try: 108 instance.actual_instance = ImageUrlDataChanges.from_json(json_str) 109 matches.append(instance.actual_instance) 110 except (ValidationError, ValueError) as e: 111 error_messages.append(str(e)) 112 113 if not matches: 114 # no match 115 raise ValueError( 116 "No match found when deserializing the JSON string into ItemDataChanges with oneOf schemas: AppCardData, ImageUrlDataChanges. Details: " 117 + ", ".join(error_messages) 118 ) 119 120 # Return one match that has least additional_properties 121 if len(matches) > 1: 122 instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0] 123 124 return instance 125 126 def to_json(self) -> str: 127 """Returns the JSON representation of the actual instance""" 128 if self.actual_instance is None: 129 return "null" 130 131 if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): 132 return self.actual_instance.to_json() 133 else: 134 return json.dumps(self.actual_instance) 135 136 def to_dict(self) -> Optional[Union[Dict[str, Any], AppCardData, ImageUrlDataChanges]]: 137 """Returns the dict representation of the actual instance""" 138 if self.actual_instance is None: 139 return None 140 141 if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): 142 return self.actual_instance.to_dict() 143 else: 144 # primitive type 145 return self.actual_instance 146 147 def to_str(self) -> str: 148 """Returns the string representation of the actual instance""" 149 return pprint.pformat(self.model_dump())
Provides information about item-specific fields for update request.
46 def __init__(self, *args, **kwargs) -> None: 47 if args: 48 if len(args) > 1: 49 raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") 50 if kwargs: 51 raise ValueError("If a position argument is used, keyword arguments cannot be used.") 52 super().__init__(actual_instance=args[0]) 53 else: 54 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.
59 @field_validator("actual_instance") 60 def actual_instance_must_validate_oneof(cls, v): 61 instance = ItemDataChanges.model_construct() 62 error_messages = [] 63 match = 0 64 # validate data type: AppCardData 65 if not isinstance(v, AppCardData): 66 error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardData`") 67 else: 68 match += 1 69 # validate data type: ImageUrlDataChanges 70 if not isinstance(v, ImageUrlDataChanges): 71 error_messages.append(f"Error! Input type `{type(v)}` is not `ImageUrlDataChanges`") 72 else: 73 match += 1 74 if match > 1: 75 # more than 1 match 76 raise ValueError( 77 "Multiple matches found when setting `actual_instance` in ItemDataChanges with oneOf schemas: AppCardData, ImageUrlDataChanges. Details: " 78 + ", ".join(error_messages) 79 ) 80 elif match == 0: 81 # no match 82 raise ValueError( 83 "No match found when setting `actual_instance` in ItemDataChanges with oneOf schemas: AppCardData, ImageUrlDataChanges. Details: " 84 + ", ".join(error_messages) 85 ) 86 else: 87 return v
93 @classmethod 94 def from_json(cls, json_str: str) -> Union[AppCardData, ImageUrlDataChanges]: 95 """Returns the object represented by the json string""" 96 instance = cls.model_construct() 97 error_messages = [] 98 matches = [] 99 100 # deserialize data into AppCardData 101 try: 102 instance.actual_instance = AppCardData.from_json(json_str) 103 matches.append(instance.actual_instance) 104 except (ValidationError, ValueError) as e: 105 error_messages.append(str(e)) 106 # deserialize data into ImageUrlDataChanges 107 try: 108 instance.actual_instance = ImageUrlDataChanges.from_json(json_str) 109 matches.append(instance.actual_instance) 110 except (ValidationError, ValueError) as e: 111 error_messages.append(str(e)) 112 113 if not matches: 114 # no match 115 raise ValueError( 116 "No match found when deserializing the JSON string into ItemDataChanges with oneOf schemas: AppCardData, ImageUrlDataChanges. Details: " 117 + ", ".join(error_messages) 118 ) 119 120 # Return one match that has least additional_properties 121 if len(matches) > 1: 122 instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0] 123 124 return instance
Returns the object represented by the json string
126 def to_json(self) -> str: 127 """Returns the JSON representation of the actual instance""" 128 if self.actual_instance is None: 129 return "null" 130 131 if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): 132 return self.actual_instance.to_json() 133 else: 134 return json.dumps(self.actual_instance)
Returns the JSON representation of the actual instance
136 def to_dict(self) -> Optional[Union[Dict[str, Any], AppCardData, ImageUrlDataChanges]]: 137 """Returns the dict representation of the actual instance""" 138 if self.actual_instance is None: 139 return None 140 141 if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): 142 return self.actual_instance.to_dict() 143 else: 144 # primitive type 145 return self.actual_instance
Returns the dict representation of the actual instance
147 def to_str(self) -> str: 148 """Returns the string representation of the actual instance""" 149 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