hiddenlayer-sdk 0.1.1__py3-none-any.whl → 1.0.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. hiddenlayer/sdk/models.py +45 -8
  2. hiddenlayer/sdk/rest/__init__.py +80 -3
  3. hiddenlayer/sdk/rest/api/__init__.py +3 -0
  4. hiddenlayer/sdk/rest/api/aidr_predictive_api.py +1 -1
  5. hiddenlayer/sdk/rest/api/health_api.py +272 -0
  6. hiddenlayer/sdk/rest/api/model_scan_api.py +1 -1
  7. hiddenlayer/sdk/rest/api/model_supply_chain_api.py +2927 -0
  8. hiddenlayer/sdk/rest/api/readiness_api.py +272 -0
  9. hiddenlayer/sdk/rest/api/sensor_api.py +345 -16
  10. hiddenlayer/sdk/rest/api_client.py +1 -1
  11. hiddenlayer/sdk/rest/configuration.py +4 -4
  12. hiddenlayer/sdk/rest/exceptions.py +1 -1
  13. hiddenlayer/sdk/rest/models/__init__.py +77 -3
  14. hiddenlayer/sdk/rest/models/address.py +110 -0
  15. hiddenlayer/sdk/rest/models/artifact.py +155 -0
  16. hiddenlayer/sdk/rest/models/artifact_change.py +108 -0
  17. hiddenlayer/sdk/rest/models/artifact_content.py +101 -0
  18. hiddenlayer/sdk/rest/models/artifact_location.py +109 -0
  19. hiddenlayer/sdk/rest/models/attachment.py +129 -0
  20. hiddenlayer/sdk/rest/models/code_flow.py +113 -0
  21. hiddenlayer/sdk/rest/models/configuration_override.py +108 -0
  22. hiddenlayer/sdk/rest/models/conversion.py +114 -0
  23. hiddenlayer/sdk/rest/models/create_sensor_request.py +1 -1
  24. hiddenlayer/sdk/rest/models/detections.py +101 -0
  25. hiddenlayer/sdk/rest/models/edge.py +108 -0
  26. hiddenlayer/sdk/rest/models/edge_traversal.py +122 -0
  27. hiddenlayer/sdk/rest/models/exception.py +113 -0
  28. hiddenlayer/sdk/rest/models/external_properties.py +273 -0
  29. hiddenlayer/sdk/rest/models/external_property_file_reference.py +102 -0
  30. hiddenlayer/sdk/rest/models/external_property_file_references.py +240 -0
  31. hiddenlayer/sdk/rest/models/file_details_v3.py +140 -0
  32. hiddenlayer/sdk/rest/models/file_results_inner.py +121 -0
  33. hiddenlayer/sdk/rest/models/file_scan_report_v3.py +95 -0
  34. hiddenlayer/sdk/rest/models/fix.py +113 -0
  35. hiddenlayer/sdk/rest/models/get_multipart_upload_response.py +1 -1
  36. hiddenlayer/sdk/rest/models/graph.py +123 -0
  37. hiddenlayer/sdk/rest/models/graph_traversal.py +97 -0
  38. hiddenlayer/sdk/rest/models/invocation.py +199 -0
  39. hiddenlayer/sdk/rest/models/location.py +146 -0
  40. hiddenlayer/sdk/rest/models/{validation_error_model_loc_inner.py → location_inner.py} +7 -7
  41. hiddenlayer/sdk/rest/models/location_relationship.py +107 -0
  42. hiddenlayer/sdk/rest/models/logical_location.py +104 -0
  43. hiddenlayer/sdk/rest/models/message.py +92 -0
  44. hiddenlayer/sdk/rest/models/mitre_atlas_inner.py +110 -0
  45. hiddenlayer/sdk/rest/models/model.py +1 -1
  46. hiddenlayer/sdk/rest/models/model_inventory_info.py +99 -0
  47. hiddenlayer/sdk/rest/models/model_query_response.py +1 -1
  48. hiddenlayer/sdk/rest/models/model_scan_api_v3_scan_model_version_id_patch200_response.py +87 -0
  49. hiddenlayer/sdk/rest/models/model_scan_api_v3_scan_query200_response.py +102 -0
  50. hiddenlayer/sdk/rest/models/multiformat_message_string.py +95 -0
  51. hiddenlayer/sdk/rest/models/multipart_upload_part.py +1 -1
  52. hiddenlayer/sdk/rest/models/node.py +122 -0
  53. hiddenlayer/sdk/rest/models/notification.py +157 -0
  54. hiddenlayer/sdk/rest/models/paged_response_with_total.py +94 -0
  55. hiddenlayer/sdk/rest/models/physical_location.py +94 -0
  56. hiddenlayer/sdk/rest/models/property_bag.py +101 -0
  57. hiddenlayer/sdk/rest/models/rectangle.py +110 -0
  58. hiddenlayer/sdk/rest/models/region.py +127 -0
  59. hiddenlayer/sdk/rest/models/replacement.py +103 -0
  60. hiddenlayer/sdk/rest/models/reporting_configuration.py +113 -0
  61. hiddenlayer/sdk/rest/models/reporting_descriptor.py +162 -0
  62. hiddenlayer/sdk/rest/models/reporting_descriptor_reference.py +103 -0
  63. hiddenlayer/sdk/rest/models/reporting_descriptor_relationship.py +115 -0
  64. hiddenlayer/sdk/rest/models/result.py +312 -0
  65. hiddenlayer/sdk/rest/models/result_provenance.py +133 -0
  66. hiddenlayer/sdk/rest/models/rule_details_inner.py +102 -0
  67. hiddenlayer/sdk/rest/models/run.py +318 -0
  68. hiddenlayer/sdk/rest/models/run_automation_details.py +129 -0
  69. hiddenlayer/sdk/rest/models/sarif210.py +123 -0
  70. hiddenlayer/sdk/rest/models/scan_create_request.py +87 -0
  71. hiddenlayer/sdk/rest/models/scan_detection_v3.py +156 -0
  72. hiddenlayer/sdk/rest/models/scan_header_v3.py +129 -0
  73. hiddenlayer/sdk/rest/models/scan_job.py +109 -0
  74. hiddenlayer/sdk/rest/models/scan_job_inventory.py +137 -0
  75. hiddenlayer/sdk/rest/models/scan_model_details_v3.py +95 -0
  76. hiddenlayer/sdk/rest/models/scan_model_ids_v3.py +89 -0
  77. hiddenlayer/sdk/rest/models/scan_model_request.py +1 -1
  78. hiddenlayer/sdk/rest/models/scan_report_v3.py +139 -0
  79. hiddenlayer/sdk/rest/models/{file_info.py → scan_results.py} +14 -6
  80. hiddenlayer/sdk/rest/models/scan_results_v2.py +30 -10
  81. hiddenlayer/sdk/rest/models/security_posture.py +89 -0
  82. hiddenlayer/sdk/rest/models/sensor_sor_model_card_query_response.py +101 -0
  83. hiddenlayer/sdk/rest/models/sensor_sor_model_card_response.py +127 -0
  84. hiddenlayer/sdk/rest/models/sensor_sor_query_filter.py +1 -1
  85. hiddenlayer/sdk/rest/models/sensor_sor_query_request.py +1 -1
  86. hiddenlayer/sdk/rest/models/special_locations.py +97 -0
  87. hiddenlayer/sdk/rest/models/stack.py +113 -0
  88. hiddenlayer/sdk/rest/models/stack_frame.py +104 -0
  89. hiddenlayer/sdk/rest/models/submission_response.py +1 -1
  90. hiddenlayer/sdk/rest/models/submission_v2.py +1 -1
  91. hiddenlayer/sdk/rest/models/suppression.py +133 -0
  92. hiddenlayer/sdk/rest/models/thread_flow.py +144 -0
  93. hiddenlayer/sdk/rest/models/thread_flow_location.py +166 -0
  94. hiddenlayer/sdk/rest/models/tool.py +107 -0
  95. hiddenlayer/sdk/rest/models/tool_component.py +251 -0
  96. hiddenlayer/sdk/rest/models/tool_component_reference.py +108 -0
  97. hiddenlayer/sdk/rest/models/translation_metadata.py +110 -0
  98. hiddenlayer/sdk/rest/models/validation_error_model.py +4 -4
  99. hiddenlayer/sdk/rest/models/version_control_details.py +108 -0
  100. hiddenlayer/sdk/rest/models/web_request.py +112 -0
  101. hiddenlayer/sdk/rest/models/web_response.py +112 -0
  102. hiddenlayer/sdk/rest/rest.py +1 -1
  103. hiddenlayer/sdk/services/model.py +5 -2
  104. hiddenlayer/sdk/services/model_scan.py +153 -105
  105. hiddenlayer/sdk/version.py +1 -1
  106. {hiddenlayer_sdk-0.1.1.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/METADATA +39 -20
  107. hiddenlayer_sdk-1.0.0.dist-info/RECORD +118 -0
  108. {hiddenlayer_sdk-0.1.1.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/WHEEL +1 -1
  109. hiddenlayer/sdk/enterprise/__init__.py +0 -0
  110. hiddenlayer/sdk/enterprise/enterprise_model_scan_api.py +0 -55
  111. hiddenlayer_sdk-0.1.1.dist-info/RECORD +0 -43
  112. {hiddenlayer_sdk-0.1.1.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/LICENSE +0 -0
  113. {hiddenlayer_sdk-0.1.1.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,312 @@
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, Union
22
+ from typing_extensions import Annotated
23
+ from hiddenlayer.sdk.rest.models.artifact_location import ArtifactLocation
24
+ from hiddenlayer.sdk.rest.models.attachment import Attachment
25
+ from hiddenlayer.sdk.rest.models.code_flow import CodeFlow
26
+ from hiddenlayer.sdk.rest.models.fix import Fix
27
+ from hiddenlayer.sdk.rest.models.graph import Graph
28
+ from hiddenlayer.sdk.rest.models.graph_traversal import GraphTraversal
29
+ from hiddenlayer.sdk.rest.models.location import Location
30
+ from hiddenlayer.sdk.rest.models.message import Message
31
+ from hiddenlayer.sdk.rest.models.property_bag import PropertyBag
32
+ from hiddenlayer.sdk.rest.models.reporting_descriptor_reference import ReportingDescriptorReference
33
+ from hiddenlayer.sdk.rest.models.result_provenance import ResultProvenance
34
+ from hiddenlayer.sdk.rest.models.stack import Stack
35
+ from hiddenlayer.sdk.rest.models.suppression import Suppression
36
+ from hiddenlayer.sdk.rest.models.web_request import WebRequest
37
+ from hiddenlayer.sdk.rest.models.web_response import WebResponse
38
+ from typing import Optional, Set
39
+ from typing_extensions import Self
40
+
41
+ class Result(BaseModel):
42
+ """
43
+ A result produced by an analysis tool.
44
+ """ # noqa: E501
45
+ rule_id: Optional[StrictStr] = Field(default=None, description="The stable, unique identifier of the rule, if any, to which this result is relevant.", alias="ruleId")
46
+ rule_index: Optional[Annotated[int, Field(strict=True, ge=-1)]] = Field(default=-1, description="The index within the tool component rules array of the rule object associated with this result.", alias="ruleIndex")
47
+ rule: Optional[ReportingDescriptorReference] = None
48
+ kind: Optional[StrictStr] = Field(default='fail', description="A value that categorizes results by evaluation state.")
49
+ level: Optional[StrictStr] = Field(default='warning', description="A value specifying the severity level of the result.")
50
+ message: Optional[Message]
51
+ analysis_target: Optional[ArtifactLocation] = Field(default=None, alias="analysisTarget")
52
+ locations: Optional[Annotated[List[Location], Field(min_length=0)]] = Field(default=None, description="The set of locations where the result was detected. Specify only one location unless the problem indicated by the result can only be corrected by making a change at every specified location.")
53
+ guid: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A stable, unique identifier for the result in the form of a GUID.")
54
+ correlation_guid: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A stable, unique identifier for the equivalence class of logically identical results to which this result belongs, in the form of a GUID.", alias="correlationGuid")
55
+ occurrence_count: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="A positive integer specifying the number of times this logically unique result was observed in this run.", alias="occurrenceCount")
56
+ partial_fingerprints: Optional[Dict[str, StrictStr]] = Field(default=None, description="A set of strings that contribute to the stable, unique identity of the result.", alias="partialFingerprints")
57
+ fingerprints: Optional[Dict[str, StrictStr]] = Field(default=None, description="A set of strings each of which individually defines a stable, unique identity for the result.")
58
+ stacks: Optional[Annotated[List[Stack], Field(min_length=0)]] = Field(default=None, description="An array of 'stack' objects relevant to the result.")
59
+ code_flows: Optional[Annotated[List[CodeFlow], Field(min_length=0)]] = Field(default=None, description="An array of 'codeFlow' objects relevant to the result.", alias="codeFlows")
60
+ graphs: Optional[Annotated[List[Graph], Field(min_length=0)]] = Field(default=None, description="An array of zero or more unique graph objects associated with the result.")
61
+ graph_traversals: Optional[Annotated[List[Optional[GraphTraversal]], Field(min_length=0)]] = Field(default=None, description="An array of one or more unique 'graphTraversal' objects.", alias="graphTraversals")
62
+ related_locations: Optional[Annotated[List[Location], Field(min_length=0)]] = Field(default=None, description="A set of locations relevant to this result.", alias="relatedLocations")
63
+ suppressions: Optional[Annotated[List[Suppression], Field(min_length=0)]] = Field(default=None, description="A set of suppressions relevant to this result.")
64
+ baseline_state: Optional[StrictStr] = Field(default=None, description="The state of a result relative to a baseline of a previous run.", alias="baselineState")
65
+ rank: Optional[Union[Annotated[float, Field(le=100, strict=True, ge=-1)], Annotated[int, Field(le=100, strict=True, ge=-1)]]] = Field(default=-1, description="A number representing the priority or importance of the result.")
66
+ attachments: Optional[Annotated[List[Attachment], Field(min_length=0)]] = Field(default=None, description="A set of artifacts relevant to the result.")
67
+ hosted_viewer_uri: Optional[StrictStr] = Field(default=None, description="An absolute URI at which the result can be viewed.", alias="hostedViewerUri")
68
+ work_item_uris: Optional[Annotated[List[StrictStr], Field(min_length=0)]] = Field(default=None, description="The URIs of the work items associated with this result.", alias="workItemUris")
69
+ provenance: Optional[ResultProvenance] = None
70
+ fixes: Optional[Annotated[List[Fix], Field(min_length=0)]] = Field(default=None, description="An array of 'fix' objects, each of which represents a proposed fix to the problem indicated by the result.")
71
+ taxa: Optional[Annotated[List[Optional[ReportingDescriptorReference]], Field(min_length=0)]] = Field(default=None, description="An array of references to taxonomy reporting descriptors that are applicable to the result.")
72
+ web_request: Optional[WebRequest] = Field(default=None, alias="webRequest")
73
+ web_response: Optional[WebResponse] = Field(default=None, alias="webResponse")
74
+ properties: Optional[PropertyBag] = None
75
+ __properties: ClassVar[List[str]] = ["ruleId", "ruleIndex", "rule", "kind", "level", "message", "analysisTarget", "locations", "guid", "correlationGuid", "occurrenceCount", "partialFingerprints", "fingerprints", "stacks", "codeFlows", "graphs", "graphTraversals", "relatedLocations", "suppressions", "baselineState", "rank", "attachments", "hostedViewerUri", "workItemUris", "provenance", "fixes", "taxa", "webRequest", "webResponse", "properties"]
76
+
77
+ @field_validator('kind')
78
+ def kind_validate_enum(cls, value):
79
+ """Validates the enum"""
80
+ if value is None:
81
+ return value
82
+
83
+ if value not in set(['notApplicable', 'pass', 'fail', 'review', 'open', 'informational']):
84
+ raise ValueError("must be one of enum values ('notApplicable', 'pass', 'fail', 'review', 'open', 'informational')")
85
+ return value
86
+
87
+ @field_validator('level')
88
+ def level_validate_enum(cls, value):
89
+ """Validates the enum"""
90
+ if value is None:
91
+ return value
92
+
93
+ if value not in set(['none', 'note', 'warning', 'error']):
94
+ raise ValueError("must be one of enum values ('none', 'note', 'warning', 'error')")
95
+ return value
96
+
97
+ @field_validator('guid')
98
+ def guid_validate_regular_expression(cls, value):
99
+ """Validates the regular expression"""
100
+ if value is None:
101
+ return value
102
+
103
+ if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", value):
104
+ raise ValueError(r"must validate the regular expression /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/")
105
+ return value
106
+
107
+ @field_validator('correlation_guid')
108
+ def correlation_guid_validate_regular_expression(cls, value):
109
+ """Validates the regular expression"""
110
+ if value is None:
111
+ return value
112
+
113
+ if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", value):
114
+ raise ValueError(r"must validate the regular expression /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/")
115
+ return value
116
+
117
+ @field_validator('baseline_state')
118
+ def baseline_state_validate_enum(cls, value):
119
+ """Validates the enum"""
120
+ if value is None:
121
+ return value
122
+
123
+ if value not in set(['new', 'unchanged', 'updated', 'absent']):
124
+ raise ValueError("must be one of enum values ('new', 'unchanged', 'updated', 'absent')")
125
+ return value
126
+
127
+ model_config = ConfigDict(
128
+ populate_by_name=True,
129
+ validate_assignment=True,
130
+ protected_namespaces=(),
131
+ )
132
+
133
+
134
+ def to_str(self) -> str:
135
+ """Returns the string representation of the model using alias"""
136
+ return pprint.pformat(self.model_dump(by_alias=True))
137
+
138
+ def to_json(self) -> str:
139
+ """Returns the JSON representation of the model using alias"""
140
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
141
+ return json.dumps(self.to_dict())
142
+
143
+ @classmethod
144
+ def from_json(cls, json_str: str) -> Optional[Self]:
145
+ """Create an instance of Result from a JSON string"""
146
+ return cls.from_dict(json.loads(json_str))
147
+
148
+ def to_dict(self) -> Dict[str, Any]:
149
+ """Return the dictionary representation of the model using alias.
150
+
151
+ This has the following differences from calling pydantic's
152
+ `self.model_dump(by_alias=True)`:
153
+
154
+ * `None` is only added to the output dict for nullable fields that
155
+ were set at model initialization. Other fields with value `None`
156
+ are ignored.
157
+ """
158
+ excluded_fields: Set[str] = set([
159
+ ])
160
+
161
+ _dict = self.model_dump(
162
+ by_alias=True,
163
+ exclude=excluded_fields,
164
+ exclude_none=True,
165
+ )
166
+ # override the default output from pydantic by calling `to_dict()` of rule
167
+ if self.rule:
168
+ _dict['rule'] = self.rule.to_dict()
169
+ # override the default output from pydantic by calling `to_dict()` of message
170
+ if self.message:
171
+ _dict['message'] = self.message.to_dict()
172
+ # override the default output from pydantic by calling `to_dict()` of analysis_target
173
+ if self.analysis_target:
174
+ _dict['analysisTarget'] = self.analysis_target.to_dict()
175
+ # override the default output from pydantic by calling `to_dict()` of each item in locations (list)
176
+ _items = []
177
+ if self.locations:
178
+ for _item in self.locations:
179
+ if _item:
180
+ _items.append(_item.to_dict())
181
+ _dict['locations'] = _items
182
+ # override the default output from pydantic by calling `to_dict()` of each item in stacks (list)
183
+ _items = []
184
+ if self.stacks:
185
+ for _item in self.stacks:
186
+ if _item:
187
+ _items.append(_item.to_dict())
188
+ _dict['stacks'] = _items
189
+ # override the default output from pydantic by calling `to_dict()` of each item in code_flows (list)
190
+ _items = []
191
+ if self.code_flows:
192
+ for _item in self.code_flows:
193
+ if _item:
194
+ _items.append(_item.to_dict())
195
+ _dict['codeFlows'] = _items
196
+ # override the default output from pydantic by calling `to_dict()` of each item in graphs (list)
197
+ _items = []
198
+ if self.graphs:
199
+ for _item in self.graphs:
200
+ if _item:
201
+ _items.append(_item.to_dict())
202
+ _dict['graphs'] = _items
203
+ # override the default output from pydantic by calling `to_dict()` of each item in graph_traversals (list)
204
+ _items = []
205
+ if self.graph_traversals:
206
+ for _item in self.graph_traversals:
207
+ if _item:
208
+ _items.append(_item.to_dict())
209
+ _dict['graphTraversals'] = _items
210
+ # override the default output from pydantic by calling `to_dict()` of each item in related_locations (list)
211
+ _items = []
212
+ if self.related_locations:
213
+ for _item in self.related_locations:
214
+ if _item:
215
+ _items.append(_item.to_dict())
216
+ _dict['relatedLocations'] = _items
217
+ # override the default output from pydantic by calling `to_dict()` of each item in suppressions (list)
218
+ _items = []
219
+ if self.suppressions:
220
+ for _item in self.suppressions:
221
+ if _item:
222
+ _items.append(_item.to_dict())
223
+ _dict['suppressions'] = _items
224
+ # override the default output from pydantic by calling `to_dict()` of each item in attachments (list)
225
+ _items = []
226
+ if self.attachments:
227
+ for _item in self.attachments:
228
+ if _item:
229
+ _items.append(_item.to_dict())
230
+ _dict['attachments'] = _items
231
+ # override the default output from pydantic by calling `to_dict()` of provenance
232
+ if self.provenance:
233
+ _dict['provenance'] = self.provenance.to_dict()
234
+ # override the default output from pydantic by calling `to_dict()` of each item in fixes (list)
235
+ _items = []
236
+ if self.fixes:
237
+ for _item in self.fixes:
238
+ if _item:
239
+ _items.append(_item.to_dict())
240
+ _dict['fixes'] = _items
241
+ # override the default output from pydantic by calling `to_dict()` of each item in taxa (list)
242
+ _items = []
243
+ if self.taxa:
244
+ for _item in self.taxa:
245
+ if _item:
246
+ _items.append(_item.to_dict())
247
+ _dict['taxa'] = _items
248
+ # override the default output from pydantic by calling `to_dict()` of web_request
249
+ if self.web_request:
250
+ _dict['webRequest'] = self.web_request.to_dict()
251
+ # override the default output from pydantic by calling `to_dict()` of web_response
252
+ if self.web_response:
253
+ _dict['webResponse'] = self.web_response.to_dict()
254
+ # override the default output from pydantic by calling `to_dict()` of properties
255
+ if self.properties:
256
+ _dict['properties'] = self.properties.to_dict()
257
+ # set to None if rule (nullable) is None
258
+ # and model_fields_set contains the field
259
+ if self.rule is None and "rule" in self.model_fields_set:
260
+ _dict['rule'] = None
261
+
262
+ # set to None if message (nullable) is None
263
+ # and model_fields_set contains the field
264
+ if self.message is None and "message" in self.model_fields_set:
265
+ _dict['message'] = None
266
+
267
+ return _dict
268
+
269
+ @classmethod
270
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
271
+ """Create an instance of Result from a dict"""
272
+ if obj is None:
273
+ return None
274
+
275
+ if not isinstance(obj, dict):
276
+ return cls.model_validate(obj)
277
+
278
+ _obj = cls.model_validate({
279
+ "ruleId": obj.get("ruleId"),
280
+ "ruleIndex": obj.get("ruleIndex") if obj.get("ruleIndex") is not None else -1,
281
+ "rule": ReportingDescriptorReference.from_dict(obj["rule"]) if obj.get("rule") is not None else None,
282
+ "kind": obj.get("kind") if obj.get("kind") is not None else 'fail',
283
+ "level": obj.get("level") if obj.get("level") is not None else 'warning',
284
+ "message": Message.from_dict(obj["message"]) if obj.get("message") is not None else None,
285
+ "analysisTarget": ArtifactLocation.from_dict(obj["analysisTarget"]) if obj.get("analysisTarget") is not None else None,
286
+ "locations": [Location.from_dict(_item) for _item in obj["locations"]] if obj.get("locations") is not None else None,
287
+ "guid": obj.get("guid"),
288
+ "correlationGuid": obj.get("correlationGuid"),
289
+ "occurrenceCount": obj.get("occurrenceCount"),
290
+ "partialFingerprints": obj.get("partialFingerprints"),
291
+ "fingerprints": obj.get("fingerprints"),
292
+ "stacks": [Stack.from_dict(_item) for _item in obj["stacks"]] if obj.get("stacks") is not None else None,
293
+ "codeFlows": [CodeFlow.from_dict(_item) for _item in obj["codeFlows"]] if obj.get("codeFlows") is not None else None,
294
+ "graphs": [Graph.from_dict(_item) for _item in obj["graphs"]] if obj.get("graphs") is not None else None,
295
+ "graphTraversals": [GraphTraversal.from_dict(_item) for _item in obj["graphTraversals"]] if obj.get("graphTraversals") is not None else None,
296
+ "relatedLocations": [Location.from_dict(_item) for _item in obj["relatedLocations"]] if obj.get("relatedLocations") is not None else None,
297
+ "suppressions": [Suppression.from_dict(_item) for _item in obj["suppressions"]] if obj.get("suppressions") is not None else None,
298
+ "baselineState": obj.get("baselineState"),
299
+ "rank": obj.get("rank") if obj.get("rank") is not None else -1,
300
+ "attachments": [Attachment.from_dict(_item) for _item in obj["attachments"]] if obj.get("attachments") is not None else None,
301
+ "hostedViewerUri": obj.get("hostedViewerUri"),
302
+ "workItemUris": obj.get("workItemUris"),
303
+ "provenance": ResultProvenance.from_dict(obj["provenance"]) if obj.get("provenance") is not None else None,
304
+ "fixes": [Fix.from_dict(_item) for _item in obj["fixes"]] if obj.get("fixes") is not None else None,
305
+ "taxa": [ReportingDescriptorReference.from_dict(_item) for _item in obj["taxa"]] if obj.get("taxa") is not None else None,
306
+ "webRequest": WebRequest.from_dict(obj["webRequest"]) if obj.get("webRequest") is not None else None,
307
+ "webResponse": WebResponse.from_dict(obj["webResponse"]) if obj.get("webResponse") is not None else None,
308
+ "properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
309
+ })
310
+ return _obj
311
+
312
+
@@ -0,0 +1,133 @@
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 datetime import datetime
21
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing_extensions import Annotated
24
+ from hiddenlayer.sdk.rest.models.physical_location import PhysicalLocation
25
+ from hiddenlayer.sdk.rest.models.property_bag import PropertyBag
26
+ from typing import Optional, Set
27
+ from typing_extensions import Self
28
+
29
+ class ResultProvenance(BaseModel):
30
+ """
31
+ Contains information about how and when a result was detected.
32
+ """ # noqa: E501
33
+ first_detection_time_utc: Optional[datetime] = Field(default=None, description="The Coordinated Universal Time (UTC) date and time at which the result was first detected. See \"Date/time properties\" in the SARIF spec for the required format.", alias="firstDetectionTimeUtc")
34
+ last_detection_time_utc: Optional[datetime] = Field(default=None, description="The Coordinated Universal Time (UTC) date and time at which the result was most recently detected. See \"Date/time properties\" in the SARIF spec for the required format.", alias="lastDetectionTimeUtc")
35
+ first_detection_run_guid: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A GUID-valued string equal to the automationDetails.guid property of the run in which the result was first detected.", alias="firstDetectionRunGuid")
36
+ last_detection_run_guid: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A GUID-valued string equal to the automationDetails.guid property of the run in which the result was most recently detected.", alias="lastDetectionRunGuid")
37
+ invocation_index: Optional[Annotated[int, Field(strict=True, ge=-1)]] = Field(default=-1, description="The index within the run.invocations array of the invocation object which describes the tool invocation that detected the result.", alias="invocationIndex")
38
+ conversion_sources: Optional[Annotated[List[Optional[PhysicalLocation]], Field(min_length=0)]] = Field(default=None, description="An array of physicalLocation objects which specify the portions of an analysis tool's output that a converter transformed into the result.", alias="conversionSources")
39
+ properties: Optional[PropertyBag] = None
40
+ __properties: ClassVar[List[str]] = ["firstDetectionTimeUtc", "lastDetectionTimeUtc", "firstDetectionRunGuid", "lastDetectionRunGuid", "invocationIndex", "conversionSources", "properties"]
41
+
42
+ @field_validator('first_detection_run_guid')
43
+ def first_detection_run_guid_validate_regular_expression(cls, value):
44
+ """Validates the regular expression"""
45
+ if value is None:
46
+ return value
47
+
48
+ if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", value):
49
+ raise ValueError(r"must validate the regular expression /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/")
50
+ return value
51
+
52
+ @field_validator('last_detection_run_guid')
53
+ def last_detection_run_guid_validate_regular_expression(cls, value):
54
+ """Validates the regular expression"""
55
+ if value is None:
56
+ return value
57
+
58
+ if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", value):
59
+ raise ValueError(r"must validate the regular expression /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/")
60
+ return value
61
+
62
+ model_config = ConfigDict(
63
+ populate_by_name=True,
64
+ validate_assignment=True,
65
+ protected_namespaces=(),
66
+ )
67
+
68
+
69
+ def to_str(self) -> str:
70
+ """Returns the string representation of the model using alias"""
71
+ return pprint.pformat(self.model_dump(by_alias=True))
72
+
73
+ def to_json(self) -> str:
74
+ """Returns the JSON representation of the model using alias"""
75
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
76
+ return json.dumps(self.to_dict())
77
+
78
+ @classmethod
79
+ def from_json(cls, json_str: str) -> Optional[Self]:
80
+ """Create an instance of ResultProvenance from a JSON string"""
81
+ return cls.from_dict(json.loads(json_str))
82
+
83
+ def to_dict(self) -> Dict[str, Any]:
84
+ """Return the dictionary representation of the model using alias.
85
+
86
+ This has the following differences from calling pydantic's
87
+ `self.model_dump(by_alias=True)`:
88
+
89
+ * `None` is only added to the output dict for nullable fields that
90
+ were set at model initialization. Other fields with value `None`
91
+ are ignored.
92
+ """
93
+ excluded_fields: Set[str] = set([
94
+ ])
95
+
96
+ _dict = self.model_dump(
97
+ by_alias=True,
98
+ exclude=excluded_fields,
99
+ exclude_none=True,
100
+ )
101
+ # override the default output from pydantic by calling `to_dict()` of each item in conversion_sources (list)
102
+ _items = []
103
+ if self.conversion_sources:
104
+ for _item in self.conversion_sources:
105
+ if _item:
106
+ _items.append(_item.to_dict())
107
+ _dict['conversionSources'] = _items
108
+ # override the default output from pydantic by calling `to_dict()` of properties
109
+ if self.properties:
110
+ _dict['properties'] = self.properties.to_dict()
111
+ return _dict
112
+
113
+ @classmethod
114
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
115
+ """Create an instance of ResultProvenance from a dict"""
116
+ if obj is None:
117
+ return None
118
+
119
+ if not isinstance(obj, dict):
120
+ return cls.model_validate(obj)
121
+
122
+ _obj = cls.model_validate({
123
+ "firstDetectionTimeUtc": obj.get("firstDetectionTimeUtc"),
124
+ "lastDetectionTimeUtc": obj.get("lastDetectionTimeUtc"),
125
+ "firstDetectionRunGuid": obj.get("firstDetectionRunGuid"),
126
+ "lastDetectionRunGuid": obj.get("lastDetectionRunGuid"),
127
+ "invocationIndex": obj.get("invocationIndex") if obj.get("invocationIndex") is not None else -1,
128
+ "conversionSources": [PhysicalLocation.from_dict(_item) for _item in obj["conversionSources"]] if obj.get("conversionSources") is not None else None,
129
+ "properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
130
+ })
131
+ return _obj
132
+
133
+
@@ -0,0 +1,102 @@
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 datetime import datetime
21
+ from pydantic import BaseModel, ConfigDict, Field, 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 RuleDetailsInner(BaseModel):
27
+ """
28
+ RuleDetailsInner
29
+ """ # noqa: E501
30
+ status: Optional[StrictStr] = Field(default=None, description="status")
31
+ status_at: Optional[datetime] = Field(default=None, description="date-time when the details entry was created")
32
+ description: Optional[StrictStr] = Field(default=None, description="description of the deprecation")
33
+ __properties: ClassVar[List[str]] = ["status", "status_at", "description"]
34
+
35
+ @field_validator('status')
36
+ def status_validate_enum(cls, value):
37
+ """Validates the enum"""
38
+ if value is None:
39
+ return value
40
+
41
+ if value not in set(['created', 'deprecated', 'updated', 'superseded']):
42
+ raise ValueError("must be one of enum values ('created', 'deprecated', 'updated', 'superseded')")
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 RuleDetailsInner 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
+ return _dict
85
+
86
+ @classmethod
87
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
88
+ """Create an instance of RuleDetailsInner from a dict"""
89
+ if obj is None:
90
+ return None
91
+
92
+ if not isinstance(obj, dict):
93
+ return cls.model_validate(obj)
94
+
95
+ _obj = cls.model_validate({
96
+ "status": obj.get("status"),
97
+ "status_at": obj.get("status_at"),
98
+ "description": obj.get("description")
99
+ })
100
+ return _obj
101
+
102
+