hiddenlayer-sdk 0.1.2__py3-none-any.whl → 1.1.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. hiddenlayer/sdk/constants.py +1 -0
  2. hiddenlayer/sdk/models.py +45 -8
  3. hiddenlayer/sdk/rest/__init__.py +80 -3
  4. hiddenlayer/sdk/rest/api/__init__.py +3 -0
  5. hiddenlayer/sdk/rest/api/aidr_predictive_api.py +1 -1
  6. hiddenlayer/sdk/rest/api/health_api.py +272 -0
  7. hiddenlayer/sdk/rest/api/model_scan_api.py +1 -1
  8. hiddenlayer/sdk/rest/api/model_supply_chain_api.py +2927 -0
  9. hiddenlayer/sdk/rest/api/readiness_api.py +272 -0
  10. hiddenlayer/sdk/rest/api/sensor_api.py +354 -37
  11. hiddenlayer/sdk/rest/api_client.py +1 -1
  12. hiddenlayer/sdk/rest/configuration.py +4 -4
  13. hiddenlayer/sdk/rest/exceptions.py +1 -1
  14. hiddenlayer/sdk/rest/models/__init__.py +77 -3
  15. hiddenlayer/sdk/rest/models/address.py +110 -0
  16. hiddenlayer/sdk/rest/models/artifact.py +155 -0
  17. hiddenlayer/sdk/rest/models/artifact_change.py +108 -0
  18. hiddenlayer/sdk/rest/models/artifact_content.py +101 -0
  19. hiddenlayer/sdk/rest/models/artifact_location.py +109 -0
  20. hiddenlayer/sdk/rest/models/attachment.py +129 -0
  21. hiddenlayer/sdk/rest/models/code_flow.py +113 -0
  22. hiddenlayer/sdk/rest/models/configuration_override.py +108 -0
  23. hiddenlayer/sdk/rest/models/conversion.py +114 -0
  24. hiddenlayer/sdk/rest/models/create_sensor_request.py +1 -1
  25. hiddenlayer/sdk/rest/models/detections.py +101 -0
  26. hiddenlayer/sdk/rest/models/edge.py +108 -0
  27. hiddenlayer/sdk/rest/models/edge_traversal.py +122 -0
  28. hiddenlayer/sdk/rest/models/exception.py +113 -0
  29. hiddenlayer/sdk/rest/models/external_properties.py +273 -0
  30. hiddenlayer/sdk/rest/models/external_property_file_reference.py +102 -0
  31. hiddenlayer/sdk/rest/models/external_property_file_references.py +240 -0
  32. hiddenlayer/sdk/rest/models/file_details_v3.py +140 -0
  33. hiddenlayer/sdk/rest/models/file_scan_report_v3.py +132 -0
  34. hiddenlayer/sdk/rest/models/file_scan_reports_v3.py +95 -0
  35. hiddenlayer/sdk/rest/models/fix.py +113 -0
  36. hiddenlayer/sdk/rest/models/get_multipart_upload_response.py +1 -1
  37. hiddenlayer/sdk/rest/models/graph.py +123 -0
  38. hiddenlayer/sdk/rest/models/graph_traversal.py +97 -0
  39. hiddenlayer/sdk/rest/models/invocation.py +199 -0
  40. hiddenlayer/sdk/rest/models/location.py +146 -0
  41. hiddenlayer/sdk/rest/models/{validation_error_model_loc_inner.py → location_inner.py} +7 -7
  42. hiddenlayer/sdk/rest/models/location_relationship.py +107 -0
  43. hiddenlayer/sdk/rest/models/logical_location.py +104 -0
  44. hiddenlayer/sdk/rest/models/message.py +92 -0
  45. hiddenlayer/sdk/rest/models/mitre_atlas_inner.py +110 -0
  46. hiddenlayer/sdk/rest/models/model.py +1 -1
  47. hiddenlayer/sdk/rest/models/model_inventory_info.py +99 -0
  48. hiddenlayer/sdk/rest/models/model_query_response.py +1 -1
  49. hiddenlayer/sdk/rest/models/model_scan_api_v3_scan_model_version_id_patch200_response.py +87 -0
  50. hiddenlayer/sdk/rest/models/model_scan_api_v3_scan_query200_response.py +102 -0
  51. hiddenlayer/sdk/rest/models/multiformat_message_string.py +95 -0
  52. hiddenlayer/sdk/rest/models/multipart_upload_part.py +1 -1
  53. hiddenlayer/sdk/rest/models/node.py +122 -0
  54. hiddenlayer/sdk/rest/models/notification.py +157 -0
  55. hiddenlayer/sdk/rest/models/paged_response_with_total.py +94 -0
  56. hiddenlayer/sdk/rest/models/physical_location.py +94 -0
  57. hiddenlayer/sdk/rest/models/property_bag.py +101 -0
  58. hiddenlayer/sdk/rest/models/rectangle.py +110 -0
  59. hiddenlayer/sdk/rest/models/region.py +127 -0
  60. hiddenlayer/sdk/rest/models/replacement.py +103 -0
  61. hiddenlayer/sdk/rest/models/reporting_configuration.py +113 -0
  62. hiddenlayer/sdk/rest/models/reporting_descriptor.py +162 -0
  63. hiddenlayer/sdk/rest/models/reporting_descriptor_reference.py +103 -0
  64. hiddenlayer/sdk/rest/models/reporting_descriptor_relationship.py +115 -0
  65. hiddenlayer/sdk/rest/models/result.py +312 -0
  66. hiddenlayer/sdk/rest/models/result_provenance.py +133 -0
  67. hiddenlayer/sdk/rest/models/rule_details_inner.py +102 -0
  68. hiddenlayer/sdk/rest/models/run.py +318 -0
  69. hiddenlayer/sdk/rest/models/run_automation_details.py +129 -0
  70. hiddenlayer/sdk/rest/models/sarif210.py +123 -0
  71. hiddenlayer/sdk/rest/models/scan_create_request.py +87 -0
  72. hiddenlayer/sdk/rest/models/scan_detection_v3.py +156 -0
  73. hiddenlayer/sdk/rest/models/scan_header_v3.py +129 -0
  74. hiddenlayer/sdk/rest/models/scan_job.py +109 -0
  75. hiddenlayer/sdk/rest/models/scan_job_inventory.py +137 -0
  76. hiddenlayer/sdk/rest/models/scan_model_details_v3.py +95 -0
  77. hiddenlayer/sdk/rest/models/scan_model_ids_v3.py +89 -0
  78. hiddenlayer/sdk/rest/models/scan_model_request.py +1 -1
  79. hiddenlayer/sdk/rest/models/scan_report_v3.py +139 -0
  80. hiddenlayer/sdk/rest/models/{file_info.py → scan_results.py} +14 -6
  81. hiddenlayer/sdk/rest/models/scan_results_v2.py +30 -10
  82. hiddenlayer/sdk/rest/models/security_posture.py +89 -0
  83. hiddenlayer/sdk/rest/models/sensor_sor_model_card_query_response.py +101 -0
  84. hiddenlayer/sdk/rest/models/sensor_sor_model_card_response.py +127 -0
  85. hiddenlayer/sdk/rest/models/sensor_sor_query_filter.py +1 -1
  86. hiddenlayer/sdk/rest/models/sensor_sor_query_request.py +1 -1
  87. hiddenlayer/sdk/rest/models/special_locations.py +97 -0
  88. hiddenlayer/sdk/rest/models/stack.py +113 -0
  89. hiddenlayer/sdk/rest/models/stack_frame.py +104 -0
  90. hiddenlayer/sdk/rest/models/submission_response.py +1 -1
  91. hiddenlayer/sdk/rest/models/submission_v2.py +1 -1
  92. hiddenlayer/sdk/rest/models/suppression.py +133 -0
  93. hiddenlayer/sdk/rest/models/thread_flow.py +144 -0
  94. hiddenlayer/sdk/rest/models/thread_flow_location.py +166 -0
  95. hiddenlayer/sdk/rest/models/tool.py +107 -0
  96. hiddenlayer/sdk/rest/models/tool_component.py +251 -0
  97. hiddenlayer/sdk/rest/models/tool_component_reference.py +108 -0
  98. hiddenlayer/sdk/rest/models/translation_metadata.py +110 -0
  99. hiddenlayer/sdk/rest/models/validation_error_model.py +4 -4
  100. hiddenlayer/sdk/rest/models/version_control_details.py +108 -0
  101. hiddenlayer/sdk/rest/models/web_request.py +112 -0
  102. hiddenlayer/sdk/rest/models/web_response.py +112 -0
  103. hiddenlayer/sdk/rest/rest.py +1 -1
  104. hiddenlayer/sdk/services/model.py +51 -3
  105. hiddenlayer/sdk/services/model_scan.py +153 -105
  106. hiddenlayer/sdk/version.py +1 -1
  107. {hiddenlayer_sdk-0.1.2.dist-info → hiddenlayer_sdk-1.1.0.dist-info}/METADATA +40 -21
  108. hiddenlayer_sdk-1.1.0.dist-info/RECORD +118 -0
  109. {hiddenlayer_sdk-0.1.2.dist-info → hiddenlayer_sdk-1.1.0.dist-info}/WHEEL +1 -1
  110. hiddenlayer/sdk/enterprise/__init__.py +0 -0
  111. hiddenlayer/sdk/enterprise/enterprise_model_scan_api.py +0 -55
  112. hiddenlayer_sdk-0.1.2.dist-info/RECORD +0 -43
  113. {hiddenlayer_sdk-0.1.2.dist-info → hiddenlayer_sdk-1.1.0.dist-info}/LICENSE +0 -0
  114. {hiddenlayer_sdk-0.1.2.dist-info → hiddenlayer_sdk-1.1.0.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
  # flake8: noqa
4
4
  """
5
- HiddenLayer ModelScan
5
+ HiddenLayer ModelScan V2
6
6
 
7
7
  HiddenLayer ModelScan API for scanning of models
8
8
 
@@ -14,17 +14,91 @@
14
14
 
15
15
 
16
16
  # import models into model package
17
+ from hiddenlayer.sdk.rest.models.address import Address
18
+ from hiddenlayer.sdk.rest.models.artifact import Artifact
19
+ from hiddenlayer.sdk.rest.models.artifact_change import ArtifactChange
20
+ from hiddenlayer.sdk.rest.models.artifact_content import ArtifactContent
21
+ from hiddenlayer.sdk.rest.models.artifact_location import ArtifactLocation
22
+ from hiddenlayer.sdk.rest.models.attachment import Attachment
23
+ from hiddenlayer.sdk.rest.models.code_flow import CodeFlow
24
+ from hiddenlayer.sdk.rest.models.configuration_override import ConfigurationOverride
25
+ from hiddenlayer.sdk.rest.models.conversion import Conversion
17
26
  from hiddenlayer.sdk.rest.models.create_sensor_request import CreateSensorRequest
18
- from hiddenlayer.sdk.rest.models.file_info import FileInfo
27
+ from hiddenlayer.sdk.rest.models.detections import Detections
28
+ from hiddenlayer.sdk.rest.models.edge import Edge
29
+ from hiddenlayer.sdk.rest.models.edge_traversal import EdgeTraversal
30
+ from hiddenlayer.sdk.rest.models.exception import Exception
31
+ from hiddenlayer.sdk.rest.models.external_properties import ExternalProperties
32
+ from hiddenlayer.sdk.rest.models.external_property_file_reference import ExternalPropertyFileReference
33
+ from hiddenlayer.sdk.rest.models.external_property_file_references import ExternalPropertyFileReferences
34
+ from hiddenlayer.sdk.rest.models.file_details_v3 import FileDetailsV3
35
+ from hiddenlayer.sdk.rest.models.file_scan_report_v3 import FileScanReportV3
36
+ from hiddenlayer.sdk.rest.models.file_scan_reports_v3 import FileScanReportsV3
37
+ from hiddenlayer.sdk.rest.models.fix import Fix
19
38
  from hiddenlayer.sdk.rest.models.get_multipart_upload_response import GetMultipartUploadResponse
39
+ from hiddenlayer.sdk.rest.models.graph import Graph
40
+ from hiddenlayer.sdk.rest.models.graph_traversal import GraphTraversal
41
+ from hiddenlayer.sdk.rest.models.invocation import Invocation
42
+ from hiddenlayer.sdk.rest.models.location import Location
43
+ from hiddenlayer.sdk.rest.models.location_inner import LocationInner
44
+ from hiddenlayer.sdk.rest.models.location_relationship import LocationRelationship
45
+ from hiddenlayer.sdk.rest.models.logical_location import LogicalLocation
46
+ from hiddenlayer.sdk.rest.models.mitre_atlas_inner import MITREAtlasInner
47
+ from hiddenlayer.sdk.rest.models.message import Message
20
48
  from hiddenlayer.sdk.rest.models.model import Model
49
+ from hiddenlayer.sdk.rest.models.model_inventory_info import ModelInventoryInfo
21
50
  from hiddenlayer.sdk.rest.models.model_query_response import ModelQueryResponse
51
+ from hiddenlayer.sdk.rest.models.model_scan_api_v3_scan_model_version_id_patch200_response import ModelScanApiV3ScanModelVersionIdPatch200Response
52
+ from hiddenlayer.sdk.rest.models.model_scan_api_v3_scan_query200_response import ModelScanApiV3ScanQuery200Response
53
+ from hiddenlayer.sdk.rest.models.multiformat_message_string import MultiformatMessageString
22
54
  from hiddenlayer.sdk.rest.models.multipart_upload_part import MultipartUploadPart
55
+ from hiddenlayer.sdk.rest.models.node import Node
56
+ from hiddenlayer.sdk.rest.models.notification import Notification
57
+ from hiddenlayer.sdk.rest.models.paged_response_with_total import PagedResponseWithTotal
58
+ from hiddenlayer.sdk.rest.models.physical_location import PhysicalLocation
59
+ from hiddenlayer.sdk.rest.models.property_bag import PropertyBag
60
+ from hiddenlayer.sdk.rest.models.rectangle import Rectangle
61
+ from hiddenlayer.sdk.rest.models.region import Region
62
+ from hiddenlayer.sdk.rest.models.replacement import Replacement
63
+ from hiddenlayer.sdk.rest.models.reporting_configuration import ReportingConfiguration
64
+ from hiddenlayer.sdk.rest.models.reporting_descriptor import ReportingDescriptor
65
+ from hiddenlayer.sdk.rest.models.reporting_descriptor_reference import ReportingDescriptorReference
66
+ from hiddenlayer.sdk.rest.models.reporting_descriptor_relationship import ReportingDescriptorRelationship
67
+ from hiddenlayer.sdk.rest.models.result import Result
68
+ from hiddenlayer.sdk.rest.models.result_provenance import ResultProvenance
69
+ from hiddenlayer.sdk.rest.models.rule_details_inner import RuleDetailsInner
70
+ from hiddenlayer.sdk.rest.models.run import Run
71
+ from hiddenlayer.sdk.rest.models.run_automation_details import RunAutomationDetails
72
+ from hiddenlayer.sdk.rest.models.sarif210 import Sarif210
73
+ from hiddenlayer.sdk.rest.models.scan_create_request import ScanCreateRequest
74
+ from hiddenlayer.sdk.rest.models.scan_detection_v3 import ScanDetectionV3
75
+ from hiddenlayer.sdk.rest.models.scan_header_v3 import ScanHeaderV3
76
+ from hiddenlayer.sdk.rest.models.scan_job import ScanJob
77
+ from hiddenlayer.sdk.rest.models.scan_job_inventory import ScanJobInventory
78
+ from hiddenlayer.sdk.rest.models.scan_model_details_v3 import ScanModelDetailsV3
79
+ from hiddenlayer.sdk.rest.models.scan_model_ids_v3 import ScanModelIdsV3
23
80
  from hiddenlayer.sdk.rest.models.scan_model_request import ScanModelRequest
81
+ from hiddenlayer.sdk.rest.models.scan_report_v3 import ScanReportV3
82
+ from hiddenlayer.sdk.rest.models.scan_results import ScanResults
24
83
  from hiddenlayer.sdk.rest.models.scan_results_v2 import ScanResultsV2
84
+ from hiddenlayer.sdk.rest.models.security_posture import SecurityPosture
85
+ from hiddenlayer.sdk.rest.models.sensor_sor_model_card_query_response import SensorSORModelCardQueryResponse
86
+ from hiddenlayer.sdk.rest.models.sensor_sor_model_card_response import SensorSORModelCardResponse
25
87
  from hiddenlayer.sdk.rest.models.sensor_sor_query_filter import SensorSORQueryFilter
26
88
  from hiddenlayer.sdk.rest.models.sensor_sor_query_request import SensorSORQueryRequest
89
+ from hiddenlayer.sdk.rest.models.special_locations import SpecialLocations
90
+ from hiddenlayer.sdk.rest.models.stack import Stack
91
+ from hiddenlayer.sdk.rest.models.stack_frame import StackFrame
27
92
  from hiddenlayer.sdk.rest.models.submission_response import SubmissionResponse
28
93
  from hiddenlayer.sdk.rest.models.submission_v2 import SubmissionV2
94
+ from hiddenlayer.sdk.rest.models.suppression import Suppression
95
+ from hiddenlayer.sdk.rest.models.thread_flow import ThreadFlow
96
+ from hiddenlayer.sdk.rest.models.thread_flow_location import ThreadFlowLocation
97
+ from hiddenlayer.sdk.rest.models.tool import Tool
98
+ from hiddenlayer.sdk.rest.models.tool_component import ToolComponent
99
+ from hiddenlayer.sdk.rest.models.tool_component_reference import ToolComponentReference
100
+ from hiddenlayer.sdk.rest.models.translation_metadata import TranslationMetadata
29
101
  from hiddenlayer.sdk.rest.models.validation_error_model import ValidationErrorModel
30
- from hiddenlayer.sdk.rest.models.validation_error_model_loc_inner import ValidationErrorModelLocInner
102
+ from hiddenlayer.sdk.rest.models.version_control_details import VersionControlDetails
103
+ from hiddenlayer.sdk.rest.models.web_request import WebRequest
104
+ from hiddenlayer.sdk.rest.models.web_response import WebResponse
@@ -0,0 +1,110 @@
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, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing_extensions import Annotated
23
+ from hiddenlayer.sdk.rest.models.property_bag import PropertyBag
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class Address(BaseModel):
28
+ """
29
+ A physical or virtual address, or a range of addresses, in an 'addressable region' (memory or a binary file).
30
+ """ # noqa: E501
31
+ absolute_address: Optional[Annotated[int, Field(strict=True, ge=-1)]] = Field(default=-1, description="The address expressed as a byte offset from the start of the addressable region.", alias="absoluteAddress")
32
+ relative_address: Optional[StrictInt] = Field(default=None, description="The address expressed as a byte offset from the absolute address of the top-most parent object.", alias="relativeAddress")
33
+ length: Optional[StrictInt] = Field(default=None, description="The number of bytes in this range of addresses.")
34
+ kind: Optional[StrictStr] = Field(default=None, description="An open-ended string that identifies the address kind. 'data', 'function', 'header','instruction', 'module', 'page', 'section', 'segment', 'stack', 'stackFrame', 'table' are well-known values.")
35
+ name: Optional[StrictStr] = Field(default=None, description="A name that is associated with the address, e.g., '.text'.")
36
+ fully_qualified_name: Optional[StrictStr] = Field(default=None, description="A human-readable fully qualified name that is associated with the address.", alias="fullyQualifiedName")
37
+ offset_from_parent: Optional[StrictInt] = Field(default=None, description="The byte offset of this address from the absolute or relative address of the parent object.", alias="offsetFromParent")
38
+ index: Optional[Annotated[int, Field(strict=True, ge=-1)]] = Field(default=-1, description="The index within run.addresses of the cached object for this address.")
39
+ parent_index: Optional[Annotated[int, Field(strict=True, ge=-1)]] = Field(default=-1, description="The index within run.addresses of the parent object.", alias="parentIndex")
40
+ properties: Optional[PropertyBag] = None
41
+ __properties: ClassVar[List[str]] = ["absoluteAddress", "relativeAddress", "length", "kind", "name", "fullyQualifiedName", "offsetFromParent", "index", "parentIndex", "properties"]
42
+
43
+ model_config = ConfigDict(
44
+ populate_by_name=True,
45
+ validate_assignment=True,
46
+ protected_namespaces=(),
47
+ )
48
+
49
+
50
+ def to_str(self) -> str:
51
+ """Returns the string representation of the model using alias"""
52
+ return pprint.pformat(self.model_dump(by_alias=True))
53
+
54
+ def to_json(self) -> str:
55
+ """Returns the JSON representation of the model using alias"""
56
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
57
+ return json.dumps(self.to_dict())
58
+
59
+ @classmethod
60
+ def from_json(cls, json_str: str) -> Optional[Self]:
61
+ """Create an instance of Address from a JSON string"""
62
+ return cls.from_dict(json.loads(json_str))
63
+
64
+ def to_dict(self) -> Dict[str, Any]:
65
+ """Return the dictionary representation of the model using alias.
66
+
67
+ This has the following differences from calling pydantic's
68
+ `self.model_dump(by_alias=True)`:
69
+
70
+ * `None` is only added to the output dict for nullable fields that
71
+ were set at model initialization. Other fields with value `None`
72
+ are ignored.
73
+ """
74
+ excluded_fields: Set[str] = set([
75
+ ])
76
+
77
+ _dict = self.model_dump(
78
+ by_alias=True,
79
+ exclude=excluded_fields,
80
+ exclude_none=True,
81
+ )
82
+ # override the default output from pydantic by calling `to_dict()` of properties
83
+ if self.properties:
84
+ _dict['properties'] = self.properties.to_dict()
85
+ return _dict
86
+
87
+ @classmethod
88
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
89
+ """Create an instance of Address from a dict"""
90
+ if obj is None:
91
+ return None
92
+
93
+ if not isinstance(obj, dict):
94
+ return cls.model_validate(obj)
95
+
96
+ _obj = cls.model_validate({
97
+ "absoluteAddress": obj.get("absoluteAddress") if obj.get("absoluteAddress") is not None else -1,
98
+ "relativeAddress": obj.get("relativeAddress"),
99
+ "length": obj.get("length"),
100
+ "kind": obj.get("kind"),
101
+ "name": obj.get("name"),
102
+ "fullyQualifiedName": obj.get("fullyQualifiedName"),
103
+ "offsetFromParent": obj.get("offsetFromParent"),
104
+ "index": obj.get("index") if obj.get("index") is not None else -1,
105
+ "parentIndex": obj.get("parentIndex") if obj.get("parentIndex") is not None else -1,
106
+ "properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
107
+ })
108
+ return _obj
109
+
110
+
@@ -0,0 +1,155 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan V2
5
+
6
+ HiddenLayer ModelScan API for scanning of models
7
+
8
+ The version of the OpenAPI document: 1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from 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_extensions import Annotated
24
+ from hiddenlayer.sdk.rest.models.artifact_content import ArtifactContent
25
+ from hiddenlayer.sdk.rest.models.artifact_location import ArtifactLocation
26
+ from hiddenlayer.sdk.rest.models.message import Message
27
+ from hiddenlayer.sdk.rest.models.property_bag import PropertyBag
28
+ from typing import Optional, Set
29
+ from typing_extensions import Self
30
+
31
+ class Artifact(BaseModel):
32
+ """
33
+ A single artifact. In some cases, this artifact might be nested within another artifact.
34
+ """ # noqa: E501
35
+ description: Optional[Message] = None
36
+ location: Optional[ArtifactLocation] = None
37
+ parent_index: Optional[Annotated[int, Field(strict=True, ge=-1)]] = Field(default=-1, description="Identifies the index of the immediate parent of the artifact, if this artifact is nested.", alias="parentIndex")
38
+ offset: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, description="The offset in bytes of the artifact within its containing artifact.")
39
+ length: Optional[Annotated[int, Field(strict=True, ge=-1)]] = Field(default=-1, description="The length of the artifact in bytes.")
40
+ roles: Optional[Annotated[List[StrictStr], Field(min_length=0)]] = Field(default=None, description="The role or roles played by the artifact in the analysis.")
41
+ mime_type: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="The MIME type (RFC 2045) of the artifact.", alias="mimeType")
42
+ contents: Optional[ArtifactContent] = None
43
+ encoding: Optional[StrictStr] = Field(default=None, description="Specifies the encoding for an artifact object that refers to a text file.")
44
+ source_language: Optional[StrictStr] = Field(default=None, description="Specifies the source language for any artifact object that refers to a text file that contains source code.", alias="sourceLanguage")
45
+ hashes: Optional[Dict[str, StrictStr]] = Field(default=None, description="A dictionary, each of whose keys is the name of a hash function and each of whose values is the hashed value of the artifact produced by the specified hash function.")
46
+ last_modified_time_utc: Optional[datetime] = Field(default=None, description="The Coordinated Universal Time (UTC) date and time at which the artifact was most recently modified. See \"Date/time properties\" in the SARIF spec for the required format.", alias="lastModifiedTimeUtc")
47
+ properties: Optional[PropertyBag] = None
48
+ __properties: ClassVar[List[str]] = ["description", "location", "parentIndex", "offset", "length", "roles", "mimeType", "contents", "encoding", "sourceLanguage", "hashes", "lastModifiedTimeUtc", "properties"]
49
+
50
+ @field_validator('roles')
51
+ def roles_validate_enum(cls, value):
52
+ """Validates the enum"""
53
+ if value is None:
54
+ return value
55
+
56
+ for i in value:
57
+ if i not in set(['analysisTarget', 'attachment', 'responseFile', 'resultFile', 'standardStream', 'tracedFile', 'unmodified', 'modified', 'added', 'deleted', 'renamed', 'uncontrolled', 'driver', 'extension', 'translation', 'taxonomy', 'policy', 'referencedOnCommandLine', 'memoryContents', 'directory', 'userSpecifiedConfiguration', 'toolSpecifiedConfiguration', 'debugOutputFile']):
58
+ raise ValueError("each list item must be one of ('analysisTarget', 'attachment', 'responseFile', 'resultFile', 'standardStream', 'tracedFile', 'unmodified', 'modified', 'added', 'deleted', 'renamed', 'uncontrolled', 'driver', 'extension', 'translation', 'taxonomy', 'policy', 'referencedOnCommandLine', 'memoryContents', 'directory', 'userSpecifiedConfiguration', 'toolSpecifiedConfiguration', 'debugOutputFile')")
59
+ return value
60
+
61
+ @field_validator('mime_type')
62
+ def mime_type_validate_regular_expression(cls, value):
63
+ """Validates the regular expression"""
64
+ if value is None:
65
+ return value
66
+
67
+ if not re.match(r"[^\/]+\/.+", value):
68
+ raise ValueError(r"must validate the regular expression /[^\/]+\/.+/")
69
+ return value
70
+
71
+ model_config = ConfigDict(
72
+ populate_by_name=True,
73
+ validate_assignment=True,
74
+ protected_namespaces=(),
75
+ )
76
+
77
+
78
+ def to_str(self) -> str:
79
+ """Returns the string representation of the model using alias"""
80
+ return pprint.pformat(self.model_dump(by_alias=True))
81
+
82
+ def to_json(self) -> str:
83
+ """Returns the JSON representation of the model using alias"""
84
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
85
+ return json.dumps(self.to_dict())
86
+
87
+ @classmethod
88
+ def from_json(cls, json_str: str) -> Optional[Self]:
89
+ """Create an instance of Artifact from a JSON string"""
90
+ return cls.from_dict(json.loads(json_str))
91
+
92
+ def to_dict(self) -> Dict[str, Any]:
93
+ """Return the dictionary representation of the model using alias.
94
+
95
+ This has the following differences from calling pydantic's
96
+ `self.model_dump(by_alias=True)`:
97
+
98
+ * `None` is only added to the output dict for nullable fields that
99
+ were set at model initialization. Other fields with value `None`
100
+ are ignored.
101
+ """
102
+ excluded_fields: Set[str] = set([
103
+ ])
104
+
105
+ _dict = self.model_dump(
106
+ by_alias=True,
107
+ exclude=excluded_fields,
108
+ exclude_none=True,
109
+ )
110
+ # override the default output from pydantic by calling `to_dict()` of description
111
+ if self.description:
112
+ _dict['description'] = self.description.to_dict()
113
+ # override the default output from pydantic by calling `to_dict()` of location
114
+ if self.location:
115
+ _dict['location'] = self.location.to_dict()
116
+ # override the default output from pydantic by calling `to_dict()` of contents
117
+ if self.contents:
118
+ _dict['contents'] = self.contents.to_dict()
119
+ # override the default output from pydantic by calling `to_dict()` of properties
120
+ if self.properties:
121
+ _dict['properties'] = self.properties.to_dict()
122
+ # set to None if description (nullable) is None
123
+ # and model_fields_set contains the field
124
+ if self.description is None and "description" in self.model_fields_set:
125
+ _dict['description'] = None
126
+
127
+ return _dict
128
+
129
+ @classmethod
130
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
131
+ """Create an instance of Artifact from a dict"""
132
+ if obj is None:
133
+ return None
134
+
135
+ if not isinstance(obj, dict):
136
+ return cls.model_validate(obj)
137
+
138
+ _obj = cls.model_validate({
139
+ "description": Message.from_dict(obj["description"]) if obj.get("description") is not None else None,
140
+ "location": ArtifactLocation.from_dict(obj["location"]) if obj.get("location") is not None else None,
141
+ "parentIndex": obj.get("parentIndex") if obj.get("parentIndex") is not None else -1,
142
+ "offset": obj.get("offset"),
143
+ "length": obj.get("length") if obj.get("length") is not None else -1,
144
+ "roles": obj.get("roles"),
145
+ "mimeType": obj.get("mimeType"),
146
+ "contents": ArtifactContent.from_dict(obj["contents"]) if obj.get("contents") is not None else None,
147
+ "encoding": obj.get("encoding"),
148
+ "sourceLanguage": obj.get("sourceLanguage"),
149
+ "hashes": obj.get("hashes"),
150
+ "lastModifiedTimeUtc": obj.get("lastModifiedTimeUtc"),
151
+ "properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
152
+ })
153
+ return _obj
154
+
155
+
@@ -0,0 +1,108 @@
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
22
+ from typing_extensions import Annotated
23
+ from hiddenlayer.sdk.rest.models.artifact_location import ArtifactLocation
24
+ from hiddenlayer.sdk.rest.models.property_bag import PropertyBag
25
+ from hiddenlayer.sdk.rest.models.replacement import Replacement
26
+ from typing import Optional, Set
27
+ from typing_extensions import Self
28
+
29
+ class ArtifactChange(BaseModel):
30
+ """
31
+ A change to a single artifact.
32
+ """ # noqa: E501
33
+ artifact_location: ArtifactLocation = Field(alias="artifactLocation")
34
+ replacements: Annotated[List[Replacement], Field(min_length=1)] = Field(description="An array of replacement objects, each of which represents the replacement of a single region in a single artifact specified by 'artifactLocation'.")
35
+ properties: Optional[PropertyBag] = None
36
+ __properties: ClassVar[List[str]] = ["artifactLocation", "replacements", "properties"]
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 ArtifactChange 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
+ # override the default output from pydantic by calling `to_dict()` of artifact_location
78
+ if self.artifact_location:
79
+ _dict['artifactLocation'] = self.artifact_location.to_dict()
80
+ # override the default output from pydantic by calling `to_dict()` of each item in replacements (list)
81
+ _items = []
82
+ if self.replacements:
83
+ for _item in self.replacements:
84
+ if _item:
85
+ _items.append(_item.to_dict())
86
+ _dict['replacements'] = _items
87
+ # override the default output from pydantic by calling `to_dict()` of properties
88
+ if self.properties:
89
+ _dict['properties'] = self.properties.to_dict()
90
+ return _dict
91
+
92
+ @classmethod
93
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
94
+ """Create an instance of ArtifactChange from a dict"""
95
+ if obj is None:
96
+ return None
97
+
98
+ if not isinstance(obj, dict):
99
+ return cls.model_validate(obj)
100
+
101
+ _obj = cls.model_validate({
102
+ "artifactLocation": ArtifactLocation.from_dict(obj["artifactLocation"]) if obj.get("artifactLocation") is not None else None,
103
+ "replacements": [Replacement.from_dict(_item) for _item in obj["replacements"]] if obj.get("replacements") is not None else None,
104
+ "properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
105
+ })
106
+ return _obj
107
+
108
+
@@ -0,0 +1,101 @@
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.multiformat_message_string import MultiformatMessageString
23
+ from hiddenlayer.sdk.rest.models.property_bag import PropertyBag
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class ArtifactContent(BaseModel):
28
+ """
29
+ Represents the contents of an artifact.
30
+ """ # noqa: E501
31
+ text: Optional[StrictStr] = Field(default=None, description="UTF-8-encoded content from a text artifact.")
32
+ binary: Optional[StrictStr] = Field(default=None, description="MIME Base64-encoded content from a binary artifact, or from a text artifact in its original encoding.")
33
+ rendered: Optional[MultiformatMessageString] = None
34
+ properties: Optional[PropertyBag] = None
35
+ __properties: ClassVar[List[str]] = ["text", "binary", "rendered", "properties"]
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 ArtifactContent 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 rendered
77
+ if self.rendered:
78
+ _dict['rendered'] = self.rendered.to_dict()
79
+ # override the default output from pydantic by calling `to_dict()` of properties
80
+ if self.properties:
81
+ _dict['properties'] = self.properties.to_dict()
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of ArtifactContent from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate({
94
+ "text": obj.get("text"),
95
+ "binary": obj.get("binary"),
96
+ "rendered": MultiformatMessageString.from_dict(obj["rendered"]) if obj.get("rendered") is not None else None,
97
+ "properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
98
+ })
99
+ return _obj
100
+
101
+