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.
- 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.1.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.1.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.1.dist-info/RECORD +0 -43
- {hiddenlayer_sdk-0.1.1.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/LICENSE +0 -0
- {hiddenlayer_sdk-0.1.1.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,156 @@
|
|
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 ScanDetectionV3(BaseModel):
|
29
|
+
"""
|
30
|
+
ScanDetectionV3
|
31
|
+
""" # noqa: E501
|
32
|
+
description: StrictStr = Field(description="detection description")
|
33
|
+
risk: StrictStr = Field(description="detection risk")
|
34
|
+
severity: StrictStr = Field(description="detection severity")
|
35
|
+
detection_id: StrictStr = Field(description="unique identifier for the detection")
|
36
|
+
impact: Optional[StrictStr] = Field(default=None, description="detection impact")
|
37
|
+
likelihood: Optional[StrictStr] = Field(default=None, description="detection likelihood")
|
38
|
+
rule_details: Optional[List[RuleDetailsInner]] = None
|
39
|
+
rule_id: StrictStr = Field(description="unique identifier for the rule that sourced the detection")
|
40
|
+
category: StrictStr = Field(description="Vulnerability category for the detection")
|
41
|
+
mitre_atlas: List[MITREAtlasInner]
|
42
|
+
owasp: List[Annotated[str, Field(strict=True)]]
|
43
|
+
cve: Optional[List[Annotated[str, Field(strict=True)]]] = None
|
44
|
+
cwe: Optional[Annotated[str, Field(strict=True)]] = None
|
45
|
+
cwe_href: Optional[StrictStr] = Field(default=None, description="CWE URL for the detection")
|
46
|
+
technical_blog_href: Optional[StrictStr] = Field(default=None, description="Hiddenlayer Technical Blog URL for the detection")
|
47
|
+
__properties: ClassVar[List[str]] = ["description", "risk", "severity", "detection_id", "impact", "likelihood", "rule_details", "rule_id", "category", "mitre_atlas", "owasp", "cve", "cwe", "cwe_href", "technical_blog_href"]
|
48
|
+
|
49
|
+
@field_validator('risk')
|
50
|
+
def risk_validate_enum(cls, value):
|
51
|
+
"""Validates the enum"""
|
52
|
+
if value not in set(['MALICIOUS', 'SUSPICIOUS', 'BENIGN']):
|
53
|
+
raise ValueError("must be one of enum values ('MALICIOUS', 'SUSPICIOUS', 'BENIGN')")
|
54
|
+
return value
|
55
|
+
|
56
|
+
@field_validator('severity')
|
57
|
+
def severity_validate_enum(cls, value):
|
58
|
+
"""Validates the enum"""
|
59
|
+
if value not in set(['low', 'medium', 'high', 'critical']):
|
60
|
+
raise ValueError("must be one of enum values ('low', 'medium', 'high', 'critical')")
|
61
|
+
return value
|
62
|
+
|
63
|
+
@field_validator('cwe')
|
64
|
+
def cwe_validate_regular_expression(cls, value):
|
65
|
+
"""Validates the regular expression"""
|
66
|
+
if value is None:
|
67
|
+
return value
|
68
|
+
|
69
|
+
if not re.match(r"^CWE-\d{1,4}.*$", value):
|
70
|
+
raise ValueError(r"must validate the regular expression /^CWE-\d{1,4}.*$/")
|
71
|
+
return value
|
72
|
+
|
73
|
+
model_config = ConfigDict(
|
74
|
+
populate_by_name=True,
|
75
|
+
validate_assignment=True,
|
76
|
+
protected_namespaces=(),
|
77
|
+
)
|
78
|
+
|
79
|
+
|
80
|
+
def to_str(self) -> str:
|
81
|
+
"""Returns the string representation of the model using alias"""
|
82
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
83
|
+
|
84
|
+
def to_json(self) -> str:
|
85
|
+
"""Returns the JSON representation of the model using alias"""
|
86
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
87
|
+
return json.dumps(self.to_dict())
|
88
|
+
|
89
|
+
@classmethod
|
90
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
91
|
+
"""Create an instance of ScanDetectionV3 from a JSON string"""
|
92
|
+
return cls.from_dict(json.loads(json_str))
|
93
|
+
|
94
|
+
def to_dict(self) -> Dict[str, Any]:
|
95
|
+
"""Return the dictionary representation of the model using alias.
|
96
|
+
|
97
|
+
This has the following differences from calling pydantic's
|
98
|
+
`self.model_dump(by_alias=True)`:
|
99
|
+
|
100
|
+
* `None` is only added to the output dict for nullable fields that
|
101
|
+
were set at model initialization. Other fields with value `None`
|
102
|
+
are ignored.
|
103
|
+
"""
|
104
|
+
excluded_fields: Set[str] = set([
|
105
|
+
])
|
106
|
+
|
107
|
+
_dict = self.model_dump(
|
108
|
+
by_alias=True,
|
109
|
+
exclude=excluded_fields,
|
110
|
+
exclude_none=True,
|
111
|
+
)
|
112
|
+
# override the default output from pydantic by calling `to_dict()` of each item in rule_details (list)
|
113
|
+
_items = []
|
114
|
+
if self.rule_details:
|
115
|
+
for _item in self.rule_details:
|
116
|
+
if _item:
|
117
|
+
_items.append(_item.to_dict())
|
118
|
+
_dict['rule_details'] = _items
|
119
|
+
# override the default output from pydantic by calling `to_dict()` of each item in mitre_atlas (list)
|
120
|
+
_items = []
|
121
|
+
if self.mitre_atlas:
|
122
|
+
for _item in self.mitre_atlas:
|
123
|
+
if _item:
|
124
|
+
_items.append(_item.to_dict())
|
125
|
+
_dict['mitre_atlas'] = _items
|
126
|
+
return _dict
|
127
|
+
|
128
|
+
@classmethod
|
129
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
130
|
+
"""Create an instance of ScanDetectionV3 from a dict"""
|
131
|
+
if obj is None:
|
132
|
+
return None
|
133
|
+
|
134
|
+
if not isinstance(obj, dict):
|
135
|
+
return cls.model_validate(obj)
|
136
|
+
|
137
|
+
_obj = cls.model_validate({
|
138
|
+
"description": obj.get("description"),
|
139
|
+
"risk": obj.get("risk"),
|
140
|
+
"severity": obj.get("severity"),
|
141
|
+
"detection_id": obj.get("detection_id"),
|
142
|
+
"impact": obj.get("impact"),
|
143
|
+
"likelihood": obj.get("likelihood"),
|
144
|
+
"rule_details": [RuleDetailsInner.from_dict(_item) for _item in obj["rule_details"]] if obj.get("rule_details") is not None else None,
|
145
|
+
"rule_id": obj.get("rule_id"),
|
146
|
+
"category": obj.get("category"),
|
147
|
+
"mitre_atlas": [MITREAtlasInner.from_dict(_item) for _item in obj["mitre_atlas"]] if obj.get("mitre_atlas") is not None else None,
|
148
|
+
"owasp": obj.get("owasp"),
|
149
|
+
"cve": obj.get("cve"),
|
150
|
+
"cwe": obj.get("cwe"),
|
151
|
+
"cwe_href": obj.get("cwe_href"),
|
152
|
+
"technical_blog_href": obj.get("technical_blog_href")
|
153
|
+
})
|
154
|
+
return _obj
|
155
|
+
|
156
|
+
|
@@ -0,0 +1,129 @@
|
|
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 hiddenlayer.sdk.rest.models.model_inventory_info import ModelInventoryInfo
|
24
|
+
from typing import Optional, Set
|
25
|
+
from typing_extensions import Self
|
26
|
+
|
27
|
+
class ScanHeaderV3(BaseModel):
|
28
|
+
"""
|
29
|
+
ScanHeaderV3
|
30
|
+
""" # noqa: E501
|
31
|
+
file_count: StrictInt = Field(description="number of files scanned")
|
32
|
+
files_with_detections_count: StrictInt = Field(description="number of files with detections found")
|
33
|
+
detection_count: StrictInt = Field(description="number of detections found")
|
34
|
+
detection_categories: Optional[List[StrictStr]] = Field(default=None, description="list of detection categories found")
|
35
|
+
inventory: ModelInventoryInfo
|
36
|
+
version: StrictStr = Field(description="scanner version")
|
37
|
+
scan_id: StrictStr = Field(description="unique identifier for the scan")
|
38
|
+
start_time: datetime = Field(description="time the scan started")
|
39
|
+
end_time: Optional[datetime] = Field(default=None, description="time the scan ended")
|
40
|
+
status: StrictStr = Field(description="status of the scan")
|
41
|
+
severity: Optional[StrictStr] = Field(default=None, description="detection severity")
|
42
|
+
__properties: ClassVar[List[str]] = ["file_count", "files_with_detections_count", "detection_count", "detection_categories", "inventory", "version", "scan_id", "start_time", "end_time", "status", "severity"]
|
43
|
+
|
44
|
+
@field_validator('status')
|
45
|
+
def status_validate_enum(cls, value):
|
46
|
+
"""Validates the enum"""
|
47
|
+
if value not in set(['pending', 'running', 'done', 'failed', 'canceled']):
|
48
|
+
raise ValueError("must be one of enum values ('pending', 'running', 'done', 'failed', 'canceled')")
|
49
|
+
return value
|
50
|
+
|
51
|
+
@field_validator('severity')
|
52
|
+
def severity_validate_enum(cls, value):
|
53
|
+
"""Validates the enum"""
|
54
|
+
if value is None:
|
55
|
+
return value
|
56
|
+
|
57
|
+
if value not in set(['low', 'medium', 'high', 'critical', 'safe', 'unknown']):
|
58
|
+
raise ValueError("must be one of enum values ('low', 'medium', 'high', 'critical', 'safe', 'unknown')")
|
59
|
+
return value
|
60
|
+
|
61
|
+
model_config = ConfigDict(
|
62
|
+
populate_by_name=True,
|
63
|
+
validate_assignment=True,
|
64
|
+
protected_namespaces=(),
|
65
|
+
)
|
66
|
+
|
67
|
+
|
68
|
+
def to_str(self) -> str:
|
69
|
+
"""Returns the string representation of the model using alias"""
|
70
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
71
|
+
|
72
|
+
def to_json(self) -> str:
|
73
|
+
"""Returns the JSON representation of the model using alias"""
|
74
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
75
|
+
return json.dumps(self.to_dict())
|
76
|
+
|
77
|
+
@classmethod
|
78
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
79
|
+
"""Create an instance of ScanHeaderV3 from a JSON string"""
|
80
|
+
return cls.from_dict(json.loads(json_str))
|
81
|
+
|
82
|
+
def to_dict(self) -> Dict[str, Any]:
|
83
|
+
"""Return the dictionary representation of the model using alias.
|
84
|
+
|
85
|
+
This has the following differences from calling pydantic's
|
86
|
+
`self.model_dump(by_alias=True)`:
|
87
|
+
|
88
|
+
* `None` is only added to the output dict for nullable fields that
|
89
|
+
were set at model initialization. Other fields with value `None`
|
90
|
+
are ignored.
|
91
|
+
"""
|
92
|
+
excluded_fields: Set[str] = set([
|
93
|
+
])
|
94
|
+
|
95
|
+
_dict = self.model_dump(
|
96
|
+
by_alias=True,
|
97
|
+
exclude=excluded_fields,
|
98
|
+
exclude_none=True,
|
99
|
+
)
|
100
|
+
# override the default output from pydantic by calling `to_dict()` of inventory
|
101
|
+
if self.inventory:
|
102
|
+
_dict['inventory'] = self.inventory.to_dict()
|
103
|
+
return _dict
|
104
|
+
|
105
|
+
@classmethod
|
106
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
107
|
+
"""Create an instance of ScanHeaderV3 from a dict"""
|
108
|
+
if obj is None:
|
109
|
+
return None
|
110
|
+
|
111
|
+
if not isinstance(obj, dict):
|
112
|
+
return cls.model_validate(obj)
|
113
|
+
|
114
|
+
_obj = cls.model_validate({
|
115
|
+
"file_count": obj.get("file_count"),
|
116
|
+
"files_with_detections_count": obj.get("files_with_detections_count"),
|
117
|
+
"detection_count": obj.get("detection_count"),
|
118
|
+
"detection_categories": obj.get("detection_categories"),
|
119
|
+
"inventory": ModelInventoryInfo.from_dict(obj["inventory"]) if obj.get("inventory") is not None else None,
|
120
|
+
"version": obj.get("version"),
|
121
|
+
"scan_id": obj.get("scan_id"),
|
122
|
+
"start_time": obj.get("start_time"),
|
123
|
+
"end_time": obj.get("end_time"),
|
124
|
+
"status": obj.get("status"),
|
125
|
+
"severity": obj.get("severity")
|
126
|
+
})
|
127
|
+
return _obj
|
128
|
+
|
129
|
+
|
@@ -0,0 +1,109 @@
|
|
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 hiddenlayer.sdk.rest.models.scan_job_inventory import ScanJobInventory
|
23
|
+
from typing import Optional, Set
|
24
|
+
from typing_extensions import Self
|
25
|
+
|
26
|
+
class ScanJob(BaseModel):
|
27
|
+
"""
|
28
|
+
ScanJob
|
29
|
+
""" # noqa: E501
|
30
|
+
scan_id: Optional[StrictStr] = Field(default=None, description="unique identifier for the scan")
|
31
|
+
status: Optional[StrictStr] = Field(default=None, description="Status of the scan")
|
32
|
+
inventory: Optional[ScanJobInventory] = None
|
33
|
+
__properties: ClassVar[List[str]] = ["scan_id", "status", "inventory"]
|
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(['pending', 'running', 'done', 'failed', 'canceled']):
|
42
|
+
raise ValueError("must be one of enum values ('pending', 'running', 'done', 'failed', 'canceled')")
|
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 ScanJob 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
|
+
* OpenAPI `readOnly` fields are excluded.
|
76
|
+
* OpenAPI `readOnly` fields are excluded.
|
77
|
+
"""
|
78
|
+
excluded_fields: Set[str] = set([
|
79
|
+
"scan_id",
|
80
|
+
"status",
|
81
|
+
])
|
82
|
+
|
83
|
+
_dict = self.model_dump(
|
84
|
+
by_alias=True,
|
85
|
+
exclude=excluded_fields,
|
86
|
+
exclude_none=True,
|
87
|
+
)
|
88
|
+
# override the default output from pydantic by calling `to_dict()` of inventory
|
89
|
+
if self.inventory:
|
90
|
+
_dict['inventory'] = self.inventory.to_dict()
|
91
|
+
return _dict
|
92
|
+
|
93
|
+
@classmethod
|
94
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
95
|
+
"""Create an instance of ScanJob from a dict"""
|
96
|
+
if obj is None:
|
97
|
+
return None
|
98
|
+
|
99
|
+
if not isinstance(obj, dict):
|
100
|
+
return cls.model_validate(obj)
|
101
|
+
|
102
|
+
_obj = cls.model_validate({
|
103
|
+
"scan_id": obj.get("scan_id"),
|
104
|
+
"status": obj.get("status"),
|
105
|
+
"inventory": ScanJobInventory.from_dict(obj["inventory"]) if obj.get("inventory") is not None else None
|
106
|
+
})
|
107
|
+
return _obj
|
108
|
+
|
109
|
+
|
@@ -0,0 +1,137 @@
|
|
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 json
|
17
|
+
import pprint
|
18
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
|
19
|
+
from typing import Any, List, Optional
|
20
|
+
from hiddenlayer.sdk.rest.models.scan_model_details_v3 import ScanModelDetailsV3
|
21
|
+
from hiddenlayer.sdk.rest.models.scan_model_ids_v3 import ScanModelIdsV3
|
22
|
+
from pydantic import StrictStr, Field
|
23
|
+
from typing import Union, List, Set, Optional, Dict
|
24
|
+
from typing_extensions import Literal, Self
|
25
|
+
|
26
|
+
SCANJOBINVENTORY_ONE_OF_SCHEMAS = ["ScanModelDetailsV3", "ScanModelIdsV3"]
|
27
|
+
|
28
|
+
class ScanJobInventory(BaseModel):
|
29
|
+
"""
|
30
|
+
ScanJobInventory
|
31
|
+
"""
|
32
|
+
# data type: ScanModelDetailsV3
|
33
|
+
oneof_schema_1_validator: Optional[ScanModelDetailsV3] = None
|
34
|
+
# data type: ScanModelIdsV3
|
35
|
+
oneof_schema_2_validator: Optional[ScanModelIdsV3] = None
|
36
|
+
actual_instance: Optional[Union[ScanModelDetailsV3, ScanModelIdsV3]] = None
|
37
|
+
one_of_schemas: Set[str] = { "ScanModelDetailsV3", "ScanModelIdsV3" }
|
38
|
+
|
39
|
+
model_config = ConfigDict(
|
40
|
+
validate_assignment=True,
|
41
|
+
protected_namespaces=(),
|
42
|
+
)
|
43
|
+
|
44
|
+
|
45
|
+
def __init__(self, *args, **kwargs) -> None:
|
46
|
+
if args:
|
47
|
+
if len(args) > 1:
|
48
|
+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
|
49
|
+
if kwargs:
|
50
|
+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
|
51
|
+
super().__init__(actual_instance=args[0])
|
52
|
+
else:
|
53
|
+
super().__init__(**kwargs)
|
54
|
+
|
55
|
+
@field_validator('actual_instance')
|
56
|
+
def actual_instance_must_validate_oneof(cls, v):
|
57
|
+
instance = ScanJobInventory.model_construct()
|
58
|
+
error_messages = []
|
59
|
+
match = 0
|
60
|
+
# validate data type: ScanModelDetailsV3
|
61
|
+
if not isinstance(v, ScanModelDetailsV3):
|
62
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `ScanModelDetailsV3`")
|
63
|
+
else:
|
64
|
+
match += 1
|
65
|
+
# validate data type: ScanModelIdsV3
|
66
|
+
if not isinstance(v, ScanModelIdsV3):
|
67
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `ScanModelIdsV3`")
|
68
|
+
else:
|
69
|
+
match += 1
|
70
|
+
if match > 1:
|
71
|
+
# more than 1 match
|
72
|
+
raise ValueError("Multiple matches found when setting `actual_instance` in ScanJobInventory with oneOf schemas: ScanModelDetailsV3, ScanModelIdsV3. Details: " + ", ".join(error_messages))
|
73
|
+
elif match == 0:
|
74
|
+
# no match
|
75
|
+
raise ValueError("No match found when setting `actual_instance` in ScanJobInventory with oneOf schemas: ScanModelDetailsV3, ScanModelIdsV3. Details: " + ", ".join(error_messages))
|
76
|
+
else:
|
77
|
+
return v
|
78
|
+
|
79
|
+
@classmethod
|
80
|
+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
|
81
|
+
return cls.from_json(json.dumps(obj))
|
82
|
+
|
83
|
+
@classmethod
|
84
|
+
def from_json(cls, json_str: str) -> Self:
|
85
|
+
"""Returns the object represented by the json string"""
|
86
|
+
instance = cls.model_construct()
|
87
|
+
error_messages = []
|
88
|
+
match = 0
|
89
|
+
|
90
|
+
# deserialize data into ScanModelDetailsV3
|
91
|
+
try:
|
92
|
+
instance.actual_instance = ScanModelDetailsV3.from_json(json_str)
|
93
|
+
match += 1
|
94
|
+
except (ValidationError, ValueError) as e:
|
95
|
+
error_messages.append(str(e))
|
96
|
+
# deserialize data into ScanModelIdsV3
|
97
|
+
try:
|
98
|
+
instance.actual_instance = ScanModelIdsV3.from_json(json_str)
|
99
|
+
match += 1
|
100
|
+
except (ValidationError, ValueError) as e:
|
101
|
+
error_messages.append(str(e))
|
102
|
+
|
103
|
+
if match > 1:
|
104
|
+
# more than 1 match
|
105
|
+
raise ValueError("Multiple matches found when deserializing the JSON string into ScanJobInventory with oneOf schemas: ScanModelDetailsV3, ScanModelIdsV3. Details: " + ", ".join(error_messages))
|
106
|
+
elif match == 0:
|
107
|
+
# no match
|
108
|
+
raise ValueError("No match found when deserializing the JSON string into ScanJobInventory with oneOf schemas: ScanModelDetailsV3, ScanModelIdsV3. Details: " + ", ".join(error_messages))
|
109
|
+
else:
|
110
|
+
return instance
|
111
|
+
|
112
|
+
def to_json(self) -> str:
|
113
|
+
"""Returns the JSON representation of the actual instance"""
|
114
|
+
if self.actual_instance is None:
|
115
|
+
return "null"
|
116
|
+
|
117
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
118
|
+
return self.actual_instance.to_json()
|
119
|
+
else:
|
120
|
+
return json.dumps(self.actual_instance)
|
121
|
+
|
122
|
+
def to_dict(self) -> Optional[Union[Dict[str, Any], ScanModelDetailsV3, ScanModelIdsV3]]:
|
123
|
+
"""Returns the dict representation of the actual instance"""
|
124
|
+
if self.actual_instance is None:
|
125
|
+
return None
|
126
|
+
|
127
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
128
|
+
return self.actual_instance.to_dict()
|
129
|
+
else:
|
130
|
+
# primitive type
|
131
|
+
return self.actual_instance
|
132
|
+
|
133
|
+
def to_str(self) -> str:
|
134
|
+
"""Returns the string representation of the actual instance"""
|
135
|
+
return pprint.pformat(self.model_dump())
|
136
|
+
|
137
|
+
|
@@ -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 typing import Optional, Set
|
23
|
+
from typing_extensions import Self
|
24
|
+
|
25
|
+
class ScanModelDetailsV3(BaseModel):
|
26
|
+
"""
|
27
|
+
ScanModelDetailsV3
|
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
|
+
__properties: ClassVar[List[str]] = ["model_name", "model_version", "model_source", "requested_scan_location", "requesting_entity"]
|
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 ScanModelDetailsV3 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 ScanModelDetailsV3 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
|
+
"model_name": obj.get("model_name"),
|
88
|
+
"model_version": obj.get("model_version"),
|
89
|
+
"model_source": obj.get("model_source"),
|
90
|
+
"requested_scan_location": obj.get("requested_scan_location"),
|
91
|
+
"requesting_entity": obj.get("requesting_entity")
|
92
|
+
})
|
93
|
+
return _obj
|
94
|
+
|
95
|
+
|