hiddenlayer-sdk 1.2.2__py3-none-any.whl → 2.0.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. hiddenlayer/__init__.py +0 -10
  2. hiddenlayer/sdk/exceptions.py +1 -1
  3. hiddenlayer/sdk/models.py +2 -3
  4. hiddenlayer/sdk/rest/__init__.py +16 -11
  5. hiddenlayer/sdk/rest/api/__init__.py +0 -1
  6. hiddenlayer/sdk/rest/api/model_supply_chain_api.py +1706 -571
  7. hiddenlayer/sdk/rest/api/sensor_api.py +214 -1320
  8. hiddenlayer/sdk/rest/models/__init__.py +16 -10
  9. hiddenlayer/sdk/rest/models/{scan_model_request.py → begin_multi_file_upload200_response.py} +9 -9
  10. hiddenlayer/sdk/rest/models/{get_multipart_upload_response.py → begin_multipart_file_upload200_response.py} +9 -9
  11. hiddenlayer/sdk/rest/models/{multipart_upload_part.py → begin_multipart_file_upload200_response_parts_inner.py} +11 -10
  12. hiddenlayer/sdk/rest/models/errors_inner.py +91 -0
  13. hiddenlayer/sdk/rest/models/file_details_v3.py +8 -2
  14. hiddenlayer/sdk/rest/models/{scan_results_v2.py → file_result_v3.py} +21 -32
  15. hiddenlayer/sdk/rest/models/{model_scan_api_v3_scan_query200_response.py → get_condensed_model_scan_reports200_response.py} +4 -4
  16. hiddenlayer/sdk/rest/models/inventory_v3.py +97 -0
  17. hiddenlayer/sdk/rest/models/model_inventory_info.py +1 -1
  18. hiddenlayer/sdk/rest/models/{detections.py → multi_file_upload_request_v3.py} +14 -22
  19. hiddenlayer/sdk/rest/models/{model_scan_api_v3_scan_model_version_id_patch200_response.py → notify_model_scan_completed200_response.py} +4 -4
  20. hiddenlayer/sdk/rest/models/pagination_v3.py +95 -0
  21. hiddenlayer/sdk/rest/models/problem_details.py +103 -0
  22. hiddenlayer/sdk/rest/models/scan_detection_v31.py +155 -0
  23. hiddenlayer/sdk/rest/models/scan_model_details_v3.py +1 -1
  24. hiddenlayer/sdk/rest/models/scan_results_map_v3.py +105 -0
  25. hiddenlayer/sdk/rest/models/scan_results_v3.py +120 -0
  26. hiddenlayer/sdk/rest/models/{model.py → sensor.py} +4 -4
  27. hiddenlayer/sdk/rest/models/{model_query_response.py → sensor_query_response.py} +7 -7
  28. hiddenlayer/sdk/services/aidr_predictive.py +57 -3
  29. hiddenlayer/sdk/services/model_scan.py +94 -132
  30. hiddenlayer/sdk/version.py +1 -1
  31. {hiddenlayer_sdk-1.2.2.dist-info → hiddenlayer_sdk-2.0.1.dist-info}/METADATA +12 -2
  32. {hiddenlayer_sdk-1.2.2.dist-info → hiddenlayer_sdk-2.0.1.dist-info}/RECORD +35 -31
  33. hiddenlayer/sdk/rest/api/model_scan_api.py +0 -591
  34. hiddenlayer/sdk/rest/models/scan_results.py +0 -118
  35. hiddenlayer/sdk/services/model.py +0 -149
  36. {hiddenlayer_sdk-1.2.2.dist-info → hiddenlayer_sdk-2.0.1.dist-info}/LICENSE +0 -0
  37. {hiddenlayer_sdk-1.2.2.dist-info → hiddenlayer_sdk-2.0.1.dist-info}/WHEEL +0 -0
  38. {hiddenlayer_sdk-1.2.2.dist-info → hiddenlayer_sdk-2.0.1.dist-info}/top_level.txt +0 -0
@@ -17,29 +17,20 @@ import pprint
17
17
  import re # noqa: F401
18
18
  import json
19
19
 
20
- from pydantic import BaseModel, ConfigDict, StrictStr, field_validator
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
21
  from typing import Any, ClassVar, Dict, List, Optional
22
22
  from typing import Optional, Set
23
23
  from typing_extensions import Self
24
24
 
25
- class Detections(BaseModel):
25
+ class MultiFileUploadRequestV3(BaseModel):
26
26
  """
27
- Detections
27
+ MultiFileUploadRequestV3
28
28
  """ # noqa: E501
29
- description: Optional[StrictStr] = None
30
- message: Optional[StrictStr] = None
31
- severity: Optional[StrictStr] = None
32
- __properties: ClassVar[List[str]] = ["description", "message", "severity"]
33
-
34
- @field_validator('severity')
35
- def severity_validate_enum(cls, value):
36
- """Validates the enum"""
37
- if value is None:
38
- return value
39
-
40
- if value not in set(['MISS', 'SAFE', 'SUSPICIOUS', 'UNSAFE', 'MALICIOUS']):
41
- raise ValueError("must be one of enum values ('MISS', 'SAFE', 'SUSPICIOUS', 'UNSAFE', 'MALICIOUS')")
42
- return value
29
+ model_version: StrictStr = Field(description="Model version")
30
+ model_name: StrictStr = Field(description="Model name")
31
+ requesting_entity: StrictStr = Field(description="Requesting entity")
32
+ location_alias: Optional[StrictStr] = Field(default=None, description="Requested location alias")
33
+ __properties: ClassVar[List[str]] = ["model_version", "model_name", "requesting_entity", "location_alias"]
43
34
 
44
35
  model_config = ConfigDict(
45
36
  populate_by_name=True,
@@ -59,7 +50,7 @@ class Detections(BaseModel):
59
50
 
60
51
  @classmethod
61
52
  def from_json(cls, json_str: str) -> Optional[Self]:
62
- """Create an instance of Detections from a JSON string"""
53
+ """Create an instance of MultiFileUploadRequestV3 from a JSON string"""
63
54
  return cls.from_dict(json.loads(json_str))
64
55
 
65
56
  def to_dict(self) -> Dict[str, Any]:
@@ -84,7 +75,7 @@ class Detections(BaseModel):
84
75
 
85
76
  @classmethod
86
77
  def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
87
- """Create an instance of Detections from a dict"""
78
+ """Create an instance of MultiFileUploadRequestV3 from a dict"""
88
79
  if obj is None:
89
80
  return None
90
81
 
@@ -92,9 +83,10 @@ class Detections(BaseModel):
92
83
  return cls.model_validate(obj)
93
84
 
94
85
  _obj = cls.model_validate({
95
- "description": obj.get("description"),
96
- "message": obj.get("message"),
97
- "severity": obj.get("severity")
86
+ "model_version": obj.get("model_version"),
87
+ "model_name": obj.get("model_name"),
88
+ "requesting_entity": obj.get("requesting_entity"),
89
+ "location_alias": obj.get("location_alias")
98
90
  })
99
91
  return _obj
100
92
 
@@ -22,9 +22,9 @@ from typing import Any, ClassVar, Dict, List
22
22
  from typing import Optional, Set
23
23
  from typing_extensions import Self
24
24
 
25
- class ModelScanApiV3ScanModelVersionIdPatch200Response(BaseModel):
25
+ class NotifyModelScanCompleted200Response(BaseModel):
26
26
  """
27
- ModelScanApiV3ScanModelVersionIdPatch200Response
27
+ NotifyModelScanCompleted200Response
28
28
  """ # noqa: E501
29
29
  message: StrictStr = Field(description="Request to resource is successful")
30
30
  __properties: ClassVar[List[str]] = ["message"]
@@ -47,7 +47,7 @@ class ModelScanApiV3ScanModelVersionIdPatch200Response(BaseModel):
47
47
 
48
48
  @classmethod
49
49
  def from_json(cls, json_str: str) -> Optional[Self]:
50
- """Create an instance of ModelScanApiV3ScanModelVersionIdPatch200Response from a JSON string"""
50
+ """Create an instance of NotifyModelScanCompleted200Response from a JSON string"""
51
51
  return cls.from_dict(json.loads(json_str))
52
52
 
53
53
  def to_dict(self) -> Dict[str, Any]:
@@ -72,7 +72,7 @@ class ModelScanApiV3ScanModelVersionIdPatch200Response(BaseModel):
72
72
 
73
73
  @classmethod
74
74
  def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
75
- """Create an instance of ModelScanApiV3ScanModelVersionIdPatch200Response from a dict"""
75
+ """Create an instance of NotifyModelScanCompleted200Response from a dict"""
76
76
  if obj is None:
77
77
  return None
78
78
 
@@ -0,0 +1,95 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan V2
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, Field, StrictStr
21
+ from typing import Any, ClassVar, Dict, List
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class PaginationV3(BaseModel):
26
+ """
27
+ PaginationV3
28
+ """ # noqa: E501
29
+ var_self: StrictStr = Field(alias="self")
30
+ first: StrictStr
31
+ prev: StrictStr
32
+ next: StrictStr
33
+ last: StrictStr
34
+ __properties: ClassVar[List[str]] = ["self", "first", "prev", "next", "last"]
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 PaginationV3 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 PaginationV3 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
+ "self": obj.get("self"),
88
+ "first": obj.get("first"),
89
+ "prev": obj.get("prev"),
90
+ "next": obj.get("next"),
91
+ "last": obj.get("last")
92
+ })
93
+ return _obj
94
+
95
+
@@ -0,0 +1,103 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan V2
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, Field, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from hiddenlayer.sdk.rest.models.errors_inner import ErrorsInner
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class ProblemDetails(BaseModel):
27
+ """
28
+ ProblemDetails
29
+ """ # noqa: E501
30
+ type: Optional[StrictStr] = Field(default=None, description="https://www.rfc-editor.org/rfc/rfc9457.html#name-type")
31
+ title: Optional[StrictStr] = Field(default=None, description="https://www.rfc-editor.org/rfc/rfc9457.html#name-title")
32
+ detail: Optional[StrictStr] = Field(default=None, description="https://www.rfc-editor.org/rfc/rfc9457.html#name-detail")
33
+ instance: Optional[StrictStr] = Field(default=None, description="https://www.rfc-editor.org/rfc/rfc9457.html#name-instance")
34
+ errors: List[ErrorsInner] = Field(description="Error details")
35
+ __properties: ClassVar[List[str]] = ["type", "title", "detail", "instance", "errors"]
36
+
37
+ model_config = ConfigDict(
38
+ populate_by_name=True,
39
+ validate_assignment=True,
40
+ protected_namespaces=(),
41
+ )
42
+
43
+
44
+ def to_str(self) -> str:
45
+ """Returns the string representation of the model using alias"""
46
+ return pprint.pformat(self.model_dump(by_alias=True))
47
+
48
+ def to_json(self) -> str:
49
+ """Returns the JSON representation of the model using alias"""
50
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
51
+ return json.dumps(self.to_dict())
52
+
53
+ @classmethod
54
+ def from_json(cls, json_str: str) -> Optional[Self]:
55
+ """Create an instance of ProblemDetails from a JSON string"""
56
+ return cls.from_dict(json.loads(json_str))
57
+
58
+ def to_dict(self) -> Dict[str, Any]:
59
+ """Return the dictionary representation of the model using alias.
60
+
61
+ This has the following differences from calling pydantic's
62
+ `self.model_dump(by_alias=True)`:
63
+
64
+ * `None` is only added to the output dict for nullable fields that
65
+ were set at model initialization. Other fields with value `None`
66
+ are ignored.
67
+ """
68
+ excluded_fields: Set[str] = set([
69
+ ])
70
+
71
+ _dict = self.model_dump(
72
+ by_alias=True,
73
+ exclude=excluded_fields,
74
+ exclude_none=True,
75
+ )
76
+ # override the default output from pydantic by calling `to_dict()` of each item in errors (list)
77
+ _items = []
78
+ if self.errors:
79
+ for _item in self.errors:
80
+ if _item:
81
+ _items.append(_item.to_dict())
82
+ _dict['errors'] = _items
83
+ return _dict
84
+
85
+ @classmethod
86
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
87
+ """Create an instance of ProblemDetails from a dict"""
88
+ if obj is None:
89
+ return None
90
+
91
+ if not isinstance(obj, dict):
92
+ return cls.model_validate(obj)
93
+
94
+ _obj = cls.model_validate({
95
+ "type": obj.get("type"),
96
+ "title": obj.get("title"),
97
+ "detail": obj.get("detail"),
98
+ "instance": obj.get("instance"),
99
+ "errors": [ErrorsInner.from_dict(_item) for _item in obj["errors"]] if obj.get("errors") is not None else None
100
+ })
101
+ return _obj
102
+
103
+
@@ -0,0 +1,155 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan V2
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, Field, StrictStr, field_validator
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing_extensions import Annotated
23
+ from hiddenlayer.sdk.rest.models.mitre_atlas_inner import MITREAtlasInner
24
+ from hiddenlayer.sdk.rest.models.rule_details_inner import RuleDetailsInner
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+
28
+ class ScanDetectionV31(BaseModel):
29
+ """
30
+ ScanDetectionV31
31
+ """ # noqa: E501
32
+ detection_id: StrictStr = Field(description="unique identifier for the detection")
33
+ rule_id: StrictStr = Field(description="unique identifier for the rule that sourced the detection")
34
+ risk: StrictStr = Field(description="detection risk")
35
+ category: StrictStr = Field(description="Vulnerability category for the detection")
36
+ description: StrictStr = Field(description="detection description")
37
+ likelihood: StrictStr = Field(description="detection likelihood")
38
+ impact: StrictStr = Field(description="detection impact")
39
+ severity: StrictStr = Field(description="detection severity")
40
+ rule_details: Optional[List[RuleDetailsInner]] = None
41
+ mitre_atlas: List[MITREAtlasInner]
42
+ owasp: List[Annotated[str, Field(strict=True)]]
43
+ cve: List[Annotated[str, Field(strict=True)]]
44
+ cwe: Annotated[str, Field(strict=True)]
45
+ cwe_href: StrictStr = Field(description="CWE URL for the detection")
46
+ technical_blog_hrefs: Optional[List[StrictStr]] = Field(default=None, description="Hiddenlayer Technical Blog URLs for the detection")
47
+ technical_blog_href: Optional[StrictStr] = Field(default=None, description="Hiddenlayer Technical Blog URL for the detection")
48
+ __properties: ClassVar[List[str]] = ["detection_id", "rule_id", "risk", "category", "description", "likelihood", "impact", "severity", "rule_details", "mitre_atlas", "owasp", "cve", "cwe", "cwe_href", "technical_blog_hrefs", "technical_blog_href"]
49
+
50
+ @field_validator('risk')
51
+ def risk_validate_enum(cls, value):
52
+ """Validates the enum"""
53
+ if value not in set(['MALICIOUS', 'SUSPICIOUS']):
54
+ raise ValueError("must be one of enum values ('MALICIOUS', 'SUSPICIOUS')")
55
+ return value
56
+
57
+ @field_validator('severity')
58
+ def severity_validate_enum(cls, value):
59
+ """Validates the enum"""
60
+ if value not in set(['low', 'medium', 'high', 'critical']):
61
+ raise ValueError("must be one of enum values ('low', 'medium', 'high', 'critical')")
62
+ return value
63
+
64
+ @field_validator('cwe')
65
+ def cwe_validate_regular_expression(cls, value):
66
+ """Validates the regular expression"""
67
+ if not re.match(r"^CWE-\d{1,4}.*$|^$", value):
68
+ raise ValueError(r"must validate the regular expression /^CWE-\d{1,4}.*$|^$/")
69
+ return value
70
+
71
+ model_config = ConfigDict(
72
+ populate_by_name=True,
73
+ validate_assignment=True,
74
+ protected_namespaces=(),
75
+ )
76
+
77
+
78
+ def to_str(self) -> str:
79
+ """Returns the string representation of the model using alias"""
80
+ return pprint.pformat(self.model_dump(by_alias=True))
81
+
82
+ def to_json(self) -> str:
83
+ """Returns the JSON representation of the model using alias"""
84
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
85
+ return json.dumps(self.to_dict())
86
+
87
+ @classmethod
88
+ def from_json(cls, json_str: str) -> Optional[Self]:
89
+ """Create an instance of ScanDetectionV31 from a JSON string"""
90
+ return cls.from_dict(json.loads(json_str))
91
+
92
+ def to_dict(self) -> Dict[str, Any]:
93
+ """Return the dictionary representation of the model using alias.
94
+
95
+ This has the following differences from calling pydantic's
96
+ `self.model_dump(by_alias=True)`:
97
+
98
+ * `None` is only added to the output dict for nullable fields that
99
+ were set at model initialization. Other fields with value `None`
100
+ are ignored.
101
+ """
102
+ excluded_fields: Set[str] = set([
103
+ ])
104
+
105
+ _dict = self.model_dump(
106
+ by_alias=True,
107
+ exclude=excluded_fields,
108
+ exclude_none=True,
109
+ )
110
+ # override the default output from pydantic by calling `to_dict()` of each item in rule_details (list)
111
+ _items = []
112
+ if self.rule_details:
113
+ for _item in self.rule_details:
114
+ if _item:
115
+ _items.append(_item.to_dict())
116
+ _dict['rule_details'] = _items
117
+ # override the default output from pydantic by calling `to_dict()` of each item in mitre_atlas (list)
118
+ _items = []
119
+ if self.mitre_atlas:
120
+ for _item in self.mitre_atlas:
121
+ if _item:
122
+ _items.append(_item.to_dict())
123
+ _dict['mitre_atlas'] = _items
124
+ return _dict
125
+
126
+ @classmethod
127
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
128
+ """Create an instance of ScanDetectionV31 from a dict"""
129
+ if obj is None:
130
+ return None
131
+
132
+ if not isinstance(obj, dict):
133
+ return cls.model_validate(obj)
134
+
135
+ _obj = cls.model_validate({
136
+ "detection_id": obj.get("detection_id"),
137
+ "rule_id": obj.get("rule_id"),
138
+ "risk": obj.get("risk"),
139
+ "category": obj.get("category"),
140
+ "description": obj.get("description"),
141
+ "likelihood": obj.get("likelihood"),
142
+ "impact": obj.get("impact"),
143
+ "severity": obj.get("severity"),
144
+ "rule_details": [RuleDetailsInner.from_dict(_item) for _item in obj["rule_details"]] if obj.get("rule_details") is not None else None,
145
+ "mitre_atlas": [MITREAtlasInner.from_dict(_item) for _item in obj["mitre_atlas"]] if obj.get("mitre_atlas") is not None else None,
146
+ "owasp": obj.get("owasp"),
147
+ "cve": obj.get("cve"),
148
+ "cwe": obj.get("cwe"),
149
+ "cwe_href": obj.get("cwe_href"),
150
+ "technical_blog_hrefs": obj.get("technical_blog_hrefs"),
151
+ "technical_blog_href": obj.get("technical_blog_href")
152
+ })
153
+ return _obj
154
+
155
+
@@ -28,7 +28,7 @@ class ScanModelDetailsV3(BaseModel):
28
28
  """ # noqa: E501
29
29
  model_name: StrictStr = Field(description="name of the model")
30
30
  model_version: StrictStr = Field(description="version of the model")
31
- model_source: StrictStr = Field(description="source (provider) info")
31
+ model_source: Optional[StrictStr] = Field(default=None, description="source (provider) info")
32
32
  requested_scan_location: StrictStr = Field(description="Location to be scanned")
33
33
  requesting_entity: Optional[StrictStr] = Field(default=None, description="Entity that requested the scan")
34
34
  __properties: ClassVar[List[str]] = ["model_name", "model_version", "model_source", "requested_scan_location", "requesting_entity"]
@@ -0,0 +1,105 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan V2
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
21
+ from typing import Any, ClassVar, Dict, List
22
+ from hiddenlayer.sdk.rest.models.pagination_v3 import PaginationV3
23
+ from hiddenlayer.sdk.rest.models.scan_results_v3 import ScanResultsV3
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class ScanResultsMapV3(BaseModel):
28
+ """
29
+ ScanResultsMapV3
30
+ """ # noqa: E501
31
+ page: List[PaginationV3]
32
+ items: List[ScanResultsV3]
33
+ __properties: ClassVar[List[str]] = ["page", "items"]
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 ScanResultsMapV3 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 page (list)
75
+ _items = []
76
+ if self.page:
77
+ for _item in self.page:
78
+ if _item:
79
+ _items.append(_item.to_dict())
80
+ _dict['page'] = _items
81
+ # override the default output from pydantic by calling `to_dict()` of each item in items (list)
82
+ _items = []
83
+ if self.items:
84
+ for _item in self.items:
85
+ if _item:
86
+ _items.append(_item.to_dict())
87
+ _dict['items'] = _items
88
+ return _dict
89
+
90
+ @classmethod
91
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
92
+ """Create an instance of ScanResultsMapV3 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
+ "page": [PaginationV3.from_dict(_item) for _item in obj["page"]] if obj.get("page") is not None else None,
101
+ "items": [ScanResultsV3.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None
102
+ })
103
+ return _obj
104
+
105
+