aind-metadata-service-client 1.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of aind-metadata-service-client might be problematic. Click here for more details.

Files changed (33) hide show
  1. aind_metadata_service_client/__init__.py +52 -0
  2. aind_metadata_service_client/api/__init__.py +6 -0
  3. aind_metadata_service_client/api/default_api.py +3818 -0
  4. aind_metadata_service_client/api/healthcheck_api.py +281 -0
  5. aind_metadata_service_client/api_client.py +797 -0
  6. aind_metadata_service_client/api_response.py +21 -0
  7. aind_metadata_service_client/configuration.py +572 -0
  8. aind_metadata_service_client/exceptions.py +216 -0
  9. aind_metadata_service_client/models/__init__.py +34 -0
  10. aind_metadata_service_client/models/anyof_schema1_validator.py +144 -0
  11. aind_metadata_service_client/models/average_hit_rate.py +144 -0
  12. aind_metadata_service_client/models/fov_coordinate_ap.py +144 -0
  13. aind_metadata_service_client/models/fov_coordinate_ml.py +112 -0
  14. aind_metadata_service_client/models/health_check.py +99 -0
  15. aind_metadata_service_client/models/hit_rate_trials010.py +144 -0
  16. aind_metadata_service_client/models/hit_rate_trials2040.py +144 -0
  17. aind_metadata_service_client/models/http_validation_error.py +95 -0
  18. aind_metadata_service_client/models/input_source.py +122 -0
  19. aind_metadata_service_client/models/job_settings.py +369 -0
  20. aind_metadata_service_client/models/job_settings_starting_lickport_position_inner.py +138 -0
  21. aind_metadata_service_client/models/output_directory.py +108 -0
  22. aind_metadata_service_client/models/slims_workflow.py +40 -0
  23. aind_metadata_service_client/models/total_hits.py +144 -0
  24. aind_metadata_service_client/models/trial_num.py +144 -0
  25. aind_metadata_service_client/models/user_settings_config_file.py +108 -0
  26. aind_metadata_service_client/models/validation_error.py +99 -0
  27. aind_metadata_service_client/models/validation_error_loc_inner.py +138 -0
  28. aind_metadata_service_client/py.typed +0 -0
  29. aind_metadata_service_client/rest.py +258 -0
  30. aind_metadata_service_client-1.0.7.dist-info/METADATA +23 -0
  31. aind_metadata_service_client-1.0.7.dist-info/RECORD +33 -0
  32. aind_metadata_service_client-1.0.7.dist-info/WHEEL +5 -0
  33. aind_metadata_service_client-1.0.7.dist-info/top_level.txt +1 -0
@@ -0,0 +1,108 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ aind-metadata-service
5
+
6
+ ## aind-metadata-service Service to pull data from example backend.
7
+
8
+ The version of the OpenAPI document: 1.0.7
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class OutputDirectory(BaseModel):
26
+ """
27
+ Location to metadata file data to. None to return object.
28
+ """ # noqa: E501
29
+ anyof_schema_1_validator: Optional[StrictStr] = None
30
+ anyof_schema_2_validator: Optional[StrictStr] = None
31
+ actual_instance: Optional[Any] = None
32
+ any_of_schemas: Optional[List[StrictStr]] = None
33
+ __properties: ClassVar[List[str]] = ["anyof_schema_1_validator", "anyof_schema_2_validator", "actual_instance", "any_of_schemas"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
+ return json.dumps(self.to_dict())
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of OutputDirectory from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ ])
68
+
69
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ # set to None if anyof_schema_1_validator (nullable) is None
75
+ # and model_fields_set contains the field
76
+ if self.anyof_schema_1_validator is None and "anyof_schema_1_validator" in self.model_fields_set:
77
+ _dict['anyof_schema_1_validator'] = None
78
+
79
+ # set to None if anyof_schema_2_validator (nullable) is None
80
+ # and model_fields_set contains the field
81
+ if self.anyof_schema_2_validator is None and "anyof_schema_2_validator" in self.model_fields_set:
82
+ _dict['anyof_schema_2_validator'] = None
83
+
84
+ # set to None if actual_instance (nullable) is None
85
+ # and model_fields_set contains the field
86
+ if self.actual_instance is None and "actual_instance" in self.model_fields_set:
87
+ _dict['actual_instance'] = None
88
+
89
+ return _dict
90
+
91
+ @classmethod
92
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
93
+ """Create an instance of OutputDirectory from a dict"""
94
+ if obj is None:
95
+ return None
96
+
97
+ if not isinstance(obj, dict):
98
+ return cls.model_validate(obj)
99
+
100
+ _obj = cls.model_validate({
101
+ "anyof_schema_1_validator": obj.get("anyof_schema_1_validator"),
102
+ "anyof_schema_2_validator": obj.get("anyof_schema_2_validator"),
103
+ "actual_instance": obj.get("actual_instance"),
104
+ "any_of_schemas": obj.get("any_of_schemas")
105
+ })
106
+ return _obj
107
+
108
+
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ aind-metadata-service
5
+
6
+ ## aind-metadata-service Service to pull data from example backend.
7
+
8
+ The version of the OpenAPI document: 1.0.7
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import json
17
+ from enum import Enum
18
+ from typing_extensions import Self
19
+
20
+
21
+ class SlimsWorkflow(str, Enum):
22
+ """
23
+ Available workflows that can be queried.
24
+ """
25
+
26
+ """
27
+ allowed enum values
28
+ """
29
+ SMARTSPIM_IMAGING = 'smartspim_imaging'
30
+ HISTOLOGY = 'histology'
31
+ WATER_RESTRICTION = 'water_restriction'
32
+ VIRAL_INJECTIONS = 'viral_injections'
33
+ ECEPHYS_SESSIONS = 'ecephys_sessions'
34
+
35
+ @classmethod
36
+ def from_json(cls, json_str: str) -> Self:
37
+ """Create an instance of SlimsWorkflow from a JSON string"""
38
+ return cls(json.loads(json_str))
39
+
40
+
@@ -0,0 +1,144 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ aind-metadata-service
5
+
6
+ ## aind-metadata-service Service to pull data from example backend.
7
+
8
+ The version of the OpenAPI document: 1.0.7
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ from inspect import getfullargspec
17
+ import json
18
+ import pprint
19
+ import re # noqa: F401
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, ValidationError, field_validator
21
+ from typing import Optional, Union
22
+ from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
23
+ from typing_extensions import Literal, Self
24
+ from pydantic import Field
25
+
26
+ TOTALHITS_ANY_OF_SCHEMAS = ["float", "int"]
27
+
28
+ class TotalHits(BaseModel):
29
+ """
30
+ TotalHits
31
+ """
32
+
33
+ # data type: float
34
+ anyof_schema_1_validator: Optional[Union[StrictFloat, StrictInt]] = None
35
+ # data type: int
36
+ anyof_schema_2_validator: Optional[StrictInt] = None
37
+ if TYPE_CHECKING:
38
+ actual_instance: Optional[Union[float, int]] = None
39
+ else:
40
+ actual_instance: Any = None
41
+ any_of_schemas: Set[str] = { "float", "int" }
42
+
43
+ model_config = {
44
+ "validate_assignment": True,
45
+ "protected_namespaces": (),
46
+ }
47
+
48
+ def __init__(self, *args, **kwargs) -> None:
49
+ if args:
50
+ if len(args) > 1:
51
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
52
+ if kwargs:
53
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
54
+ super().__init__(actual_instance=args[0])
55
+ else:
56
+ super().__init__(**kwargs)
57
+
58
+ @field_validator('actual_instance')
59
+ def actual_instance_must_validate_anyof(cls, v):
60
+ if v is None:
61
+ return v
62
+
63
+ instance = TotalHits.model_construct()
64
+ error_messages = []
65
+ # validate data type: float
66
+ try:
67
+ instance.anyof_schema_1_validator = v
68
+ return v
69
+ except (ValidationError, ValueError) as e:
70
+ error_messages.append(str(e))
71
+ # validate data type: int
72
+ try:
73
+ instance.anyof_schema_2_validator = v
74
+ return v
75
+ except (ValidationError, ValueError) as e:
76
+ error_messages.append(str(e))
77
+ if error_messages:
78
+ # no match
79
+ raise ValueError("No match found when setting the actual_instance in TotalHits with anyOf schemas: float, int. Details: " + ", ".join(error_messages))
80
+ else:
81
+ return v
82
+
83
+ @classmethod
84
+ def from_dict(cls, obj: Dict[str, Any]) -> Self:
85
+ return cls.from_json(json.dumps(obj))
86
+
87
+ @classmethod
88
+ def from_json(cls, json_str: str) -> Self:
89
+ """Returns the object represented by the json string"""
90
+ instance = cls.model_construct()
91
+ if json_str is None:
92
+ return instance
93
+
94
+ error_messages = []
95
+ # deserialize data into float
96
+ try:
97
+ # validation
98
+ instance.anyof_schema_1_validator = json.loads(json_str)
99
+ # assign value to actual_instance
100
+ instance.actual_instance = instance.anyof_schema_1_validator
101
+ return instance
102
+ except (ValidationError, ValueError) as e:
103
+ error_messages.append(str(e))
104
+ # deserialize data into int
105
+ try:
106
+ # validation
107
+ instance.anyof_schema_2_validator = json.loads(json_str)
108
+ # assign value to actual_instance
109
+ instance.actual_instance = instance.anyof_schema_2_validator
110
+ return instance
111
+ except (ValidationError, ValueError) as e:
112
+ error_messages.append(str(e))
113
+
114
+ if error_messages:
115
+ # no match
116
+ raise ValueError("No match found when deserializing the JSON string into TotalHits with anyOf schemas: float, int. Details: " + ", ".join(error_messages))
117
+ else:
118
+ return instance
119
+
120
+ def to_json(self) -> str:
121
+ """Returns the JSON representation of the actual instance"""
122
+ if self.actual_instance is None:
123
+ return "null"
124
+
125
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
126
+ return self.actual_instance.to_json()
127
+ else:
128
+ return json.dumps(self.actual_instance)
129
+
130
+ def to_dict(self) -> Optional[Union[Dict[str, Any], float, int]]:
131
+ """Returns the dict representation of the actual instance"""
132
+ if self.actual_instance is None:
133
+ return None
134
+
135
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
136
+ return self.actual_instance.to_dict()
137
+ else:
138
+ return self.actual_instance
139
+
140
+ def to_str(self) -> str:
141
+ """Returns the string representation of the actual instance"""
142
+ return pprint.pformat(self.model_dump())
143
+
144
+
@@ -0,0 +1,144 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ aind-metadata-service
5
+
6
+ ## aind-metadata-service Service to pull data from example backend.
7
+
8
+ The version of the OpenAPI document: 1.0.7
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ from inspect import getfullargspec
17
+ import json
18
+ import pprint
19
+ import re # noqa: F401
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, ValidationError, field_validator
21
+ from typing import Optional, Union
22
+ from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
23
+ from typing_extensions import Literal, Self
24
+ from pydantic import Field
25
+
26
+ TRIALNUM_ANY_OF_SCHEMAS = ["float", "int"]
27
+
28
+ class TrialNum(BaseModel):
29
+ """
30
+ TrialNum
31
+ """
32
+
33
+ # data type: float
34
+ anyof_schema_1_validator: Optional[Union[StrictFloat, StrictInt]] = None
35
+ # data type: int
36
+ anyof_schema_2_validator: Optional[StrictInt] = None
37
+ if TYPE_CHECKING:
38
+ actual_instance: Optional[Union[float, int]] = None
39
+ else:
40
+ actual_instance: Any = None
41
+ any_of_schemas: Set[str] = { "float", "int" }
42
+
43
+ model_config = {
44
+ "validate_assignment": True,
45
+ "protected_namespaces": (),
46
+ }
47
+
48
+ def __init__(self, *args, **kwargs) -> None:
49
+ if args:
50
+ if len(args) > 1:
51
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
52
+ if kwargs:
53
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
54
+ super().__init__(actual_instance=args[0])
55
+ else:
56
+ super().__init__(**kwargs)
57
+
58
+ @field_validator('actual_instance')
59
+ def actual_instance_must_validate_anyof(cls, v):
60
+ if v is None:
61
+ return v
62
+
63
+ instance = TrialNum.model_construct()
64
+ error_messages = []
65
+ # validate data type: float
66
+ try:
67
+ instance.anyof_schema_1_validator = v
68
+ return v
69
+ except (ValidationError, ValueError) as e:
70
+ error_messages.append(str(e))
71
+ # validate data type: int
72
+ try:
73
+ instance.anyof_schema_2_validator = v
74
+ return v
75
+ except (ValidationError, ValueError) as e:
76
+ error_messages.append(str(e))
77
+ if error_messages:
78
+ # no match
79
+ raise ValueError("No match found when setting the actual_instance in TrialNum with anyOf schemas: float, int. Details: " + ", ".join(error_messages))
80
+ else:
81
+ return v
82
+
83
+ @classmethod
84
+ def from_dict(cls, obj: Dict[str, Any]) -> Self:
85
+ return cls.from_json(json.dumps(obj))
86
+
87
+ @classmethod
88
+ def from_json(cls, json_str: str) -> Self:
89
+ """Returns the object represented by the json string"""
90
+ instance = cls.model_construct()
91
+ if json_str is None:
92
+ return instance
93
+
94
+ error_messages = []
95
+ # deserialize data into float
96
+ try:
97
+ # validation
98
+ instance.anyof_schema_1_validator = json.loads(json_str)
99
+ # assign value to actual_instance
100
+ instance.actual_instance = instance.anyof_schema_1_validator
101
+ return instance
102
+ except (ValidationError, ValueError) as e:
103
+ error_messages.append(str(e))
104
+ # deserialize data into int
105
+ try:
106
+ # validation
107
+ instance.anyof_schema_2_validator = json.loads(json_str)
108
+ # assign value to actual_instance
109
+ instance.actual_instance = instance.anyof_schema_2_validator
110
+ return instance
111
+ except (ValidationError, ValueError) as e:
112
+ error_messages.append(str(e))
113
+
114
+ if error_messages:
115
+ # no match
116
+ raise ValueError("No match found when deserializing the JSON string into TrialNum with anyOf schemas: float, int. Details: " + ", ".join(error_messages))
117
+ else:
118
+ return instance
119
+
120
+ def to_json(self) -> str:
121
+ """Returns the JSON representation of the actual instance"""
122
+ if self.actual_instance is None:
123
+ return "null"
124
+
125
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
126
+ return self.actual_instance.to_json()
127
+ else:
128
+ return json.dumps(self.actual_instance)
129
+
130
+ def to_dict(self) -> Optional[Union[Dict[str, Any], float, int]]:
131
+ """Returns the dict representation of the actual instance"""
132
+ if self.actual_instance is None:
133
+ return None
134
+
135
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
136
+ return self.actual_instance.to_dict()
137
+ else:
138
+ return self.actual_instance
139
+
140
+ def to_str(self) -> str:
141
+ """Returns the string representation of the actual instance"""
142
+ return pprint.pformat(self.model_dump())
143
+
144
+
@@ -0,0 +1,108 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ aind-metadata-service
5
+
6
+ ## aind-metadata-service Service to pull data from example backend.
7
+
8
+ The version of the OpenAPI document: 1.0.7
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class UserSettingsConfigFile(BaseModel):
26
+ """
27
+ Optionally pull settings from a local config file.
28
+ """ # noqa: E501
29
+ anyof_schema_1_validator: Optional[StrictStr] = None
30
+ anyof_schema_2_validator: Optional[StrictStr] = None
31
+ actual_instance: Optional[Any] = None
32
+ any_of_schemas: Optional[List[StrictStr]] = None
33
+ __properties: ClassVar[List[str]] = ["anyof_schema_1_validator", "anyof_schema_2_validator", "actual_instance", "any_of_schemas"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
+ return json.dumps(self.to_dict())
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of UserSettingsConfigFile from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ ])
68
+
69
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ # set to None if anyof_schema_1_validator (nullable) is None
75
+ # and model_fields_set contains the field
76
+ if self.anyof_schema_1_validator is None and "anyof_schema_1_validator" in self.model_fields_set:
77
+ _dict['anyof_schema_1_validator'] = None
78
+
79
+ # set to None if anyof_schema_2_validator (nullable) is None
80
+ # and model_fields_set contains the field
81
+ if self.anyof_schema_2_validator is None and "anyof_schema_2_validator" in self.model_fields_set:
82
+ _dict['anyof_schema_2_validator'] = None
83
+
84
+ # set to None if actual_instance (nullable) is None
85
+ # and model_fields_set contains the field
86
+ if self.actual_instance is None and "actual_instance" in self.model_fields_set:
87
+ _dict['actual_instance'] = None
88
+
89
+ return _dict
90
+
91
+ @classmethod
92
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
93
+ """Create an instance of UserSettingsConfigFile from a dict"""
94
+ if obj is None:
95
+ return None
96
+
97
+ if not isinstance(obj, dict):
98
+ return cls.model_validate(obj)
99
+
100
+ _obj = cls.model_validate({
101
+ "anyof_schema_1_validator": obj.get("anyof_schema_1_validator"),
102
+ "anyof_schema_2_validator": obj.get("anyof_schema_2_validator"),
103
+ "actual_instance": obj.get("actual_instance"),
104
+ "any_of_schemas": obj.get("any_of_schemas")
105
+ })
106
+ return _obj
107
+
108
+
@@ -0,0 +1,99 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ aind-metadata-service
5
+
6
+ ## aind-metadata-service Service to pull data from example backend.
7
+
8
+ The version of the OpenAPI document: 1.0.7
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictStr
21
+ from typing import Any, ClassVar, Dict, List
22
+ from aind_metadata_service_client.models.validation_error_loc_inner import ValidationErrorLocInner
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class ValidationError(BaseModel):
27
+ """
28
+ ValidationError
29
+ """ # noqa: E501
30
+ loc: List[ValidationErrorLocInner]
31
+ msg: StrictStr
32
+ type: StrictStr
33
+ __properties: ClassVar[List[str]] = ["loc", "msg", "type"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
+ return json.dumps(self.to_dict())
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of ValidationError from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ ])
68
+
69
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ # override the default output from pydantic by calling `to_dict()` of each item in loc (list)
75
+ _items = []
76
+ if self.loc:
77
+ for _item_loc in self.loc:
78
+ if _item_loc:
79
+ _items.append(_item_loc.to_dict())
80
+ _dict['loc'] = _items
81
+ return _dict
82
+
83
+ @classmethod
84
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
85
+ """Create an instance of ValidationError from a dict"""
86
+ if obj is None:
87
+ return None
88
+
89
+ if not isinstance(obj, dict):
90
+ return cls.model_validate(obj)
91
+
92
+ _obj = cls.model_validate({
93
+ "loc": [ValidationErrorLocInner.from_dict(_item) for _item in obj["loc"]] if obj.get("loc") is not None else None,
94
+ "msg": obj.get("msg"),
95
+ "type": obj.get("type")
96
+ })
97
+ return _obj
98
+
99
+