miro_api.models.item_data

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

Contains information about item-specific data.

ItemData(*args, **kwargs)
47    def __init__(self, *args, **kwargs) -> None:
48        if args:
49            if len(args) > 1:
50                raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
51            if kwargs:
52                raise ValueError("If a position argument is used, keyword arguments cannot be used.")
53            super().__init__(actual_instance=args[0])
54        else:
55            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.

oneof_schema_2_validator: Optional[miro_api.models.image_data_response.ImageDataResponse]
one_of_schemas: List[str]
model_config = {'validate_assignment': True, 'protected_namespaces': ()}
@field_validator('actual_instance')
def actual_instance_must_validate_oneof(cls, v):
60    @field_validator("actual_instance")
61    def actual_instance_must_validate_oneof(cls, v):
62        instance = ItemData.model_construct()
63        error_messages = []
64        match = 0
65        # validate data type: DocumentDataResponse
66        if not isinstance(v, DocumentDataResponse):
67            error_messages.append(f"Error! Input type `{type(v)}` is not `DocumentDataResponse`")
68        else:
69            match += 1
70        # validate data type: ImageDataResponse
71        if not isinstance(v, ImageDataResponse):
72            error_messages.append(f"Error! Input type `{type(v)}` is not `ImageDataResponse`")
73        else:
74            match += 1
75        if match > 1:
76            # more than 1 match
77            raise ValueError(
78                "Multiple matches found when setting `actual_instance` in ItemData with oneOf schemas: DocumentDataResponse, ImageDataResponse. Details: "
79                + ", ".join(error_messages)
80            )
81        elif match == 0:
82            # no match
83            raise ValueError(
84                "No match found when setting `actual_instance` in ItemData with oneOf schemas: DocumentDataResponse, ImageDataResponse. Details: "
85                + ", ".join(error_messages)
86            )
87        else:
88            return v
@classmethod
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> typing_extensions.Self:
90    @classmethod
91    def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
92        return cls.from_json(json.dumps(obj))
@classmethod
def from_json( cls, json_str: str) -> Union[miro_api.models.document_data_response.DocumentDataResponse, miro_api.models.image_data_response.ImageDataResponse]:
 94    @classmethod
 95    def from_json(cls, json_str: str) -> Union[DocumentDataResponse, ImageDataResponse]:
 96        """Returns the object represented by the json string"""
 97        instance = cls.model_construct()
 98        error_messages = []
 99        matches = []
100
101        # deserialize data into DocumentDataResponse
102        try:
103            instance.actual_instance = DocumentDataResponse.from_json(json_str)
104            matches.append(instance.actual_instance)
105        except (ValidationError, ValueError) as e:
106            error_messages.append(str(e))
107        # deserialize data into ImageDataResponse
108        try:
109            instance.actual_instance = ImageDataResponse.from_json(json_str)
110            matches.append(instance.actual_instance)
111        except (ValidationError, ValueError) as e:
112            error_messages.append(str(e))
113
114        if not matches:
115            # no match
116            raise ValueError(
117                "No match found when deserializing the JSON string into ItemData with oneOf schemas: DocumentDataResponse, ImageDataResponse. Details: "
118                + ", ".join(error_messages)
119            )
120
121        # Return one match that has least additional_properties
122        if len(matches) > 1:
123            instance.actual_instance = sorted(matches, key=lambda m: len(m.additional_properties))[0]
124
125        return instance

Returns the object represented by the json string

def to_json(self) -> str:
127    def to_json(self) -> str:
128        """Returns the JSON representation of the actual instance"""
129        if self.actual_instance is None:
130            return "null"
131
132        if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
133            return self.actual_instance.to_json()
134        else:
135            return json.dumps(self.actual_instance)

Returns the JSON representation of the actual instance

137    def to_dict(self) -> Optional[Union[Dict[str, Any], DocumentDataResponse, ImageDataResponse]]:
138        """Returns the dict representation of the actual instance"""
139        if self.actual_instance is None:
140            return None
141
142        if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
143            return self.actual_instance.to_dict()
144        else:
145            # primitive type
146            return self.actual_instance

Returns the dict representation of the actual instance

def to_str(self) -> str:
148    def to_str(self) -> str:
149        """Returns the string representation of the actual instance"""
150        return pprint.pformat(self.model_dump())

Returns the string representation of the actual instance

model_fields = {'oneof_schema_1_validator': FieldInfo(annotation=Union[DocumentDataResponse, NoneType], required=False), 'oneof_schema_2_validator': FieldInfo(annotation=Union[ImageDataResponse, NoneType], required=False), 'actual_instance': FieldInfo(annotation=Union[DocumentDataResponse, ImageDataResponse, NoneType], required=False), 'one_of_schemas': FieldInfo(annotation=List[str], required=False, default=typing_extensions.Literal['DocumentDataResponse', 'ImageDataResponse'])}
model_computed_fields = {}
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