rapidata 0.1.18__py3-none-any.whl → 0.1.19__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.
Files changed (50) hide show
  1. rapidata/api_client/__init__.py +2 -0
  2. rapidata/api_client/api/rapid_api.py +1370 -0
  3. rapidata/api_client/api/validation_api.py +15 -5
  4. rapidata/api_client/models/__init__.py +2 -0
  5. rapidata/api_client/models/add_validation_rapid_result.py +87 -0
  6. rapidata/api_client/models/attach_category_result.py +98 -0
  7. rapidata/api_client/models/bounding_box_result.py +106 -0
  8. rapidata/api_client/models/classification_metadata.py +0 -10
  9. rapidata/api_client/models/compare_result.py +98 -0
  10. rapidata/api_client/models/coordinate.py +108 -0
  11. rapidata/api_client/models/count_metadata.py +0 -10
  12. rapidata/api_client/models/create_demographic_rapid_model.py +93 -0
  13. rapidata/api_client/models/create_order_model_referee.py +22 -8
  14. rapidata/api_client/models/early_stopping_referee_model.py +98 -0
  15. rapidata/api_client/models/free_text_result.py +98 -0
  16. rapidata/api_client/models/image_dimension_metadata.py +0 -10
  17. rapidata/api_client/models/line.py +106 -0
  18. rapidata/api_client/models/line_point.py +98 -0
  19. rapidata/api_client/models/line_result.py +106 -0
  20. rapidata/api_client/models/locate_coordinate.py +98 -0
  21. rapidata/api_client/models/locate_result.py +106 -0
  22. rapidata/api_client/models/location_metadata.py +0 -10
  23. rapidata/api_client/models/named_entity_result.py +106 -0
  24. rapidata/api_client/models/order_query_get200_response.py +12 -12
  25. rapidata/api_client/models/original_filename_metadata.py +0 -10
  26. rapidata/api_client/models/polygon_result.py +106 -0
  27. rapidata/api_client/models/prompt_metadata.py +0 -10
  28. rapidata/api_client/models/query_model.py +112 -0
  29. rapidata/api_client/models/query_validation_rapids_result.py +98 -0
  30. rapidata/api_client/models/query_validation_rapids_result_asset.py +174 -0
  31. rapidata/api_client/models/query_validation_rapids_result_paged_result.py +105 -0
  32. rapidata/api_client/models/rapid_result_model.py +93 -0
  33. rapidata/api_client/models/rapid_result_model_result.py +252 -0
  34. rapidata/api_client/models/rapid_skipped_model.py +89 -0
  35. rapidata/api_client/models/shape.py +104 -0
  36. rapidata/api_client/models/skip_result.py +96 -0
  37. rapidata/api_client/models/text_metadata.py +0 -7
  38. rapidata/api_client/models/transcription_metadata.py +0 -7
  39. rapidata/api_client/models/transcription_result.py +106 -0
  40. rapidata/rapidata_client/dataset/rapidata_dataset.py +1 -2
  41. rapidata/rapidata_client/dataset/rapidata_validation_set.py +1 -2
  42. rapidata/rapidata_client/dataset/validation_rapid_parts.py +1 -2
  43. rapidata/rapidata_client/order/rapidata_order_builder.py +2 -3
  44. rapidata/rapidata_client/utils/utils.py +22 -0
  45. rapidata/service/openapi_service.py +6 -2
  46. {rapidata-0.1.18.dist-info → rapidata-0.1.19.dist-info}/METADATA +2 -1
  47. {rapidata-0.1.18.dist-info → rapidata-0.1.19.dist-info}/RECORD +49 -23
  48. rapidata/rapidata_client/types/__init__.py +0 -1
  49. {rapidata-0.1.18.dist-info → rapidata-0.1.19.dist-info}/LICENSE +0 -0
  50. {rapidata-0.1.18.dist-info → rapidata-0.1.19.dist-info}/WHEEL +0 -0
@@ -0,0 +1,106 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Rapidata.Dataset
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: v1
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, Field, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List
22
+ from rapidata.api_client.models.line import Line
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class LineResult(BaseModel):
27
+ """
28
+ LineResult
29
+ """ # noqa: E501
30
+ t: StrictStr = Field(description="Discriminator value for LineResult", alias="_t")
31
+ lines: List[Line]
32
+ rapid_id: StrictStr = Field(alias="rapidId")
33
+ __properties: ClassVar[List[str]] = ["_t", "lines", "rapidId"]
34
+
35
+ @field_validator('t')
36
+ def t_validate_enum(cls, value):
37
+ """Validates the enum"""
38
+ if value not in set(['LineResult']):
39
+ raise ValueError("must be one of enum values ('LineResult')")
40
+ return value
41
+
42
+ model_config = ConfigDict(
43
+ populate_by_name=True,
44
+ validate_assignment=True,
45
+ protected_namespaces=(),
46
+ )
47
+
48
+
49
+ def to_str(self) -> str:
50
+ """Returns the string representation of the model using alias"""
51
+ return pprint.pformat(self.model_dump(by_alias=True))
52
+
53
+ def to_json(self) -> str:
54
+ """Returns the JSON representation of the model using alias"""
55
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
56
+ return json.dumps(self.to_dict())
57
+
58
+ @classmethod
59
+ def from_json(cls, json_str: str) -> Optional[Self]:
60
+ """Create an instance of LineResult from a JSON string"""
61
+ return cls.from_dict(json.loads(json_str))
62
+
63
+ def to_dict(self) -> Dict[str, Any]:
64
+ """Return the dictionary representation of the model using alias.
65
+
66
+ This has the following differences from calling pydantic's
67
+ `self.model_dump(by_alias=True)`:
68
+
69
+ * `None` is only added to the output dict for nullable fields that
70
+ were set at model initialization. Other fields with value `None`
71
+ are ignored.
72
+ """
73
+ excluded_fields: Set[str] = set([
74
+ ])
75
+
76
+ _dict = self.model_dump(
77
+ by_alias=True,
78
+ exclude=excluded_fields,
79
+ exclude_none=True,
80
+ )
81
+ # override the default output from pydantic by calling `to_dict()` of each item in lines (list)
82
+ _items = []
83
+ if self.lines:
84
+ for _item_lines in self.lines:
85
+ if _item_lines:
86
+ _items.append(_item_lines.to_dict())
87
+ _dict['lines'] = _items
88
+ return _dict
89
+
90
+ @classmethod
91
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
92
+ """Create an instance of LineResult from a dict"""
93
+ if obj is None:
94
+ return None
95
+
96
+ if not isinstance(obj, dict):
97
+ return cls.model_validate(obj)
98
+
99
+ _obj = cls.model_validate({
100
+ "_t": obj.get("_t") if obj.get("_t") is not None else 'LineResult',
101
+ "lines": [Line.from_dict(_item) for _item in obj["lines"]] if obj.get("lines") is not None else None,
102
+ "rapidId": obj.get("rapidId")
103
+ })
104
+ return _obj
105
+
106
+
@@ -0,0 +1,98 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Rapidata.Dataset
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: v1
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, Field, StrictFloat, StrictInt, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List, Union
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class LocateCoordinate(BaseModel):
26
+ """
27
+ LocateCoordinate
28
+ """ # noqa: E501
29
+ t: StrictStr = Field(description="Discriminator value for LocateCoordinate", alias="_t")
30
+ x: Union[StrictFloat, StrictInt]
31
+ y: Union[StrictFloat, StrictInt]
32
+ __properties: ClassVar[List[str]] = ["_t", "x", "y"]
33
+
34
+ @field_validator('t')
35
+ def t_validate_enum(cls, value):
36
+ """Validates the enum"""
37
+ if value not in set(['LocateCoordinate']):
38
+ raise ValueError("must be one of enum values ('LocateCoordinate')")
39
+ return value
40
+
41
+ model_config = ConfigDict(
42
+ populate_by_name=True,
43
+ validate_assignment=True,
44
+ protected_namespaces=(),
45
+ )
46
+
47
+
48
+ def to_str(self) -> str:
49
+ """Returns the string representation of the model using alias"""
50
+ return pprint.pformat(self.model_dump(by_alias=True))
51
+
52
+ def to_json(self) -> str:
53
+ """Returns the JSON representation of the model using alias"""
54
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
55
+ return json.dumps(self.to_dict())
56
+
57
+ @classmethod
58
+ def from_json(cls, json_str: str) -> Optional[Self]:
59
+ """Create an instance of LocateCoordinate from a JSON string"""
60
+ return cls.from_dict(json.loads(json_str))
61
+
62
+ def to_dict(self) -> Dict[str, Any]:
63
+ """Return the dictionary representation of the model using alias.
64
+
65
+ This has the following differences from calling pydantic's
66
+ `self.model_dump(by_alias=True)`:
67
+
68
+ * `None` is only added to the output dict for nullable fields that
69
+ were set at model initialization. Other fields with value `None`
70
+ are ignored.
71
+ """
72
+ excluded_fields: Set[str] = set([
73
+ ])
74
+
75
+ _dict = self.model_dump(
76
+ by_alias=True,
77
+ exclude=excluded_fields,
78
+ exclude_none=True,
79
+ )
80
+ return _dict
81
+
82
+ @classmethod
83
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
84
+ """Create an instance of LocateCoordinate from a dict"""
85
+ if obj is None:
86
+ return None
87
+
88
+ if not isinstance(obj, dict):
89
+ return cls.model_validate(obj)
90
+
91
+ _obj = cls.model_validate({
92
+ "_t": obj.get("_t") if obj.get("_t") is not None else 'LocateCoordinate',
93
+ "x": obj.get("x"),
94
+ "y": obj.get("y")
95
+ })
96
+ return _obj
97
+
98
+
@@ -0,0 +1,106 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Rapidata.Dataset
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: v1
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, Field, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List
22
+ from rapidata.api_client.models.locate_coordinate import LocateCoordinate
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class LocateResult(BaseModel):
27
+ """
28
+ LocateResult
29
+ """ # noqa: E501
30
+ t: StrictStr = Field(description="Discriminator value for LocateResult", alias="_t")
31
+ coordinates: List[LocateCoordinate]
32
+ rapid_id: StrictStr = Field(alias="rapidId")
33
+ __properties: ClassVar[List[str]] = ["_t", "coordinates", "rapidId"]
34
+
35
+ @field_validator('t')
36
+ def t_validate_enum(cls, value):
37
+ """Validates the enum"""
38
+ if value not in set(['LocateResult']):
39
+ raise ValueError("must be one of enum values ('LocateResult')")
40
+ return value
41
+
42
+ model_config = ConfigDict(
43
+ populate_by_name=True,
44
+ validate_assignment=True,
45
+ protected_namespaces=(),
46
+ )
47
+
48
+
49
+ def to_str(self) -> str:
50
+ """Returns the string representation of the model using alias"""
51
+ return pprint.pformat(self.model_dump(by_alias=True))
52
+
53
+ def to_json(self) -> str:
54
+ """Returns the JSON representation of the model using alias"""
55
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
56
+ return json.dumps(self.to_dict())
57
+
58
+ @classmethod
59
+ def from_json(cls, json_str: str) -> Optional[Self]:
60
+ """Create an instance of LocateResult from a JSON string"""
61
+ return cls.from_dict(json.loads(json_str))
62
+
63
+ def to_dict(self) -> Dict[str, Any]:
64
+ """Return the dictionary representation of the model using alias.
65
+
66
+ This has the following differences from calling pydantic's
67
+ `self.model_dump(by_alias=True)`:
68
+
69
+ * `None` is only added to the output dict for nullable fields that
70
+ were set at model initialization. Other fields with value `None`
71
+ are ignored.
72
+ """
73
+ excluded_fields: Set[str] = set([
74
+ ])
75
+
76
+ _dict = self.model_dump(
77
+ by_alias=True,
78
+ exclude=excluded_fields,
79
+ exclude_none=True,
80
+ )
81
+ # override the default output from pydantic by calling `to_dict()` of each item in coordinates (list)
82
+ _items = []
83
+ if self.coordinates:
84
+ for _item_coordinates in self.coordinates:
85
+ if _item_coordinates:
86
+ _items.append(_item_coordinates.to_dict())
87
+ _dict['coordinates'] = _items
88
+ return _dict
89
+
90
+ @classmethod
91
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
92
+ """Create an instance of LocateResult from a dict"""
93
+ if obj is None:
94
+ return None
95
+
96
+ if not isinstance(obj, dict):
97
+ return cls.model_validate(obj)
98
+
99
+ _obj = cls.model_validate({
100
+ "_t": obj.get("_t") if obj.get("_t") is not None else 'LocateResult',
101
+ "coordinates": [LocateCoordinate.from_dict(_item) for _item in obj["coordinates"]] if obj.get("coordinates") is not None else None,
102
+ "rapidId": obj.get("rapidId")
103
+ })
104
+ return _obj
105
+
106
+
@@ -40,16 +40,6 @@ class LocationMetadata(BaseModel):
40
40
  raise ValueError("must be one of enum values ('LocationMetadata')")
41
41
  return value
42
42
 
43
- @field_validator('visibilities')
44
- def visibilities_validate_enum(cls, value):
45
- """Validates the enum"""
46
- if value is None:
47
- return value
48
-
49
- if value not in set(['None', 'Users', 'Customers', 'Admins', 'All']):
50
- raise ValueError("must be one of enum values ('None', 'Users', 'Customers', 'Admins', 'All')")
51
- return value
52
-
53
43
  model_config = ConfigDict(
54
44
  populate_by_name=True,
55
45
  validate_assignment=True,
@@ -0,0 +1,106 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Rapidata.Dataset
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: v1
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, Field, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List
22
+ from rapidata.api_client.models.named_classification import NamedClassification
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class NamedEntityResult(BaseModel):
27
+ """
28
+ NamedEntityResult
29
+ """ # noqa: E501
30
+ t: StrictStr = Field(description="Discriminator value for NamedEntityResult", alias="_t")
31
+ classifications: List[NamedClassification]
32
+ rapid_id: StrictStr = Field(alias="rapidId")
33
+ __properties: ClassVar[List[str]] = ["_t", "classifications", "rapidId"]
34
+
35
+ @field_validator('t')
36
+ def t_validate_enum(cls, value):
37
+ """Validates the enum"""
38
+ if value not in set(['NamedEntityResult']):
39
+ raise ValueError("must be one of enum values ('NamedEntityResult')")
40
+ return value
41
+
42
+ model_config = ConfigDict(
43
+ populate_by_name=True,
44
+ validate_assignment=True,
45
+ protected_namespaces=(),
46
+ )
47
+
48
+
49
+ def to_str(self) -> str:
50
+ """Returns the string representation of the model using alias"""
51
+ return pprint.pformat(self.model_dump(by_alias=True))
52
+
53
+ def to_json(self) -> str:
54
+ """Returns the JSON representation of the model using alias"""
55
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
56
+ return json.dumps(self.to_dict())
57
+
58
+ @classmethod
59
+ def from_json(cls, json_str: str) -> Optional[Self]:
60
+ """Create an instance of NamedEntityResult from a JSON string"""
61
+ return cls.from_dict(json.loads(json_str))
62
+
63
+ def to_dict(self) -> Dict[str, Any]:
64
+ """Return the dictionary representation of the model using alias.
65
+
66
+ This has the following differences from calling pydantic's
67
+ `self.model_dump(by_alias=True)`:
68
+
69
+ * `None` is only added to the output dict for nullable fields that
70
+ were set at model initialization. Other fields with value `None`
71
+ are ignored.
72
+ """
73
+ excluded_fields: Set[str] = set([
74
+ ])
75
+
76
+ _dict = self.model_dump(
77
+ by_alias=True,
78
+ exclude=excluded_fields,
79
+ exclude_none=True,
80
+ )
81
+ # override the default output from pydantic by calling `to_dict()` of each item in classifications (list)
82
+ _items = []
83
+ if self.classifications:
84
+ for _item_classifications in self.classifications:
85
+ if _item_classifications:
86
+ _items.append(_item_classifications.to_dict())
87
+ _dict['classifications'] = _items
88
+ return _dict
89
+
90
+ @classmethod
91
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
92
+ """Create an instance of NamedEntityResult from a dict"""
93
+ if obj is None:
94
+ return None
95
+
96
+ if not isinstance(obj, dict):
97
+ return cls.model_validate(obj)
98
+
99
+ _obj = cls.model_validate({
100
+ "_t": obj.get("_t") if obj.get("_t") is not None else 'NamedEntityResult',
101
+ "classifications": [NamedClassification.from_dict(_item) for _item in obj["classifications"]] if obj.get("classifications") is not None else None,
102
+ "rapidId": obj.get("rapidId")
103
+ })
104
+ return _obj
105
+
106
+
@@ -29,10 +29,10 @@ class OrderQueryGet200Response(BaseModel):
29
29
  """
30
30
  OrderQueryGet200Response
31
31
  """
32
- # data type: CustomerOrderModelPagedResult
33
- oneof_schema_1_validator: Optional[CustomerOrderModelPagedResult] = None
34
32
  # data type: AdminOrderModelPagedResult
35
- oneof_schema_2_validator: Optional[AdminOrderModelPagedResult] = None
33
+ oneof_schema_1_validator: Optional[AdminOrderModelPagedResult] = None
34
+ # data type: CustomerOrderModelPagedResult
35
+ oneof_schema_2_validator: Optional[CustomerOrderModelPagedResult] = None
36
36
  actual_instance: Optional[Union[AdminOrderModelPagedResult, CustomerOrderModelPagedResult]] = None
37
37
  one_of_schemas: Set[str] = { "AdminOrderModelPagedResult", "CustomerOrderModelPagedResult" }
38
38
 
@@ -57,16 +57,16 @@ class OrderQueryGet200Response(BaseModel):
57
57
  instance = OrderQueryGet200Response.model_construct()
58
58
  error_messages = []
59
59
  match = 0
60
- # validate data type: CustomerOrderModelPagedResult
61
- if not isinstance(v, CustomerOrderModelPagedResult):
62
- error_messages.append(f"Error! Input type `{type(v)}` is not `CustomerOrderModelPagedResult`")
63
- else:
64
- match += 1
65
60
  # validate data type: AdminOrderModelPagedResult
66
61
  if not isinstance(v, AdminOrderModelPagedResult):
67
62
  error_messages.append(f"Error! Input type `{type(v)}` is not `AdminOrderModelPagedResult`")
68
63
  else:
69
64
  match += 1
65
+ # validate data type: CustomerOrderModelPagedResult
66
+ if not isinstance(v, CustomerOrderModelPagedResult):
67
+ error_messages.append(f"Error! Input type `{type(v)}` is not `CustomerOrderModelPagedResult`")
68
+ else:
69
+ match += 1
70
70
  if match > 1:
71
71
  # more than 1 match
72
72
  raise ValueError("Multiple matches found when setting `actual_instance` in OrderQueryGet200Response with oneOf schemas: AdminOrderModelPagedResult, CustomerOrderModelPagedResult. Details: " + ", ".join(error_messages))
@@ -87,15 +87,15 @@ class OrderQueryGet200Response(BaseModel):
87
87
  error_messages = []
88
88
  match = 0
89
89
 
90
- # deserialize data into CustomerOrderModelPagedResult
90
+ # deserialize data into AdminOrderModelPagedResult
91
91
  try:
92
- instance.actual_instance = CustomerOrderModelPagedResult.from_json(json_str)
92
+ instance.actual_instance = AdminOrderModelPagedResult.from_json(json_str)
93
93
  match += 1
94
94
  except (ValidationError, ValueError) as e:
95
95
  error_messages.append(str(e))
96
- # deserialize data into AdminOrderModelPagedResult
96
+ # deserialize data into CustomerOrderModelPagedResult
97
97
  try:
98
- instance.actual_instance = AdminOrderModelPagedResult.from_json(json_str)
98
+ instance.actual_instance = CustomerOrderModelPagedResult.from_json(json_str)
99
99
  match += 1
100
100
  except (ValidationError, ValueError) as e:
101
101
  error_messages.append(str(e))
@@ -39,16 +39,6 @@ class OriginalFilenameMetadata(BaseModel):
39
39
  raise ValueError("must be one of enum values ('OriginalFilenameMetadata')")
40
40
  return value
41
41
 
42
- @field_validator('visibilities')
43
- def visibilities_validate_enum(cls, value):
44
- """Validates the enum"""
45
- if value is None:
46
- return value
47
-
48
- if value not in set(['None', 'Users', 'Customers', 'Admins', 'All']):
49
- raise ValueError("must be one of enum values ('None', 'Users', 'Customers', 'Admins', 'All')")
50
- return value
51
-
52
42
  model_config = ConfigDict(
53
43
  populate_by_name=True,
54
44
  validate_assignment=True,
@@ -0,0 +1,106 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Rapidata.Dataset
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: v1
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, Field, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List
22
+ from rapidata.api_client.models.shape import Shape
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class PolygonResult(BaseModel):
27
+ """
28
+ PolygonResult
29
+ """ # noqa: E501
30
+ t: StrictStr = Field(description="Discriminator value for PolygonResult", alias="_t")
31
+ shapes: List[Shape]
32
+ rapid_id: StrictStr = Field(alias="rapidId")
33
+ __properties: ClassVar[List[str]] = ["_t", "shapes", "rapidId"]
34
+
35
+ @field_validator('t')
36
+ def t_validate_enum(cls, value):
37
+ """Validates the enum"""
38
+ if value not in set(['PolygonResult']):
39
+ raise ValueError("must be one of enum values ('PolygonResult')")
40
+ return value
41
+
42
+ model_config = ConfigDict(
43
+ populate_by_name=True,
44
+ validate_assignment=True,
45
+ protected_namespaces=(),
46
+ )
47
+
48
+
49
+ def to_str(self) -> str:
50
+ """Returns the string representation of the model using alias"""
51
+ return pprint.pformat(self.model_dump(by_alias=True))
52
+
53
+ def to_json(self) -> str:
54
+ """Returns the JSON representation of the model using alias"""
55
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
56
+ return json.dumps(self.to_dict())
57
+
58
+ @classmethod
59
+ def from_json(cls, json_str: str) -> Optional[Self]:
60
+ """Create an instance of PolygonResult from a JSON string"""
61
+ return cls.from_dict(json.loads(json_str))
62
+
63
+ def to_dict(self) -> Dict[str, Any]:
64
+ """Return the dictionary representation of the model using alias.
65
+
66
+ This has the following differences from calling pydantic's
67
+ `self.model_dump(by_alias=True)`:
68
+
69
+ * `None` is only added to the output dict for nullable fields that
70
+ were set at model initialization. Other fields with value `None`
71
+ are ignored.
72
+ """
73
+ excluded_fields: Set[str] = set([
74
+ ])
75
+
76
+ _dict = self.model_dump(
77
+ by_alias=True,
78
+ exclude=excluded_fields,
79
+ exclude_none=True,
80
+ )
81
+ # override the default output from pydantic by calling `to_dict()` of each item in shapes (list)
82
+ _items = []
83
+ if self.shapes:
84
+ for _item_shapes in self.shapes:
85
+ if _item_shapes:
86
+ _items.append(_item_shapes.to_dict())
87
+ _dict['shapes'] = _items
88
+ return _dict
89
+
90
+ @classmethod
91
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
92
+ """Create an instance of PolygonResult from a dict"""
93
+ if obj is None:
94
+ return None
95
+
96
+ if not isinstance(obj, dict):
97
+ return cls.model_validate(obj)
98
+
99
+ _obj = cls.model_validate({
100
+ "_t": obj.get("_t") if obj.get("_t") is not None else 'PolygonResult',
101
+ "shapes": [Shape.from_dict(_item) for _item in obj["shapes"]] if obj.get("shapes") is not None else None,
102
+ "rapidId": obj.get("rapidId")
103
+ })
104
+ return _obj
105
+
106
+
@@ -39,16 +39,6 @@ class PromptMetadata(BaseModel):
39
39
  raise ValueError("must be one of enum values ('PromptMetadata')")
40
40
  return value
41
41
 
42
- @field_validator('visibilities')
43
- def visibilities_validate_enum(cls, value):
44
- """Validates the enum"""
45
- if value is None:
46
- return value
47
-
48
- if value not in set(['None', 'Users', 'Customers', 'Admins', 'All']):
49
- raise ValueError("must be one of enum values ('None', 'Users', 'Customers', 'Admins', 'All')")
50
- return value
51
-
52
42
  model_config = ConfigDict(
53
43
  populate_by_name=True,
54
44
  validate_assignment=True,