hiddenlayer-sdk 0.1.2__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.
- hiddenlayer/sdk/models.py +45 -8
- hiddenlayer/sdk/rest/__init__.py +80 -3
- hiddenlayer/sdk/rest/api/__init__.py +3 -0
- hiddenlayer/sdk/rest/api/aidr_predictive_api.py +1 -1
- hiddenlayer/sdk/rest/api/health_api.py +272 -0
- hiddenlayer/sdk/rest/api/model_scan_api.py +1 -1
- hiddenlayer/sdk/rest/api/model_supply_chain_api.py +2927 -0
- hiddenlayer/sdk/rest/api/readiness_api.py +272 -0
- hiddenlayer/sdk/rest/api/sensor_api.py +345 -16
- hiddenlayer/sdk/rest/api_client.py +1 -1
- hiddenlayer/sdk/rest/configuration.py +4 -4
- hiddenlayer/sdk/rest/exceptions.py +1 -1
- hiddenlayer/sdk/rest/models/__init__.py +77 -3
- hiddenlayer/sdk/rest/models/address.py +110 -0
- hiddenlayer/sdk/rest/models/artifact.py +155 -0
- hiddenlayer/sdk/rest/models/artifact_change.py +108 -0
- hiddenlayer/sdk/rest/models/artifact_content.py +101 -0
- hiddenlayer/sdk/rest/models/artifact_location.py +109 -0
- hiddenlayer/sdk/rest/models/attachment.py +129 -0
- hiddenlayer/sdk/rest/models/code_flow.py +113 -0
- hiddenlayer/sdk/rest/models/configuration_override.py +108 -0
- hiddenlayer/sdk/rest/models/conversion.py +114 -0
- hiddenlayer/sdk/rest/models/create_sensor_request.py +1 -1
- hiddenlayer/sdk/rest/models/detections.py +101 -0
- hiddenlayer/sdk/rest/models/edge.py +108 -0
- hiddenlayer/sdk/rest/models/edge_traversal.py +122 -0
- hiddenlayer/sdk/rest/models/exception.py +113 -0
- hiddenlayer/sdk/rest/models/external_properties.py +273 -0
- hiddenlayer/sdk/rest/models/external_property_file_reference.py +102 -0
- hiddenlayer/sdk/rest/models/external_property_file_references.py +240 -0
- hiddenlayer/sdk/rest/models/file_details_v3.py +140 -0
- hiddenlayer/sdk/rest/models/file_results_inner.py +121 -0
- hiddenlayer/sdk/rest/models/file_scan_report_v3.py +95 -0
- hiddenlayer/sdk/rest/models/fix.py +113 -0
- hiddenlayer/sdk/rest/models/get_multipart_upload_response.py +1 -1
- hiddenlayer/sdk/rest/models/graph.py +123 -0
- hiddenlayer/sdk/rest/models/graph_traversal.py +97 -0
- hiddenlayer/sdk/rest/models/invocation.py +199 -0
- hiddenlayer/sdk/rest/models/location.py +146 -0
- hiddenlayer/sdk/rest/models/{validation_error_model_loc_inner.py → location_inner.py} +7 -7
- hiddenlayer/sdk/rest/models/location_relationship.py +107 -0
- hiddenlayer/sdk/rest/models/logical_location.py +104 -0
- hiddenlayer/sdk/rest/models/message.py +92 -0
- hiddenlayer/sdk/rest/models/mitre_atlas_inner.py +110 -0
- hiddenlayer/sdk/rest/models/model.py +1 -1
- hiddenlayer/sdk/rest/models/model_inventory_info.py +99 -0
- hiddenlayer/sdk/rest/models/model_query_response.py +1 -1
- hiddenlayer/sdk/rest/models/model_scan_api_v3_scan_model_version_id_patch200_response.py +87 -0
- hiddenlayer/sdk/rest/models/model_scan_api_v3_scan_query200_response.py +102 -0
- hiddenlayer/sdk/rest/models/multiformat_message_string.py +95 -0
- hiddenlayer/sdk/rest/models/multipart_upload_part.py +1 -1
- hiddenlayer/sdk/rest/models/node.py +122 -0
- hiddenlayer/sdk/rest/models/notification.py +157 -0
- hiddenlayer/sdk/rest/models/paged_response_with_total.py +94 -0
- hiddenlayer/sdk/rest/models/physical_location.py +94 -0
- hiddenlayer/sdk/rest/models/property_bag.py +101 -0
- hiddenlayer/sdk/rest/models/rectangle.py +110 -0
- hiddenlayer/sdk/rest/models/region.py +127 -0
- hiddenlayer/sdk/rest/models/replacement.py +103 -0
- hiddenlayer/sdk/rest/models/reporting_configuration.py +113 -0
- hiddenlayer/sdk/rest/models/reporting_descriptor.py +162 -0
- hiddenlayer/sdk/rest/models/reporting_descriptor_reference.py +103 -0
- hiddenlayer/sdk/rest/models/reporting_descriptor_relationship.py +115 -0
- hiddenlayer/sdk/rest/models/result.py +312 -0
- hiddenlayer/sdk/rest/models/result_provenance.py +133 -0
- hiddenlayer/sdk/rest/models/rule_details_inner.py +102 -0
- hiddenlayer/sdk/rest/models/run.py +318 -0
- hiddenlayer/sdk/rest/models/run_automation_details.py +129 -0
- hiddenlayer/sdk/rest/models/sarif210.py +123 -0
- hiddenlayer/sdk/rest/models/scan_create_request.py +87 -0
- hiddenlayer/sdk/rest/models/scan_detection_v3.py +156 -0
- hiddenlayer/sdk/rest/models/scan_header_v3.py +129 -0
- hiddenlayer/sdk/rest/models/scan_job.py +109 -0
- hiddenlayer/sdk/rest/models/scan_job_inventory.py +137 -0
- hiddenlayer/sdk/rest/models/scan_model_details_v3.py +95 -0
- hiddenlayer/sdk/rest/models/scan_model_ids_v3.py +89 -0
- hiddenlayer/sdk/rest/models/scan_model_request.py +1 -1
- hiddenlayer/sdk/rest/models/scan_report_v3.py +139 -0
- hiddenlayer/sdk/rest/models/{file_info.py → scan_results.py} +14 -6
- hiddenlayer/sdk/rest/models/scan_results_v2.py +30 -10
- hiddenlayer/sdk/rest/models/security_posture.py +89 -0
- hiddenlayer/sdk/rest/models/sensor_sor_model_card_query_response.py +101 -0
- hiddenlayer/sdk/rest/models/sensor_sor_model_card_response.py +127 -0
- hiddenlayer/sdk/rest/models/sensor_sor_query_filter.py +1 -1
- hiddenlayer/sdk/rest/models/sensor_sor_query_request.py +1 -1
- hiddenlayer/sdk/rest/models/special_locations.py +97 -0
- hiddenlayer/sdk/rest/models/stack.py +113 -0
- hiddenlayer/sdk/rest/models/stack_frame.py +104 -0
- hiddenlayer/sdk/rest/models/submission_response.py +1 -1
- hiddenlayer/sdk/rest/models/submission_v2.py +1 -1
- hiddenlayer/sdk/rest/models/suppression.py +133 -0
- hiddenlayer/sdk/rest/models/thread_flow.py +144 -0
- hiddenlayer/sdk/rest/models/thread_flow_location.py +166 -0
- hiddenlayer/sdk/rest/models/tool.py +107 -0
- hiddenlayer/sdk/rest/models/tool_component.py +251 -0
- hiddenlayer/sdk/rest/models/tool_component_reference.py +108 -0
- hiddenlayer/sdk/rest/models/translation_metadata.py +110 -0
- hiddenlayer/sdk/rest/models/validation_error_model.py +4 -4
- hiddenlayer/sdk/rest/models/version_control_details.py +108 -0
- hiddenlayer/sdk/rest/models/web_request.py +112 -0
- hiddenlayer/sdk/rest/models/web_response.py +112 -0
- hiddenlayer/sdk/rest/rest.py +1 -1
- hiddenlayer/sdk/services/model.py +5 -2
- hiddenlayer/sdk/services/model_scan.py +153 -105
- hiddenlayer/sdk/version.py +1 -1
- {hiddenlayer_sdk-0.1.2.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/METADATA +39 -20
- hiddenlayer_sdk-1.0.0.dist-info/RECORD +118 -0
- {hiddenlayer_sdk-0.1.2.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/WHEEL +1 -1
- hiddenlayer/sdk/enterprise/__init__.py +0 -0
- hiddenlayer/sdk/enterprise/enterprise_model_scan_api.py +0 -55
- hiddenlayer_sdk-0.1.2.dist-info/RECORD +0 -43
- {hiddenlayer_sdk-0.1.2.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/LICENSE +0 -0
- {hiddenlayer_sdk-0.1.2.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,99 @@
|
|
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 typing import Optional, Set
|
23
|
+
from typing_extensions import Self
|
24
|
+
|
25
|
+
class ModelInventoryInfo(BaseModel):
|
26
|
+
"""
|
27
|
+
information about model and version that this scan relates to
|
28
|
+
""" # noqa: E501
|
29
|
+
model_name: StrictStr = Field(description="name of the model")
|
30
|
+
model_version: StrictStr = Field(description="version of the model")
|
31
|
+
model_source: StrictStr = Field(description="source (provider) info")
|
32
|
+
requested_scan_location: StrictStr = Field(description="Location to be scanned")
|
33
|
+
requesting_entity: Optional[StrictStr] = Field(default=None, description="Entity that requested the scan")
|
34
|
+
model_id: StrictStr = Field(description="Unique identifier for the model")
|
35
|
+
model_version_id: StrictStr = Field(description="unique identifier for the model version")
|
36
|
+
__properties: ClassVar[List[str]] = ["model_name", "model_version", "model_source", "requested_scan_location", "requesting_entity", "model_id", "model_version_id"]
|
37
|
+
|
38
|
+
model_config = ConfigDict(
|
39
|
+
populate_by_name=True,
|
40
|
+
validate_assignment=True,
|
41
|
+
protected_namespaces=(),
|
42
|
+
)
|
43
|
+
|
44
|
+
|
45
|
+
def to_str(self) -> str:
|
46
|
+
"""Returns the string representation of the model using alias"""
|
47
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
48
|
+
|
49
|
+
def to_json(self) -> str:
|
50
|
+
"""Returns the JSON representation of the model using alias"""
|
51
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
52
|
+
return json.dumps(self.to_dict())
|
53
|
+
|
54
|
+
@classmethod
|
55
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
56
|
+
"""Create an instance of ModelInventoryInfo from a JSON string"""
|
57
|
+
return cls.from_dict(json.loads(json_str))
|
58
|
+
|
59
|
+
def to_dict(self) -> Dict[str, Any]:
|
60
|
+
"""Return the dictionary representation of the model using alias.
|
61
|
+
|
62
|
+
This has the following differences from calling pydantic's
|
63
|
+
`self.model_dump(by_alias=True)`:
|
64
|
+
|
65
|
+
* `None` is only added to the output dict for nullable fields that
|
66
|
+
were set at model initialization. Other fields with value `None`
|
67
|
+
are ignored.
|
68
|
+
"""
|
69
|
+
excluded_fields: Set[str] = set([
|
70
|
+
])
|
71
|
+
|
72
|
+
_dict = self.model_dump(
|
73
|
+
by_alias=True,
|
74
|
+
exclude=excluded_fields,
|
75
|
+
exclude_none=True,
|
76
|
+
)
|
77
|
+
return _dict
|
78
|
+
|
79
|
+
@classmethod
|
80
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
81
|
+
"""Create an instance of ModelInventoryInfo from a dict"""
|
82
|
+
if obj is None:
|
83
|
+
return None
|
84
|
+
|
85
|
+
if not isinstance(obj, dict):
|
86
|
+
return cls.model_validate(obj)
|
87
|
+
|
88
|
+
_obj = cls.model_validate({
|
89
|
+
"model_name": obj.get("model_name"),
|
90
|
+
"model_version": obj.get("model_version"),
|
91
|
+
"model_source": obj.get("model_source"),
|
92
|
+
"requested_scan_location": obj.get("requested_scan_location"),
|
93
|
+
"requesting_entity": obj.get("requesting_entity"),
|
94
|
+
"model_id": obj.get("model_id"),
|
95
|
+
"model_version_id": obj.get("model_version_id")
|
96
|
+
})
|
97
|
+
return _obj
|
98
|
+
|
99
|
+
|
@@ -0,0 +1,87 @@
|
|
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 ModelScanApiV3ScanModelVersionIdPatch200Response(BaseModel):
|
26
|
+
"""
|
27
|
+
ModelScanApiV3ScanModelVersionIdPatch200Response
|
28
|
+
""" # noqa: E501
|
29
|
+
message: StrictStr = Field(description="Request to resource is successful")
|
30
|
+
__properties: ClassVar[List[str]] = ["message"]
|
31
|
+
|
32
|
+
model_config = ConfigDict(
|
33
|
+
populate_by_name=True,
|
34
|
+
validate_assignment=True,
|
35
|
+
protected_namespaces=(),
|
36
|
+
)
|
37
|
+
|
38
|
+
|
39
|
+
def to_str(self) -> str:
|
40
|
+
"""Returns the string representation of the model using alias"""
|
41
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
42
|
+
|
43
|
+
def to_json(self) -> str:
|
44
|
+
"""Returns the JSON representation of the model using alias"""
|
45
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
46
|
+
return json.dumps(self.to_dict())
|
47
|
+
|
48
|
+
@classmethod
|
49
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
50
|
+
"""Create an instance of ModelScanApiV3ScanModelVersionIdPatch200Response from a JSON string"""
|
51
|
+
return cls.from_dict(json.loads(json_str))
|
52
|
+
|
53
|
+
def to_dict(self) -> Dict[str, Any]:
|
54
|
+
"""Return the dictionary representation of the model using alias.
|
55
|
+
|
56
|
+
This has the following differences from calling pydantic's
|
57
|
+
`self.model_dump(by_alias=True)`:
|
58
|
+
|
59
|
+
* `None` is only added to the output dict for nullable fields that
|
60
|
+
were set at model initialization. Other fields with value `None`
|
61
|
+
are ignored.
|
62
|
+
"""
|
63
|
+
excluded_fields: Set[str] = set([
|
64
|
+
])
|
65
|
+
|
66
|
+
_dict = self.model_dump(
|
67
|
+
by_alias=True,
|
68
|
+
exclude=excluded_fields,
|
69
|
+
exclude_none=True,
|
70
|
+
)
|
71
|
+
return _dict
|
72
|
+
|
73
|
+
@classmethod
|
74
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
75
|
+
"""Create an instance of ModelScanApiV3ScanModelVersionIdPatch200Response from a dict"""
|
76
|
+
if obj is None:
|
77
|
+
return None
|
78
|
+
|
79
|
+
if not isinstance(obj, dict):
|
80
|
+
return cls.model_validate(obj)
|
81
|
+
|
82
|
+
_obj = cls.model_validate({
|
83
|
+
"message": obj.get("message")
|
84
|
+
})
|
85
|
+
return _obj
|
86
|
+
|
87
|
+
|
@@ -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 pydantic import BaseModel, ConfigDict, Field
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional, Union
|
22
|
+
from typing_extensions import Annotated
|
23
|
+
from hiddenlayer.sdk.rest.models.scan_report_v3 import ScanReportV3
|
24
|
+
from typing import Optional, Set
|
25
|
+
from typing_extensions import Self
|
26
|
+
|
27
|
+
class ModelScanApiV3ScanQuery200Response(BaseModel):
|
28
|
+
"""
|
29
|
+
ModelScanApiV3ScanQuery200Response
|
30
|
+
""" # noqa: E501
|
31
|
+
items: Optional[List[ScanReportV3]] = None
|
32
|
+
total: Union[Annotated[float, Field(strict=True, ge=0)], Annotated[int, Field(strict=True, ge=0)]] = Field(description="Total number of items available based on the query criteria.")
|
33
|
+
limit: Annotated[int, Field(le=100, strict=True, ge=1)] = Field(description="Maximum number of items to return")
|
34
|
+
offset: Annotated[int, Field(strict=True, ge=0)] = Field(description="Begin returning the results from this offset")
|
35
|
+
__properties: ClassVar[List[str]] = ["items", "total", "limit", "offset"]
|
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 ModelScanApiV3ScanQuery200Response 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 items (list)
|
77
|
+
_items = []
|
78
|
+
if self.items:
|
79
|
+
for _item in self.items:
|
80
|
+
if _item:
|
81
|
+
_items.append(_item.to_dict())
|
82
|
+
_dict['items'] = _items
|
83
|
+
return _dict
|
84
|
+
|
85
|
+
@classmethod
|
86
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
87
|
+
"""Create an instance of ModelScanApiV3ScanQuery200Response 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
|
+
"items": [ScanReportV3.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None,
|
96
|
+
"total": obj.get("total"),
|
97
|
+
"limit": obj.get("limit") if obj.get("limit") is not None else 25,
|
98
|
+
"offset": obj.get("offset") if obj.get("offset") is not None else 0
|
99
|
+
})
|
100
|
+
return _obj
|
101
|
+
|
102
|
+
|
@@ -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, Optional
|
22
|
+
from hiddenlayer.sdk.rest.models.property_bag import PropertyBag
|
23
|
+
from typing import Optional, Set
|
24
|
+
from typing_extensions import Self
|
25
|
+
|
26
|
+
class MultiformatMessageString(BaseModel):
|
27
|
+
"""
|
28
|
+
A message string or message format string rendered in multiple formats.
|
29
|
+
""" # noqa: E501
|
30
|
+
text: StrictStr = Field(description="A plain text message string or format string.")
|
31
|
+
markdown: Optional[StrictStr] = Field(default=None, description="A Markdown message string or format string.")
|
32
|
+
properties: Optional[PropertyBag] = None
|
33
|
+
__properties: ClassVar[List[str]] = ["text", "markdown", "properties"]
|
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 MultiformatMessageString 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 properties
|
75
|
+
if self.properties:
|
76
|
+
_dict['properties'] = self.properties.to_dict()
|
77
|
+
return _dict
|
78
|
+
|
79
|
+
@classmethod
|
80
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
81
|
+
"""Create an instance of MultiformatMessageString from a dict"""
|
82
|
+
if obj is None:
|
83
|
+
return None
|
84
|
+
|
85
|
+
if not isinstance(obj, dict):
|
86
|
+
return cls.model_validate(obj)
|
87
|
+
|
88
|
+
_obj = cls.model_validate({
|
89
|
+
"text": obj.get("text"),
|
90
|
+
"markdown": obj.get("markdown"),
|
91
|
+
"properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
|
92
|
+
})
|
93
|
+
return _obj
|
94
|
+
|
95
|
+
|
@@ -0,0 +1,122 @@
|
|
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 typing_extensions import Annotated
|
23
|
+
from hiddenlayer.sdk.rest.models.location import Location
|
24
|
+
from hiddenlayer.sdk.rest.models.message import Message
|
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 Node(BaseModel):
|
30
|
+
"""
|
31
|
+
Represents a node in a graph.
|
32
|
+
""" # noqa: E501
|
33
|
+
id: StrictStr = Field(description="A string that uniquely identifies the node within its graph.")
|
34
|
+
label: Optional[Message] = None
|
35
|
+
location: Optional[Location] = None
|
36
|
+
children: Optional[Annotated[List[Node], Field(min_length=0)]] = Field(default=None, description="Array of child nodes.")
|
37
|
+
properties: Optional[PropertyBag] = None
|
38
|
+
__properties: ClassVar[List[str]] = ["id", "label", "location", "children", "properties"]
|
39
|
+
|
40
|
+
model_config = ConfigDict(
|
41
|
+
populate_by_name=True,
|
42
|
+
validate_assignment=True,
|
43
|
+
protected_namespaces=(),
|
44
|
+
)
|
45
|
+
|
46
|
+
|
47
|
+
def to_str(self) -> str:
|
48
|
+
"""Returns the string representation of the model using alias"""
|
49
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
50
|
+
|
51
|
+
def to_json(self) -> str:
|
52
|
+
"""Returns the JSON representation of the model using alias"""
|
53
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
54
|
+
return json.dumps(self.to_dict())
|
55
|
+
|
56
|
+
@classmethod
|
57
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
58
|
+
"""Create an instance of Node from a JSON string"""
|
59
|
+
return cls.from_dict(json.loads(json_str))
|
60
|
+
|
61
|
+
def to_dict(self) -> Dict[str, Any]:
|
62
|
+
"""Return the dictionary representation of the model using alias.
|
63
|
+
|
64
|
+
This has the following differences from calling pydantic's
|
65
|
+
`self.model_dump(by_alias=True)`:
|
66
|
+
|
67
|
+
* `None` is only added to the output dict for nullable fields that
|
68
|
+
were set at model initialization. Other fields with value `None`
|
69
|
+
are ignored.
|
70
|
+
"""
|
71
|
+
excluded_fields: Set[str] = set([
|
72
|
+
])
|
73
|
+
|
74
|
+
_dict = self.model_dump(
|
75
|
+
by_alias=True,
|
76
|
+
exclude=excluded_fields,
|
77
|
+
exclude_none=True,
|
78
|
+
)
|
79
|
+
# override the default output from pydantic by calling `to_dict()` of label
|
80
|
+
if self.label:
|
81
|
+
_dict['label'] = self.label.to_dict()
|
82
|
+
# override the default output from pydantic by calling `to_dict()` of location
|
83
|
+
if self.location:
|
84
|
+
_dict['location'] = self.location.to_dict()
|
85
|
+
# override the default output from pydantic by calling `to_dict()` of each item in children (list)
|
86
|
+
_items = []
|
87
|
+
if self.children:
|
88
|
+
for _item in self.children:
|
89
|
+
if _item:
|
90
|
+
_items.append(_item.to_dict())
|
91
|
+
_dict['children'] = _items
|
92
|
+
# override the default output from pydantic by calling `to_dict()` of properties
|
93
|
+
if self.properties:
|
94
|
+
_dict['properties'] = self.properties.to_dict()
|
95
|
+
# set to None if label (nullable) is None
|
96
|
+
# and model_fields_set contains the field
|
97
|
+
if self.label is None and "label" in self.model_fields_set:
|
98
|
+
_dict['label'] = None
|
99
|
+
|
100
|
+
return _dict
|
101
|
+
|
102
|
+
@classmethod
|
103
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
104
|
+
"""Create an instance of Node from a dict"""
|
105
|
+
if obj is None:
|
106
|
+
return None
|
107
|
+
|
108
|
+
if not isinstance(obj, dict):
|
109
|
+
return cls.model_validate(obj)
|
110
|
+
|
111
|
+
_obj = cls.model_validate({
|
112
|
+
"id": obj.get("id"),
|
113
|
+
"label": Message.from_dict(obj["label"]) if obj.get("label") is not None else None,
|
114
|
+
"location": Location.from_dict(obj["location"]) if obj.get("location") is not None else None,
|
115
|
+
"children": [Node.from_dict(_item) for _item in obj["children"]] if obj.get("children") is not None else None,
|
116
|
+
"properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
|
117
|
+
})
|
118
|
+
return _obj
|
119
|
+
|
120
|
+
# TODO: Rewrite to not use raise_errors
|
121
|
+
Node.model_rebuild(raise_errors=False)
|
122
|
+
|
@@ -0,0 +1,157 @@
|
|
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, StrictInt, StrictStr, field_validator
|
22
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
23
|
+
from typing_extensions import Annotated
|
24
|
+
from hiddenlayer.sdk.rest.models.exception import Exception
|
25
|
+
from hiddenlayer.sdk.rest.models.location import Location
|
26
|
+
from hiddenlayer.sdk.rest.models.message import Message
|
27
|
+
from hiddenlayer.sdk.rest.models.property_bag import PropertyBag
|
28
|
+
from hiddenlayer.sdk.rest.models.reporting_descriptor_reference import ReportingDescriptorReference
|
29
|
+
from typing import Optional, Set
|
30
|
+
from typing_extensions import Self
|
31
|
+
|
32
|
+
class Notification(BaseModel):
|
33
|
+
"""
|
34
|
+
Describes a condition relevant to the tool itself, as opposed to being relevant to a target being analyzed by the tool.
|
35
|
+
""" # noqa: E501
|
36
|
+
locations: Optional[Annotated[List[Location], Field(min_length=0)]] = Field(default=None, description="The locations relevant to this notification.")
|
37
|
+
message: Optional[Message]
|
38
|
+
level: Optional[StrictStr] = Field(default='warning', description="A value specifying the severity level of the notification.")
|
39
|
+
thread_id: Optional[StrictInt] = Field(default=None, description="The thread identifier of the code that generated the notification.", alias="threadId")
|
40
|
+
time_utc: Optional[datetime] = Field(default=None, description="The Coordinated Universal Time (UTC) date and time at which the analysis tool generated the notification.", alias="timeUtc")
|
41
|
+
exception: Optional[Exception] = None
|
42
|
+
descriptor: Optional[ReportingDescriptorReference] = None
|
43
|
+
associated_rule: Optional[ReportingDescriptorReference] = Field(default=None, alias="associatedRule")
|
44
|
+
properties: Optional[PropertyBag] = None
|
45
|
+
__properties: ClassVar[List[str]] = ["locations", "message", "level", "threadId", "timeUtc", "exception", "descriptor", "associatedRule", "properties"]
|
46
|
+
|
47
|
+
@field_validator('level')
|
48
|
+
def level_validate_enum(cls, value):
|
49
|
+
"""Validates the enum"""
|
50
|
+
if value is None:
|
51
|
+
return value
|
52
|
+
|
53
|
+
if value not in set(['none', 'note', 'warning', 'error']):
|
54
|
+
raise ValueError("must be one of enum values ('none', 'note', 'warning', 'error')")
|
55
|
+
return value
|
56
|
+
|
57
|
+
model_config = ConfigDict(
|
58
|
+
populate_by_name=True,
|
59
|
+
validate_assignment=True,
|
60
|
+
protected_namespaces=(),
|
61
|
+
)
|
62
|
+
|
63
|
+
|
64
|
+
def to_str(self) -> str:
|
65
|
+
"""Returns the string representation of the model using alias"""
|
66
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
67
|
+
|
68
|
+
def to_json(self) -> str:
|
69
|
+
"""Returns the JSON representation of the model using alias"""
|
70
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
71
|
+
return json.dumps(self.to_dict())
|
72
|
+
|
73
|
+
@classmethod
|
74
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
75
|
+
"""Create an instance of Notification from a JSON string"""
|
76
|
+
return cls.from_dict(json.loads(json_str))
|
77
|
+
|
78
|
+
def to_dict(self) -> Dict[str, Any]:
|
79
|
+
"""Return the dictionary representation of the model using alias.
|
80
|
+
|
81
|
+
This has the following differences from calling pydantic's
|
82
|
+
`self.model_dump(by_alias=True)`:
|
83
|
+
|
84
|
+
* `None` is only added to the output dict for nullable fields that
|
85
|
+
were set at model initialization. Other fields with value `None`
|
86
|
+
are ignored.
|
87
|
+
"""
|
88
|
+
excluded_fields: Set[str] = set([
|
89
|
+
])
|
90
|
+
|
91
|
+
_dict = self.model_dump(
|
92
|
+
by_alias=True,
|
93
|
+
exclude=excluded_fields,
|
94
|
+
exclude_none=True,
|
95
|
+
)
|
96
|
+
# override the default output from pydantic by calling `to_dict()` of each item in locations (list)
|
97
|
+
_items = []
|
98
|
+
if self.locations:
|
99
|
+
for _item in self.locations:
|
100
|
+
if _item:
|
101
|
+
_items.append(_item.to_dict())
|
102
|
+
_dict['locations'] = _items
|
103
|
+
# override the default output from pydantic by calling `to_dict()` of message
|
104
|
+
if self.message:
|
105
|
+
_dict['message'] = self.message.to_dict()
|
106
|
+
# override the default output from pydantic by calling `to_dict()` of exception
|
107
|
+
if self.exception:
|
108
|
+
_dict['exception'] = self.exception.to_dict()
|
109
|
+
# override the default output from pydantic by calling `to_dict()` of descriptor
|
110
|
+
if self.descriptor:
|
111
|
+
_dict['descriptor'] = self.descriptor.to_dict()
|
112
|
+
# override the default output from pydantic by calling `to_dict()` of associated_rule
|
113
|
+
if self.associated_rule:
|
114
|
+
_dict['associatedRule'] = self.associated_rule.to_dict()
|
115
|
+
# override the default output from pydantic by calling `to_dict()` of properties
|
116
|
+
if self.properties:
|
117
|
+
_dict['properties'] = self.properties.to_dict()
|
118
|
+
# set to None if message (nullable) is None
|
119
|
+
# and model_fields_set contains the field
|
120
|
+
if self.message is None and "message" in self.model_fields_set:
|
121
|
+
_dict['message'] = None
|
122
|
+
|
123
|
+
# set to None if descriptor (nullable) is None
|
124
|
+
# and model_fields_set contains the field
|
125
|
+
if self.descriptor is None and "descriptor" in self.model_fields_set:
|
126
|
+
_dict['descriptor'] = None
|
127
|
+
|
128
|
+
# set to None if associated_rule (nullable) is None
|
129
|
+
# and model_fields_set contains the field
|
130
|
+
if self.associated_rule is None and "associated_rule" in self.model_fields_set:
|
131
|
+
_dict['associatedRule'] = None
|
132
|
+
|
133
|
+
return _dict
|
134
|
+
|
135
|
+
@classmethod
|
136
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
137
|
+
"""Create an instance of Notification from a dict"""
|
138
|
+
if obj is None:
|
139
|
+
return None
|
140
|
+
|
141
|
+
if not isinstance(obj, dict):
|
142
|
+
return cls.model_validate(obj)
|
143
|
+
|
144
|
+
_obj = cls.model_validate({
|
145
|
+
"locations": [Location.from_dict(_item) for _item in obj["locations"]] if obj.get("locations") is not None else None,
|
146
|
+
"message": Message.from_dict(obj["message"]) if obj.get("message") is not None else None,
|
147
|
+
"level": obj.get("level") if obj.get("level") is not None else 'warning',
|
148
|
+
"threadId": obj.get("threadId"),
|
149
|
+
"timeUtc": obj.get("timeUtc"),
|
150
|
+
"exception": Exception.from_dict(obj["exception"]) if obj.get("exception") is not None else None,
|
151
|
+
"descriptor": ReportingDescriptorReference.from_dict(obj["descriptor"]) if obj.get("descriptor") is not None else None,
|
152
|
+
"associatedRule": ReportingDescriptorReference.from_dict(obj["associatedRule"]) if obj.get("associatedRule") is not None else None,
|
153
|
+
"properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
|
154
|
+
})
|
155
|
+
return _obj
|
156
|
+
|
157
|
+
|