hiddenlayer-sdk 0.1.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. hiddenlayer/__init__.py +109 -0
  2. hiddenlayer/sdk/__init__.py +0 -0
  3. hiddenlayer/sdk/constants.py +14 -0
  4. hiddenlayer/sdk/enterprise/__init__.py +0 -0
  5. hiddenlayer/sdk/enterprise/enterprise_model_scan_api.py +55 -0
  6. hiddenlayer/sdk/exceptions.py +12 -0
  7. hiddenlayer/sdk/models.py +22 -0
  8. hiddenlayer/sdk/rest/__init__.py +49 -0
  9. hiddenlayer/sdk/rest/api/__init__.py +7 -0
  10. hiddenlayer/sdk/rest/api/aidr_predictive_api.py +308 -0
  11. hiddenlayer/sdk/rest/api/model_scan_api.py +591 -0
  12. hiddenlayer/sdk/rest/api/sensor_api.py +1966 -0
  13. hiddenlayer/sdk/rest/api_client.py +770 -0
  14. hiddenlayer/sdk/rest/api_response.py +21 -0
  15. hiddenlayer/sdk/rest/configuration.py +445 -0
  16. hiddenlayer/sdk/rest/exceptions.py +199 -0
  17. hiddenlayer/sdk/rest/models/__init__.py +30 -0
  18. hiddenlayer/sdk/rest/models/create_sensor_request.py +95 -0
  19. hiddenlayer/sdk/rest/models/file_info.py +110 -0
  20. hiddenlayer/sdk/rest/models/get_multipart_upload_response.py +97 -0
  21. hiddenlayer/sdk/rest/models/model.py +100 -0
  22. hiddenlayer/sdk/rest/models/model_query_response.py +101 -0
  23. hiddenlayer/sdk/rest/models/multipart_upload_part.py +93 -0
  24. hiddenlayer/sdk/rest/models/scan_model_request.py +87 -0
  25. hiddenlayer/sdk/rest/models/scan_results_v2.py +108 -0
  26. hiddenlayer/sdk/rest/models/sensor_sor_query_filter.py +108 -0
  27. hiddenlayer/sdk/rest/models/sensor_sor_query_request.py +109 -0
  28. hiddenlayer/sdk/rest/models/submission_response.py +95 -0
  29. hiddenlayer/sdk/rest/models/submission_v2.py +109 -0
  30. hiddenlayer/sdk/rest/models/validation_error_model.py +99 -0
  31. hiddenlayer/sdk/rest/models/validation_error_model_loc_inner.py +138 -0
  32. hiddenlayer/sdk/rest/rest.py +257 -0
  33. hiddenlayer/sdk/services/__init__.py +0 -0
  34. hiddenlayer/sdk/services/aidr_predictive.py +76 -0
  35. hiddenlayer/sdk/services/model.py +101 -0
  36. hiddenlayer/sdk/services/model_scan.py +414 -0
  37. hiddenlayer/sdk/utils.py +92 -0
  38. hiddenlayer/sdk/version.py +1 -0
  39. hiddenlayer_sdk-0.1.0.dist-info/LICENSE +201 -0
  40. hiddenlayer_sdk-0.1.0.dist-info/METADATA +320 -0
  41. hiddenlayer_sdk-0.1.0.dist-info/RECORD +43 -0
  42. hiddenlayer_sdk-0.1.0.dist-info/WHEEL +5 -0
  43. hiddenlayer_sdk-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,108 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan
5
+
6
+ HiddenLayer ModelScan API for scanning of models
7
+
8
+ The version of the OpenAPI document: 1
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, StrictInt, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List
22
+ from hiddenlayer.sdk.rest.models.file_info import FileInfo
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class ScanResultsV2(BaseModel):
27
+ """
28
+ ScanResultsV2
29
+ """ # noqa: E501
30
+ scan_id: StrictStr
31
+ status: StrictStr
32
+ start_time: StrictInt
33
+ end_time: StrictInt
34
+ results: FileInfo
35
+ detections: List[Dict[str, Any]]
36
+ __properties: ClassVar[List[str]] = ["scan_id", "status", "start_time", "end_time", "results", "detections"]
37
+
38
+ @field_validator('status')
39
+ def status_validate_enum(cls, value):
40
+ """Validates the enum"""
41
+ if value not in set(['done', 'accepted', 'failed', 'pending', 'created', 'retry']):
42
+ raise ValueError("must be one of enum values ('done', 'accepted', 'failed', 'pending', 'created', 'retry')")
43
+ return value
44
+
45
+ model_config = ConfigDict(
46
+ populate_by_name=True,
47
+ validate_assignment=True,
48
+ protected_namespaces=(),
49
+ )
50
+
51
+
52
+ def to_str(self) -> str:
53
+ """Returns the string representation of the model using alias"""
54
+ return pprint.pformat(self.model_dump(by_alias=True))
55
+
56
+ def to_json(self) -> str:
57
+ """Returns the JSON representation of the model using alias"""
58
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
59
+ return json.dumps(self.to_dict())
60
+
61
+ @classmethod
62
+ def from_json(cls, json_str: str) -> Optional[Self]:
63
+ """Create an instance of ScanResultsV2 from a JSON string"""
64
+ return cls.from_dict(json.loads(json_str))
65
+
66
+ def to_dict(self) -> Dict[str, Any]:
67
+ """Return the dictionary representation of the model using alias.
68
+
69
+ This has the following differences from calling pydantic's
70
+ `self.model_dump(by_alias=True)`:
71
+
72
+ * `None` is only added to the output dict for nullable fields that
73
+ were set at model initialization. Other fields with value `None`
74
+ are ignored.
75
+ """
76
+ excluded_fields: Set[str] = set([
77
+ ])
78
+
79
+ _dict = self.model_dump(
80
+ by_alias=True,
81
+ exclude=excluded_fields,
82
+ exclude_none=True,
83
+ )
84
+ # override the default output from pydantic by calling `to_dict()` of results
85
+ if self.results:
86
+ _dict['results'] = self.results.to_dict()
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of ScanResultsV2 from a dict"""
92
+ if obj is None:
93
+ return None
94
+
95
+ if not isinstance(obj, dict):
96
+ return cls.model_validate(obj)
97
+
98
+ _obj = cls.model_validate({
99
+ "scan_id": obj.get("scan_id"),
100
+ "status": obj.get("status"),
101
+ "start_time": obj.get("start_time"),
102
+ "end_time": obj.get("end_time"),
103
+ "results": FileInfo.from_dict(obj["results"]) if obj.get("results") is not None else None,
104
+ "detections": obj.get("detections")
105
+ })
106
+ return _obj
107
+
108
+
@@ -0,0 +1,108 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan
5
+
6
+ HiddenLayer ModelScan API for scanning of models
7
+
8
+ The version of the OpenAPI document: 1
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 datetime import datetime
21
+ from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class SensorSORQueryFilter(BaseModel):
27
+ """
28
+ SensorSORQueryFilter
29
+ """ # noqa: E501
30
+ plaintext_name: Optional[StrictStr] = None
31
+ active: Optional[StrictBool] = None
32
+ version: Optional[StrictInt] = None
33
+ created_at_start: Optional[datetime] = None
34
+ created_at_stop: Optional[datetime] = None
35
+ source: Optional[StrictStr] = None
36
+ __properties: ClassVar[List[str]] = ["plaintext_name", "active", "version", "created_at_start", "created_at_stop", "source"]
37
+
38
+ @field_validator('source')
39
+ def source_validate_enum(cls, value):
40
+ """Validates the enum"""
41
+ if value is None:
42
+ return value
43
+
44
+ if value not in set(['adhoc']):
45
+ raise ValueError("must be one of enum values ('adhoc')")
46
+ return value
47
+
48
+ model_config = ConfigDict(
49
+ populate_by_name=True,
50
+ validate_assignment=True,
51
+ protected_namespaces=(),
52
+ )
53
+
54
+
55
+ def to_str(self) -> str:
56
+ """Returns the string representation of the model using alias"""
57
+ return pprint.pformat(self.model_dump(by_alias=True))
58
+
59
+ def to_json(self) -> str:
60
+ """Returns the JSON representation of the model using alias"""
61
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
62
+ return json.dumps(self.to_dict())
63
+
64
+ @classmethod
65
+ def from_json(cls, json_str: str) -> Optional[Self]:
66
+ """Create an instance of SensorSORQueryFilter from a JSON string"""
67
+ return cls.from_dict(json.loads(json_str))
68
+
69
+ def to_dict(self) -> Dict[str, Any]:
70
+ """Return the dictionary representation of the model using alias.
71
+
72
+ This has the following differences from calling pydantic's
73
+ `self.model_dump(by_alias=True)`:
74
+
75
+ * `None` is only added to the output dict for nullable fields that
76
+ were set at model initialization. Other fields with value `None`
77
+ are ignored.
78
+ """
79
+ excluded_fields: Set[str] = set([
80
+ ])
81
+
82
+ _dict = self.model_dump(
83
+ by_alias=True,
84
+ exclude=excluded_fields,
85
+ exclude_none=True,
86
+ )
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of SensorSORQueryFilter from a dict"""
92
+ if obj is None:
93
+ return None
94
+
95
+ if not isinstance(obj, dict):
96
+ return cls.model_validate(obj)
97
+
98
+ _obj = cls.model_validate({
99
+ "plaintext_name": obj.get("plaintext_name"),
100
+ "active": obj.get("active"),
101
+ "version": obj.get("version"),
102
+ "created_at_start": obj.get("created_at_start"),
103
+ "created_at_stop": obj.get("created_at_stop"),
104
+ "source": obj.get("source")
105
+ })
106
+ return _obj
107
+
108
+
@@ -0,0 +1,109 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan
5
+
6
+ HiddenLayer ModelScan API for scanning of models
7
+
8
+ The version of the OpenAPI document: 1
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, StrictInt, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from hiddenlayer.sdk.rest.models.sensor_sor_query_filter import SensorSORQueryFilter
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class SensorSORQueryRequest(BaseModel):
27
+ """
28
+ SensorSORQueryRequest
29
+ """ # noqa: E501
30
+ filter: Optional[SensorSORQueryFilter] = None
31
+ order_by: Optional[StrictStr] = 'created_at'
32
+ order_dir: Optional[StrictStr] = None
33
+ page_size: Optional[StrictInt] = 25
34
+ page_number: Optional[StrictInt] = 0
35
+ __properties: ClassVar[List[str]] = ["filter", "order_by", "order_dir", "page_size", "page_number"]
36
+
37
+ @field_validator('order_dir')
38
+ def order_dir_validate_enum(cls, value):
39
+ """Validates the enum"""
40
+ if value is None:
41
+ return value
42
+
43
+ if value not in set(['asc', 'desc', 'ASC', 'DESC']):
44
+ raise ValueError("must be one of enum values ('asc', 'desc', 'ASC', 'DESC')")
45
+ return value
46
+
47
+ model_config = ConfigDict(
48
+ populate_by_name=True,
49
+ validate_assignment=True,
50
+ protected_namespaces=(),
51
+ )
52
+
53
+
54
+ def to_str(self) -> str:
55
+ """Returns the string representation of the model using alias"""
56
+ return pprint.pformat(self.model_dump(by_alias=True))
57
+
58
+ def to_json(self) -> str:
59
+ """Returns the JSON representation of the model using alias"""
60
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
61
+ return json.dumps(self.to_dict())
62
+
63
+ @classmethod
64
+ def from_json(cls, json_str: str) -> Optional[Self]:
65
+ """Create an instance of SensorSORQueryRequest from a JSON string"""
66
+ return cls.from_dict(json.loads(json_str))
67
+
68
+ def to_dict(self) -> Dict[str, Any]:
69
+ """Return the dictionary representation of the model using alias.
70
+
71
+ This has the following differences from calling pydantic's
72
+ `self.model_dump(by_alias=True)`:
73
+
74
+ * `None` is only added to the output dict for nullable fields that
75
+ were set at model initialization. Other fields with value `None`
76
+ are ignored.
77
+ """
78
+ excluded_fields: Set[str] = set([
79
+ ])
80
+
81
+ _dict = self.model_dump(
82
+ by_alias=True,
83
+ exclude=excluded_fields,
84
+ exclude_none=True,
85
+ )
86
+ # override the default output from pydantic by calling `to_dict()` of filter
87
+ if self.filter:
88
+ _dict['filter'] = self.filter.to_dict()
89
+ return _dict
90
+
91
+ @classmethod
92
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
93
+ """Create an instance of SensorSORQueryRequest 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
+ "filter": SensorSORQueryFilter.from_dict(obj["filter"]) if obj.get("filter") is not None else None,
102
+ "order_by": obj.get("order_by") if obj.get("order_by") is not None else 'created_at',
103
+ "order_dir": obj.get("order_dir"),
104
+ "page_size": obj.get("page_size") if obj.get("page_size") is not None else 25,
105
+ "page_number": obj.get("page_number") if obj.get("page_number") is not None else 0
106
+ })
107
+ return _obj
108
+
109
+
@@ -0,0 +1,95 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan
5
+
6
+ HiddenLayer ModelScan API for scanning of models
7
+
8
+ The version of the OpenAPI document: 1
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 typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class SubmissionResponse(BaseModel):
26
+ """
27
+ SubmissionResponse
28
+ """ # noqa: E501
29
+ tenant_id: StrictStr
30
+ sensor_id: StrictStr
31
+ requester_id: StrictStr
32
+ group_id: StrictStr
33
+ event_time: StrictStr
34
+ __properties: ClassVar[List[str]] = ["tenant_id", "sensor_id", "requester_id", "group_id", "event_time"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+
43
+ def to_str(self) -> str:
44
+ """Returns the string representation of the model using alias"""
45
+ return pprint.pformat(self.model_dump(by_alias=True))
46
+
47
+ def to_json(self) -> str:
48
+ """Returns the JSON representation of the model using alias"""
49
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50
+ return json.dumps(self.to_dict())
51
+
52
+ @classmethod
53
+ def from_json(cls, json_str: str) -> Optional[Self]:
54
+ """Create an instance of SubmissionResponse from a JSON string"""
55
+ return cls.from_dict(json.loads(json_str))
56
+
57
+ def to_dict(self) -> Dict[str, Any]:
58
+ """Return the dictionary representation of the model using alias.
59
+
60
+ This has the following differences from calling pydantic's
61
+ `self.model_dump(by_alias=True)`:
62
+
63
+ * `None` is only added to the output dict for nullable fields that
64
+ were set at model initialization. Other fields with value `None`
65
+ are ignored.
66
+ """
67
+ excluded_fields: Set[str] = set([
68
+ ])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ return _dict
76
+
77
+ @classmethod
78
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
79
+ """Create an instance of SubmissionResponse from a dict"""
80
+ if obj is None:
81
+ return None
82
+
83
+ if not isinstance(obj, dict):
84
+ return cls.model_validate(obj)
85
+
86
+ _obj = cls.model_validate({
87
+ "tenant_id": obj.get("tenant_id"),
88
+ "sensor_id": obj.get("sensor_id"),
89
+ "requester_id": obj.get("requester_id"),
90
+ "group_id": obj.get("group_id"),
91
+ "event_time": obj.get("event_time")
92
+ })
93
+ return _obj
94
+
95
+
@@ -0,0 +1,109 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan
5
+
6
+ HiddenLayer ModelScan API for scanning of models
7
+
8
+ The version of the OpenAPI document: 1
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, StrictFloat, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional, Union
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class SubmissionV2(BaseModel):
26
+ """
27
+ SubmissionV2
28
+ """ # noqa: E501
29
+ metadata: Optional[Dict[str, Any]] = None
30
+ tags: Optional[List[StrictStr]] = None
31
+ sensor_id: StrictStr
32
+ requester_id: Optional[StrictStr] = 'UNKNOWN'
33
+ input_layer: StrictStr
34
+ input_layer_dtype: StrictStr
35
+ input_layer_shape: List[Union[StrictFloat, StrictInt]]
36
+ output_layer: StrictStr
37
+ output_layer_dtype: StrictStr
38
+ output_layer_shape: List[Union[StrictFloat, StrictInt]]
39
+ predictions: Optional[List[Union[StrictFloat, StrictInt]]] = None
40
+ event_time: Optional[StrictStr] = None
41
+ __properties: ClassVar[List[str]] = ["metadata", "tags", "sensor_id", "requester_id", "input_layer", "input_layer_dtype", "input_layer_shape", "output_layer", "output_layer_dtype", "output_layer_shape", "predictions", "event_time"]
42
+
43
+ model_config = ConfigDict(
44
+ populate_by_name=True,
45
+ validate_assignment=True,
46
+ protected_namespaces=(),
47
+ )
48
+
49
+
50
+ def to_str(self) -> str:
51
+ """Returns the string representation of the model using alias"""
52
+ return pprint.pformat(self.model_dump(by_alias=True))
53
+
54
+ def to_json(self) -> str:
55
+ """Returns the JSON representation of the model using alias"""
56
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
57
+ return json.dumps(self.to_dict())
58
+
59
+ @classmethod
60
+ def from_json(cls, json_str: str) -> Optional[Self]:
61
+ """Create an instance of SubmissionV2 from a JSON string"""
62
+ return cls.from_dict(json.loads(json_str))
63
+
64
+ def to_dict(self) -> Dict[str, Any]:
65
+ """Return the dictionary representation of the model using alias.
66
+
67
+ This has the following differences from calling pydantic's
68
+ `self.model_dump(by_alias=True)`:
69
+
70
+ * `None` is only added to the output dict for nullable fields that
71
+ were set at model initialization. Other fields with value `None`
72
+ are ignored.
73
+ """
74
+ excluded_fields: Set[str] = set([
75
+ ])
76
+
77
+ _dict = self.model_dump(
78
+ by_alias=True,
79
+ exclude=excluded_fields,
80
+ exclude_none=True,
81
+ )
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of SubmissionV2 from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate({
94
+ "metadata": obj.get("metadata"),
95
+ "tags": obj.get("tags"),
96
+ "sensor_id": obj.get("sensor_id"),
97
+ "requester_id": obj.get("requester_id") if obj.get("requester_id") is not None else 'UNKNOWN',
98
+ "input_layer": obj.get("input_layer"),
99
+ "input_layer_dtype": obj.get("input_layer_dtype"),
100
+ "input_layer_shape": obj.get("input_layer_shape"),
101
+ "output_layer": obj.get("output_layer"),
102
+ "output_layer_dtype": obj.get("output_layer_dtype"),
103
+ "output_layer_shape": obj.get("output_layer_shape"),
104
+ "predictions": obj.get("predictions"),
105
+ "event_time": obj.get("event_time")
106
+ })
107
+ return _obj
108
+
109
+
@@ -0,0 +1,99 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan
5
+
6
+ HiddenLayer ModelScan API for scanning of models
7
+
8
+ The version of the OpenAPI document: 1
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 hiddenlayer.sdk.rest.models.validation_error_model_loc_inner import ValidationErrorModelLocInner
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class ValidationErrorModel(BaseModel):
27
+ """
28
+ ValidationErrorModel
29
+ """ # noqa: E501
30
+ loc: List[ValidationErrorModelLocInner]
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 ValidationErrorModel 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 in self.loc:
78
+ if _item:
79
+ _items.append(_item.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 ValidationErrorModel 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": [ValidationErrorModelLocInner.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
+