miro_api.models.item_style
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_style import AppCardStyle 21from miro_api.models.card_style import CardStyle 22from miro_api.models.shape_style import ShapeStyle 23from miro_api.models.sticky_note_style import StickyNoteStyle 24from miro_api.models.text_style import TextStyle 25from pydantic import StrictStr, Field 26from typing import Union, List, Optional, Dict 27from typing_extensions import Literal, Self 28 29ITEMSTYLE_ONE_OF_SCHEMAS = ["AppCardStyle", "CardStyle", "ShapeStyle", "StickyNoteStyle", "TextStyle"] 30 31 32class ItemStyle(BaseModel): 33 """ 34 Contains information about item-specific styles. 35 """ 36 37 # data type: AppCardStyle 38 oneof_schema_1_validator: Optional[AppCardStyle] = None 39 # data type: CardStyle 40 oneof_schema_2_validator: Optional[CardStyle] = None 41 # data type: ShapeStyle 42 oneof_schema_3_validator: Optional[ShapeStyle] = None 43 # data type: StickyNoteStyle 44 oneof_schema_4_validator: Optional[StickyNoteStyle] = None 45 # data type: TextStyle 46 oneof_schema_5_validator: Optional[TextStyle] = None 47 actual_instance: Optional[Union[AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle]] = None 48 one_of_schemas: List[str] = Field( 49 default=Literal["AppCardStyle", "CardStyle", "ShapeStyle", "StickyNoteStyle", "TextStyle"] 50 ) 51 52 model_config = { 53 "validate_assignment": True, 54 "protected_namespaces": (), 55 } 56 57 def __init__(self, *args, **kwargs) -> None: 58 if args: 59 if len(args) > 1: 60 raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") 61 if kwargs: 62 raise ValueError("If a position argument is used, keyword arguments cannot be used.") 63 super().__init__(actual_instance=args[0]) 64 else: 65 super().__init__(**kwargs) 66 67 def __getattr__(self, attr: str): 68 return getattr(self.actual_instance, attr) 69 70 @field_validator("actual_instance") 71 def actual_instance_must_validate_oneof(cls, v): 72 instance = ItemStyle.model_construct() 73 error_messages = [] 74 match = 0 75 # validate data type: AppCardStyle 76 if not isinstance(v, AppCardStyle): 77 error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardStyle`") 78 else: 79 match += 1 80 # validate data type: CardStyle 81 if not isinstance(v, CardStyle): 82 error_messages.append(f"Error! Input type `{type(v)}` is not `CardStyle`") 83 else: 84 match += 1 85 # validate data type: ShapeStyle 86 if not isinstance(v, ShapeStyle): 87 error_messages.append(f"Error! Input type `{type(v)}` is not `ShapeStyle`") 88 else: 89 match += 1 90 # validate data type: StickyNoteStyle 91 if not isinstance(v, StickyNoteStyle): 92 error_messages.append(f"Error! Input type `{type(v)}` is not `StickyNoteStyle`") 93 else: 94 match += 1 95 # validate data type: TextStyle 96 if not isinstance(v, TextStyle): 97 error_messages.append(f"Error! Input type `{type(v)}` is not `TextStyle`") 98 else: 99 match += 1 100 if match > 1: 101 # more than 1 match 102 raise ValueError( 103 "Multiple matches found when setting `actual_instance` in ItemStyle with oneOf schemas: AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle. Details: " 104 + ", ".join(error_messages) 105 ) 106 elif match == 0: 107 # no match 108 raise ValueError( 109 "No match found when setting `actual_instance` in ItemStyle with oneOf schemas: AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle. Details: " 110 + ", ".join(error_messages) 111 ) 112 else: 113 return v 114 115 @classmethod 116 def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: 117 return cls.from_json(json.dumps(obj)) 118 119 @classmethod 120 def from_json(cls, json_str: str) -> Union[AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle]: 121 """Returns the object represented by the json string""" 122 instance = cls.model_construct() 123 error_messages = [] 124 matches = [] 125 126 # deserialize data into AppCardStyle 127 try: 128 instance.actual_instance = AppCardStyle.from_json(json_str) 129 matches.append(instance.actual_instance) 130 except (ValidationError, ValueError) as e: 131 error_messages.append(str(e)) 132 # deserialize data into CardStyle 133 try: 134 instance.actual_instance = CardStyle.from_json(json_str) 135 matches.append(instance.actual_instance) 136 except (ValidationError, ValueError) as e: 137 error_messages.append(str(e)) 138 # deserialize data into ShapeStyle 139 try: 140 instance.actual_instance = ShapeStyle.from_json(json_str) 141 matches.append(instance.actual_instance) 142 except (ValidationError, ValueError) as e: 143 error_messages.append(str(e)) 144 # deserialize data into StickyNoteStyle 145 try: 146 instance.actual_instance = StickyNoteStyle.from_json(json_str) 147 matches.append(instance.actual_instance) 148 except (ValidationError, ValueError) as e: 149 error_messages.append(str(e)) 150 # deserialize data into TextStyle 151 try: 152 instance.actual_instance = TextStyle.from_json(json_str) 153 matches.append(instance.actual_instance) 154 except (ValidationError, ValueError) as e: 155 error_messages.append(str(e)) 156 157 if not matches: 158 # no match 159 raise ValueError( 160 "No match found when deserializing the JSON string into ItemStyle with oneOf schemas: AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle. Details: " 161 + ", ".join(error_messages) 162 ) 163 164 # Return one match that has least additional_properties 165 if len(matches) > 1: 166 instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0] 167 168 return instance 169 170 def to_json(self) -> str: 171 """Returns the JSON representation of the actual instance""" 172 if self.actual_instance is None: 173 return "null" 174 175 if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): 176 return self.actual_instance.to_json() 177 else: 178 return json.dumps(self.actual_instance) 179 180 def to_dict( 181 self, 182 ) -> Optional[Union[Dict[str, Any], AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle]]: 183 """Returns the dict representation of the actual instance""" 184 if self.actual_instance is None: 185 return None 186 187 if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): 188 return self.actual_instance.to_dict() 189 else: 190 # primitive type 191 return self.actual_instance 192 193 def to_str(self) -> str: 194 """Returns the string representation of the actual instance""" 195 return pprint.pformat(self.model_dump())
33class ItemStyle(BaseModel): 34 """ 35 Contains information about item-specific styles. 36 """ 37 38 # data type: AppCardStyle 39 oneof_schema_1_validator: Optional[AppCardStyle] = None 40 # data type: CardStyle 41 oneof_schema_2_validator: Optional[CardStyle] = None 42 # data type: ShapeStyle 43 oneof_schema_3_validator: Optional[ShapeStyle] = None 44 # data type: StickyNoteStyle 45 oneof_schema_4_validator: Optional[StickyNoteStyle] = None 46 # data type: TextStyle 47 oneof_schema_5_validator: Optional[TextStyle] = None 48 actual_instance: Optional[Union[AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle]] = None 49 one_of_schemas: List[str] = Field( 50 default=Literal["AppCardStyle", "CardStyle", "ShapeStyle", "StickyNoteStyle", "TextStyle"] 51 ) 52 53 model_config = { 54 "validate_assignment": True, 55 "protected_namespaces": (), 56 } 57 58 def __init__(self, *args, **kwargs) -> None: 59 if args: 60 if len(args) > 1: 61 raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") 62 if kwargs: 63 raise ValueError("If a position argument is used, keyword arguments cannot be used.") 64 super().__init__(actual_instance=args[0]) 65 else: 66 super().__init__(**kwargs) 67 68 def __getattr__(self, attr: str): 69 return getattr(self.actual_instance, attr) 70 71 @field_validator("actual_instance") 72 def actual_instance_must_validate_oneof(cls, v): 73 instance = ItemStyle.model_construct() 74 error_messages = [] 75 match = 0 76 # validate data type: AppCardStyle 77 if not isinstance(v, AppCardStyle): 78 error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardStyle`") 79 else: 80 match += 1 81 # validate data type: CardStyle 82 if not isinstance(v, CardStyle): 83 error_messages.append(f"Error! Input type `{type(v)}` is not `CardStyle`") 84 else: 85 match += 1 86 # validate data type: ShapeStyle 87 if not isinstance(v, ShapeStyle): 88 error_messages.append(f"Error! Input type `{type(v)}` is not `ShapeStyle`") 89 else: 90 match += 1 91 # validate data type: StickyNoteStyle 92 if not isinstance(v, StickyNoteStyle): 93 error_messages.append(f"Error! Input type `{type(v)}` is not `StickyNoteStyle`") 94 else: 95 match += 1 96 # validate data type: TextStyle 97 if not isinstance(v, TextStyle): 98 error_messages.append(f"Error! Input type `{type(v)}` is not `TextStyle`") 99 else: 100 match += 1 101 if match > 1: 102 # more than 1 match 103 raise ValueError( 104 "Multiple matches found when setting `actual_instance` in ItemStyle with oneOf schemas: AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle. Details: " 105 + ", ".join(error_messages) 106 ) 107 elif match == 0: 108 # no match 109 raise ValueError( 110 "No match found when setting `actual_instance` in ItemStyle with oneOf schemas: AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle. Details: " 111 + ", ".join(error_messages) 112 ) 113 else: 114 return v 115 116 @classmethod 117 def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: 118 return cls.from_json(json.dumps(obj)) 119 120 @classmethod 121 def from_json(cls, json_str: str) -> Union[AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle]: 122 """Returns the object represented by the json string""" 123 instance = cls.model_construct() 124 error_messages = [] 125 matches = [] 126 127 # deserialize data into AppCardStyle 128 try: 129 instance.actual_instance = AppCardStyle.from_json(json_str) 130 matches.append(instance.actual_instance) 131 except (ValidationError, ValueError) as e: 132 error_messages.append(str(e)) 133 # deserialize data into CardStyle 134 try: 135 instance.actual_instance = CardStyle.from_json(json_str) 136 matches.append(instance.actual_instance) 137 except (ValidationError, ValueError) as e: 138 error_messages.append(str(e)) 139 # deserialize data into ShapeStyle 140 try: 141 instance.actual_instance = ShapeStyle.from_json(json_str) 142 matches.append(instance.actual_instance) 143 except (ValidationError, ValueError) as e: 144 error_messages.append(str(e)) 145 # deserialize data into StickyNoteStyle 146 try: 147 instance.actual_instance = StickyNoteStyle.from_json(json_str) 148 matches.append(instance.actual_instance) 149 except (ValidationError, ValueError) as e: 150 error_messages.append(str(e)) 151 # deserialize data into TextStyle 152 try: 153 instance.actual_instance = TextStyle.from_json(json_str) 154 matches.append(instance.actual_instance) 155 except (ValidationError, ValueError) as e: 156 error_messages.append(str(e)) 157 158 if not matches: 159 # no match 160 raise ValueError( 161 "No match found when deserializing the JSON string into ItemStyle with oneOf schemas: AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle. Details: " 162 + ", ".join(error_messages) 163 ) 164 165 # Return one match that has least additional_properties 166 if len(matches) > 1: 167 instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0] 168 169 return instance 170 171 def to_json(self) -> str: 172 """Returns the JSON representation of the actual instance""" 173 if self.actual_instance is None: 174 return "null" 175 176 if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): 177 return self.actual_instance.to_json() 178 else: 179 return json.dumps(self.actual_instance) 180 181 def to_dict( 182 self, 183 ) -> Optional[Union[Dict[str, Any], AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle]]: 184 """Returns the dict representation of the actual instance""" 185 if self.actual_instance is None: 186 return None 187 188 if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): 189 return self.actual_instance.to_dict() 190 else: 191 # primitive type 192 return self.actual_instance 193 194 def to_str(self) -> str: 195 """Returns the string representation of the actual instance""" 196 return pprint.pformat(self.model_dump())
Contains information about item-specific styles.
58 def __init__(self, *args, **kwargs) -> None: 59 if args: 60 if len(args) > 1: 61 raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") 62 if kwargs: 63 raise ValueError("If a position argument is used, keyword arguments cannot be used.") 64 super().__init__(actual_instance=args[0]) 65 else: 66 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.
71 @field_validator("actual_instance") 72 def actual_instance_must_validate_oneof(cls, v): 73 instance = ItemStyle.model_construct() 74 error_messages = [] 75 match = 0 76 # validate data type: AppCardStyle 77 if not isinstance(v, AppCardStyle): 78 error_messages.append(f"Error! Input type `{type(v)}` is not `AppCardStyle`") 79 else: 80 match += 1 81 # validate data type: CardStyle 82 if not isinstance(v, CardStyle): 83 error_messages.append(f"Error! Input type `{type(v)}` is not `CardStyle`") 84 else: 85 match += 1 86 # validate data type: ShapeStyle 87 if not isinstance(v, ShapeStyle): 88 error_messages.append(f"Error! Input type `{type(v)}` is not `ShapeStyle`") 89 else: 90 match += 1 91 # validate data type: StickyNoteStyle 92 if not isinstance(v, StickyNoteStyle): 93 error_messages.append(f"Error! Input type `{type(v)}` is not `StickyNoteStyle`") 94 else: 95 match += 1 96 # validate data type: TextStyle 97 if not isinstance(v, TextStyle): 98 error_messages.append(f"Error! Input type `{type(v)}` is not `TextStyle`") 99 else: 100 match += 1 101 if match > 1: 102 # more than 1 match 103 raise ValueError( 104 "Multiple matches found when setting `actual_instance` in ItemStyle with oneOf schemas: AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle. Details: " 105 + ", ".join(error_messages) 106 ) 107 elif match == 0: 108 # no match 109 raise ValueError( 110 "No match found when setting `actual_instance` in ItemStyle with oneOf schemas: AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle. Details: " 111 + ", ".join(error_messages) 112 ) 113 else: 114 return v
120 @classmethod 121 def from_json(cls, json_str: str) -> Union[AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle]: 122 """Returns the object represented by the json string""" 123 instance = cls.model_construct() 124 error_messages = [] 125 matches = [] 126 127 # deserialize data into AppCardStyle 128 try: 129 instance.actual_instance = AppCardStyle.from_json(json_str) 130 matches.append(instance.actual_instance) 131 except (ValidationError, ValueError) as e: 132 error_messages.append(str(e)) 133 # deserialize data into CardStyle 134 try: 135 instance.actual_instance = CardStyle.from_json(json_str) 136 matches.append(instance.actual_instance) 137 except (ValidationError, ValueError) as e: 138 error_messages.append(str(e)) 139 # deserialize data into ShapeStyle 140 try: 141 instance.actual_instance = ShapeStyle.from_json(json_str) 142 matches.append(instance.actual_instance) 143 except (ValidationError, ValueError) as e: 144 error_messages.append(str(e)) 145 # deserialize data into StickyNoteStyle 146 try: 147 instance.actual_instance = StickyNoteStyle.from_json(json_str) 148 matches.append(instance.actual_instance) 149 except (ValidationError, ValueError) as e: 150 error_messages.append(str(e)) 151 # deserialize data into TextStyle 152 try: 153 instance.actual_instance = TextStyle.from_json(json_str) 154 matches.append(instance.actual_instance) 155 except (ValidationError, ValueError) as e: 156 error_messages.append(str(e)) 157 158 if not matches: 159 # no match 160 raise ValueError( 161 "No match found when deserializing the JSON string into ItemStyle with oneOf schemas: AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle. Details: " 162 + ", ".join(error_messages) 163 ) 164 165 # Return one match that has least additional_properties 166 if len(matches) > 1: 167 instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0] 168 169 return instance
Returns the object represented by the json string
171 def to_json(self) -> str: 172 """Returns the JSON representation of the actual instance""" 173 if self.actual_instance is None: 174 return "null" 175 176 if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): 177 return self.actual_instance.to_json() 178 else: 179 return json.dumps(self.actual_instance)
Returns the JSON representation of the actual instance
181 def to_dict( 182 self, 183 ) -> Optional[Union[Dict[str, Any], AppCardStyle, CardStyle, ShapeStyle, StickyNoteStyle, TextStyle]]: 184 """Returns the dict representation of the actual instance""" 185 if self.actual_instance is None: 186 return None 187 188 if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): 189 return self.actual_instance.to_dict() 190 else: 191 # primitive type 192 return self.actual_instance
Returns the dict representation of the actual instance
194 def to_str(self) -> str: 195 """Returns the string representation of the actual instance""" 196 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