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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. hiddenlayer/sdk/models.py +45 -8
  2. hiddenlayer/sdk/rest/__init__.py +80 -3
  3. hiddenlayer/sdk/rest/api/__init__.py +3 -0
  4. hiddenlayer/sdk/rest/api/aidr_predictive_api.py +1 -1
  5. hiddenlayer/sdk/rest/api/health_api.py +272 -0
  6. hiddenlayer/sdk/rest/api/model_scan_api.py +1 -1
  7. hiddenlayer/sdk/rest/api/model_supply_chain_api.py +2927 -0
  8. hiddenlayer/sdk/rest/api/readiness_api.py +272 -0
  9. hiddenlayer/sdk/rest/api/sensor_api.py +345 -16
  10. hiddenlayer/sdk/rest/api_client.py +1 -1
  11. hiddenlayer/sdk/rest/configuration.py +4 -4
  12. hiddenlayer/sdk/rest/exceptions.py +1 -1
  13. hiddenlayer/sdk/rest/models/__init__.py +77 -3
  14. hiddenlayer/sdk/rest/models/address.py +110 -0
  15. hiddenlayer/sdk/rest/models/artifact.py +155 -0
  16. hiddenlayer/sdk/rest/models/artifact_change.py +108 -0
  17. hiddenlayer/sdk/rest/models/artifact_content.py +101 -0
  18. hiddenlayer/sdk/rest/models/artifact_location.py +109 -0
  19. hiddenlayer/sdk/rest/models/attachment.py +129 -0
  20. hiddenlayer/sdk/rest/models/code_flow.py +113 -0
  21. hiddenlayer/sdk/rest/models/configuration_override.py +108 -0
  22. hiddenlayer/sdk/rest/models/conversion.py +114 -0
  23. hiddenlayer/sdk/rest/models/create_sensor_request.py +1 -1
  24. hiddenlayer/sdk/rest/models/detections.py +101 -0
  25. hiddenlayer/sdk/rest/models/edge.py +108 -0
  26. hiddenlayer/sdk/rest/models/edge_traversal.py +122 -0
  27. hiddenlayer/sdk/rest/models/exception.py +113 -0
  28. hiddenlayer/sdk/rest/models/external_properties.py +273 -0
  29. hiddenlayer/sdk/rest/models/external_property_file_reference.py +102 -0
  30. hiddenlayer/sdk/rest/models/external_property_file_references.py +240 -0
  31. hiddenlayer/sdk/rest/models/file_details_v3.py +140 -0
  32. hiddenlayer/sdk/rest/models/file_results_inner.py +121 -0
  33. hiddenlayer/sdk/rest/models/file_scan_report_v3.py +95 -0
  34. hiddenlayer/sdk/rest/models/fix.py +113 -0
  35. hiddenlayer/sdk/rest/models/get_multipart_upload_response.py +1 -1
  36. hiddenlayer/sdk/rest/models/graph.py +123 -0
  37. hiddenlayer/sdk/rest/models/graph_traversal.py +97 -0
  38. hiddenlayer/sdk/rest/models/invocation.py +199 -0
  39. hiddenlayer/sdk/rest/models/location.py +146 -0
  40. hiddenlayer/sdk/rest/models/{validation_error_model_loc_inner.py → location_inner.py} +7 -7
  41. hiddenlayer/sdk/rest/models/location_relationship.py +107 -0
  42. hiddenlayer/sdk/rest/models/logical_location.py +104 -0
  43. hiddenlayer/sdk/rest/models/message.py +92 -0
  44. hiddenlayer/sdk/rest/models/mitre_atlas_inner.py +110 -0
  45. hiddenlayer/sdk/rest/models/model.py +1 -1
  46. hiddenlayer/sdk/rest/models/model_inventory_info.py +99 -0
  47. hiddenlayer/sdk/rest/models/model_query_response.py +1 -1
  48. hiddenlayer/sdk/rest/models/model_scan_api_v3_scan_model_version_id_patch200_response.py +87 -0
  49. hiddenlayer/sdk/rest/models/model_scan_api_v3_scan_query200_response.py +102 -0
  50. hiddenlayer/sdk/rest/models/multiformat_message_string.py +95 -0
  51. hiddenlayer/sdk/rest/models/multipart_upload_part.py +1 -1
  52. hiddenlayer/sdk/rest/models/node.py +122 -0
  53. hiddenlayer/sdk/rest/models/notification.py +157 -0
  54. hiddenlayer/sdk/rest/models/paged_response_with_total.py +94 -0
  55. hiddenlayer/sdk/rest/models/physical_location.py +94 -0
  56. hiddenlayer/sdk/rest/models/property_bag.py +101 -0
  57. hiddenlayer/sdk/rest/models/rectangle.py +110 -0
  58. hiddenlayer/sdk/rest/models/region.py +127 -0
  59. hiddenlayer/sdk/rest/models/replacement.py +103 -0
  60. hiddenlayer/sdk/rest/models/reporting_configuration.py +113 -0
  61. hiddenlayer/sdk/rest/models/reporting_descriptor.py +162 -0
  62. hiddenlayer/sdk/rest/models/reporting_descriptor_reference.py +103 -0
  63. hiddenlayer/sdk/rest/models/reporting_descriptor_relationship.py +115 -0
  64. hiddenlayer/sdk/rest/models/result.py +312 -0
  65. hiddenlayer/sdk/rest/models/result_provenance.py +133 -0
  66. hiddenlayer/sdk/rest/models/rule_details_inner.py +102 -0
  67. hiddenlayer/sdk/rest/models/run.py +318 -0
  68. hiddenlayer/sdk/rest/models/run_automation_details.py +129 -0
  69. hiddenlayer/sdk/rest/models/sarif210.py +123 -0
  70. hiddenlayer/sdk/rest/models/scan_create_request.py +87 -0
  71. hiddenlayer/sdk/rest/models/scan_detection_v3.py +156 -0
  72. hiddenlayer/sdk/rest/models/scan_header_v3.py +129 -0
  73. hiddenlayer/sdk/rest/models/scan_job.py +109 -0
  74. hiddenlayer/sdk/rest/models/scan_job_inventory.py +137 -0
  75. hiddenlayer/sdk/rest/models/scan_model_details_v3.py +95 -0
  76. hiddenlayer/sdk/rest/models/scan_model_ids_v3.py +89 -0
  77. hiddenlayer/sdk/rest/models/scan_model_request.py +1 -1
  78. hiddenlayer/sdk/rest/models/scan_report_v3.py +139 -0
  79. hiddenlayer/sdk/rest/models/{file_info.py → scan_results.py} +14 -6
  80. hiddenlayer/sdk/rest/models/scan_results_v2.py +30 -10
  81. hiddenlayer/sdk/rest/models/security_posture.py +89 -0
  82. hiddenlayer/sdk/rest/models/sensor_sor_model_card_query_response.py +101 -0
  83. hiddenlayer/sdk/rest/models/sensor_sor_model_card_response.py +127 -0
  84. hiddenlayer/sdk/rest/models/sensor_sor_query_filter.py +1 -1
  85. hiddenlayer/sdk/rest/models/sensor_sor_query_request.py +1 -1
  86. hiddenlayer/sdk/rest/models/special_locations.py +97 -0
  87. hiddenlayer/sdk/rest/models/stack.py +113 -0
  88. hiddenlayer/sdk/rest/models/stack_frame.py +104 -0
  89. hiddenlayer/sdk/rest/models/submission_response.py +1 -1
  90. hiddenlayer/sdk/rest/models/submission_v2.py +1 -1
  91. hiddenlayer/sdk/rest/models/suppression.py +133 -0
  92. hiddenlayer/sdk/rest/models/thread_flow.py +144 -0
  93. hiddenlayer/sdk/rest/models/thread_flow_location.py +166 -0
  94. hiddenlayer/sdk/rest/models/tool.py +107 -0
  95. hiddenlayer/sdk/rest/models/tool_component.py +251 -0
  96. hiddenlayer/sdk/rest/models/tool_component_reference.py +108 -0
  97. hiddenlayer/sdk/rest/models/translation_metadata.py +110 -0
  98. hiddenlayer/sdk/rest/models/validation_error_model.py +4 -4
  99. hiddenlayer/sdk/rest/models/version_control_details.py +108 -0
  100. hiddenlayer/sdk/rest/models/web_request.py +112 -0
  101. hiddenlayer/sdk/rest/models/web_response.py +112 -0
  102. hiddenlayer/sdk/rest/rest.py +1 -1
  103. hiddenlayer/sdk/services/model.py +5 -2
  104. hiddenlayer/sdk/services/model_scan.py +153 -105
  105. hiddenlayer/sdk/version.py +1 -1
  106. {hiddenlayer_sdk-0.1.1.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/METADATA +39 -20
  107. hiddenlayer_sdk-1.0.0.dist-info/RECORD +118 -0
  108. {hiddenlayer_sdk-0.1.1.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/WHEEL +1 -1
  109. hiddenlayer/sdk/enterprise/__init__.py +0 -0
  110. hiddenlayer/sdk/enterprise/enterprise_model_scan_api.py +0 -55
  111. hiddenlayer_sdk-0.1.1.dist-info/RECORD +0 -43
  112. {hiddenlayer_sdk-0.1.1.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/LICENSE +0 -0
  113. {hiddenlayer_sdk-0.1.1.dist-info → hiddenlayer_sdk-1.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,94 @@
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, Union
22
+ from typing_extensions import Annotated
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class PagedResponseWithTotal(BaseModel):
27
+ """
28
+ PagedResponseWithTotal
29
+ """ # noqa: E501
30
+ items: Optional[List[StrictStr]] = Field(default=None, description="List of items. If no matching items are found, then `[]` will be returned.")
31
+ 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.")
32
+ limit: Annotated[int, Field(le=100, strict=True, ge=1)] = Field(description="Maximum number of items to return")
33
+ offset: Annotated[int, Field(strict=True, ge=0)] = Field(description="Begin returning the results from this offset")
34
+ __properties: ClassVar[List[str]] = ["items", "total", "limit", "offset"]
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 PagedResponseWithTotal 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 PagedResponseWithTotal 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
+ "items": obj.get("items"),
88
+ "total": obj.get("total"),
89
+ "limit": obj.get("limit") if obj.get("limit") is not None else 25,
90
+ "offset": obj.get("offset") if obj.get("offset") is not None else 0
91
+ })
92
+ return _obj
93
+
94
+
@@ -0,0 +1,94 @@
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 hiddenlayer.sdk.rest.models.address import Address
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.region import Region
26
+ from typing import Optional, Set
27
+ from typing_extensions import Self
28
+
29
+ class PhysicalLocation(BaseModel):
30
+ """
31
+ A physical location relevant to a result. Specifies a reference to a programming artifact together with a range of bytes or characters within that artifact.
32
+ """ # noqa: E501
33
+ address: Optional[Address] = None
34
+ artifact_location: Optional[ArtifactLocation] = Field(default=None, alias="artifactLocation")
35
+ region: Optional[Region] = None
36
+ context_region: Optional[Region] = Field(default=None, alias="contextRegion")
37
+ properties: Optional[PropertyBag] = None
38
+ __properties: ClassVar[List[str]] = []
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 PhysicalLocation 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
+ return _dict
80
+
81
+ @classmethod
82
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
83
+ """Create an instance of PhysicalLocation from a dict"""
84
+ if obj is None:
85
+ return None
86
+
87
+ if not isinstance(obj, dict):
88
+ return cls.model_validate(obj)
89
+
90
+ _obj = cls.model_validate({
91
+ })
92
+ return _obj
93
+
94
+
@@ -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 typing_extensions import Annotated
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class PropertyBag(BaseModel):
27
+ """
28
+ Key/value pairs that provide additional information about the object.
29
+ """ # noqa: E501
30
+ tags: Optional[Annotated[List[StrictStr], Field(min_length=0)]] = Field(default=None, description="A set of distinct strings that provide additional information.")
31
+ additional_properties: Dict[str, Any] = {}
32
+ __properties: ClassVar[List[str]] = ["tags"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of PropertyBag from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ * Fields in `self.additional_properties` are added to the output dict.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ "additional_properties",
68
+ ])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ # puts key-value pairs in additional_properties in the top level
76
+ if self.additional_properties is not None:
77
+ for _key, _value in self.additional_properties.items():
78
+ _dict[_key] = _value
79
+
80
+ return _dict
81
+
82
+ @classmethod
83
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
84
+ """Create an instance of PropertyBag from a dict"""
85
+ if obj is None:
86
+ return None
87
+
88
+ if not isinstance(obj, dict):
89
+ return cls.model_validate(obj)
90
+
91
+ _obj = cls.model_validate({
92
+ "tags": obj.get("tags")
93
+ })
94
+ # store additional fields in additional_properties
95
+ for _key in obj.keys():
96
+ if _key not in cls.__properties:
97
+ _obj.additional_properties[_key] = obj.get(_key)
98
+
99
+ return _obj
100
+
101
+
@@ -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, StrictFloat, StrictInt
21
+ from typing import Any, ClassVar, Dict, List, Optional, Union
22
+ from hiddenlayer.sdk.rest.models.message import Message
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 Rectangle(BaseModel):
28
+ """
29
+ An area within an image.
30
+ """ # noqa: E501
31
+ top: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The Y coordinate of the top edge of the rectangle, measured in the image's natural units.")
32
+ left: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The X coordinate of the left edge of the rectangle, measured in the image's natural units.")
33
+ bottom: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The Y coordinate of the bottom edge of the rectangle, measured in the image's natural units.")
34
+ right: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The X coordinate of the right edge of the rectangle, measured in the image's natural units.")
35
+ message: Optional[Message] = None
36
+ properties: Optional[PropertyBag] = None
37
+ __properties: ClassVar[List[str]] = ["top", "left", "bottom", "right", "message", "properties"]
38
+
39
+ model_config = ConfigDict(
40
+ populate_by_name=True,
41
+ validate_assignment=True,
42
+ protected_namespaces=(),
43
+ )
44
+
45
+
46
+ def to_str(self) -> str:
47
+ """Returns the string representation of the model using alias"""
48
+ return pprint.pformat(self.model_dump(by_alias=True))
49
+
50
+ def to_json(self) -> str:
51
+ """Returns the JSON representation of the model using alias"""
52
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
53
+ return json.dumps(self.to_dict())
54
+
55
+ @classmethod
56
+ def from_json(cls, json_str: str) -> Optional[Self]:
57
+ """Create an instance of Rectangle from a JSON string"""
58
+ return cls.from_dict(json.loads(json_str))
59
+
60
+ def to_dict(self) -> Dict[str, Any]:
61
+ """Return the dictionary representation of the model using alias.
62
+
63
+ This has the following differences from calling pydantic's
64
+ `self.model_dump(by_alias=True)`:
65
+
66
+ * `None` is only added to the output dict for nullable fields that
67
+ were set at model initialization. Other fields with value `None`
68
+ are ignored.
69
+ """
70
+ excluded_fields: Set[str] = set([
71
+ ])
72
+
73
+ _dict = self.model_dump(
74
+ by_alias=True,
75
+ exclude=excluded_fields,
76
+ exclude_none=True,
77
+ )
78
+ # override the default output from pydantic by calling `to_dict()` of message
79
+ if self.message:
80
+ _dict['message'] = self.message.to_dict()
81
+ # override the default output from pydantic by calling `to_dict()` of properties
82
+ if self.properties:
83
+ _dict['properties'] = self.properties.to_dict()
84
+ # set to None if message (nullable) is None
85
+ # and model_fields_set contains the field
86
+ if self.message is None and "message" in self.model_fields_set:
87
+ _dict['message'] = None
88
+
89
+ return _dict
90
+
91
+ @classmethod
92
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
93
+ """Create an instance of Rectangle from a dict"""
94
+ if obj is None:
95
+ return None
96
+
97
+ if not isinstance(obj, dict):
98
+ return cls.model_validate(obj)
99
+
100
+ _obj = cls.model_validate({
101
+ "top": obj.get("top"),
102
+ "left": obj.get("left"),
103
+ "bottom": obj.get("bottom"),
104
+ "right": obj.get("right"),
105
+ "message": Message.from_dict(obj["message"]) if obj.get("message") is not None else None,
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,127 @@
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.artifact_content import ArtifactContent
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 Region(BaseModel):
30
+ """
31
+ A region within an artifact where a result was detected.
32
+ """ # noqa: E501
33
+ start_line: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="The line number of the first character in the region.", alias="startLine")
34
+ start_column: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="The column number of the first character in the region.", alias="startColumn")
35
+ end_line: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="The line number of the last character in the region.", alias="endLine")
36
+ end_column: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="The column number of the character following the end of the region.", alias="endColumn")
37
+ char_offset: Optional[Annotated[int, Field(strict=True, ge=-1)]] = Field(default=-1, description="The zero-based offset from the beginning of the artifact of the first character in the region.", alias="charOffset")
38
+ char_length: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, description="The length of the region in characters.", alias="charLength")
39
+ byte_offset: Optional[Annotated[int, Field(strict=True, ge=-1)]] = Field(default=-1, description="The zero-based offset from the beginning of the artifact of the first byte in the region.", alias="byteOffset")
40
+ byte_length: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, description="The length of the region in bytes.", alias="byteLength")
41
+ snippet: Optional[ArtifactContent] = None
42
+ message: Optional[Message] = None
43
+ source_language: Optional[StrictStr] = Field(default=None, description="Specifies the source language, if any, of the portion of the artifact specified by the region object.", alias="sourceLanguage")
44
+ properties: Optional[PropertyBag] = None
45
+ __properties: ClassVar[List[str]] = ["startLine", "startColumn", "endLine", "endColumn", "charOffset", "charLength", "byteOffset", "byteLength", "snippet", "message", "sourceLanguage", "properties"]
46
+
47
+ model_config = ConfigDict(
48
+ populate_by_name=True,
49
+ validate_assignment=True,
50
+ protected_namespaces=(),
51
+ )
52
+
53
+
54
+ def to_str(self) -> str:
55
+ """Returns the string representation of the model using alias"""
56
+ return pprint.pformat(self.model_dump(by_alias=True))
57
+
58
+ def to_json(self) -> str:
59
+ """Returns the JSON representation of the model using alias"""
60
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
61
+ return json.dumps(self.to_dict())
62
+
63
+ @classmethod
64
+ def from_json(cls, json_str: str) -> Optional[Self]:
65
+ """Create an instance of Region from a JSON string"""
66
+ return cls.from_dict(json.loads(json_str))
67
+
68
+ def to_dict(self) -> Dict[str, Any]:
69
+ """Return the dictionary representation of the model using alias.
70
+
71
+ This has the following differences from calling pydantic's
72
+ `self.model_dump(by_alias=True)`:
73
+
74
+ * `None` is only added to the output dict for nullable fields that
75
+ were set at model initialization. Other fields with value `None`
76
+ are ignored.
77
+ """
78
+ excluded_fields: Set[str] = set([
79
+ ])
80
+
81
+ _dict = self.model_dump(
82
+ by_alias=True,
83
+ exclude=excluded_fields,
84
+ exclude_none=True,
85
+ )
86
+ # override the default output from pydantic by calling `to_dict()` of snippet
87
+ if self.snippet:
88
+ _dict['snippet'] = self.snippet.to_dict()
89
+ # override the default output from pydantic by calling `to_dict()` of message
90
+ if self.message:
91
+ _dict['message'] = self.message.to_dict()
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 message (nullable) is None
96
+ # and model_fields_set contains the field
97
+ if self.message is None and "message" in self.model_fields_set:
98
+ _dict['message'] = 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 Region 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
+ "startLine": obj.get("startLine"),
113
+ "startColumn": obj.get("startColumn"),
114
+ "endLine": obj.get("endLine"),
115
+ "endColumn": obj.get("endColumn"),
116
+ "charOffset": obj.get("charOffset") if obj.get("charOffset") is not None else -1,
117
+ "charLength": obj.get("charLength"),
118
+ "byteOffset": obj.get("byteOffset") if obj.get("byteOffset") is not None else -1,
119
+ "byteLength": obj.get("byteLength"),
120
+ "snippet": ArtifactContent.from_dict(obj["snippet"]) if obj.get("snippet") is not None else None,
121
+ "message": Message.from_dict(obj["message"]) if obj.get("message") is not None else None,
122
+ "sourceLanguage": obj.get("sourceLanguage"),
123
+ "properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
124
+ })
125
+ return _obj
126
+
127
+
@@ -0,0 +1,103 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ HiddenLayer ModelScan V2
5
+
6
+ HiddenLayer ModelScan API for scanning of models
7
+
8
+ The version of the OpenAPI document: 1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from hiddenlayer.sdk.rest.models.artifact_content import ArtifactContent
23
+ from hiddenlayer.sdk.rest.models.property_bag import PropertyBag
24
+ from hiddenlayer.sdk.rest.models.region import Region
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+
28
+ class Replacement(BaseModel):
29
+ """
30
+ The replacement of a single region of an artifact.
31
+ """ # noqa: E501
32
+ deleted_region: Region = Field(alias="deletedRegion")
33
+ inserted_content: Optional[ArtifactContent] = Field(default=None, alias="insertedContent")
34
+ properties: Optional[PropertyBag] = None
35
+ __properties: ClassVar[List[str]] = ["deletedRegion", "insertedContent", "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 Replacement 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 deleted_region
77
+ if self.deleted_region:
78
+ _dict['deletedRegion'] = self.deleted_region.to_dict()
79
+ # override the default output from pydantic by calling `to_dict()` of inserted_content
80
+ if self.inserted_content:
81
+ _dict['insertedContent'] = self.inserted_content.to_dict()
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 Replacement 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
+ "deletedRegion": Region.from_dict(obj["deletedRegion"]) if obj.get("deletedRegion") is not None else None,
98
+ "insertedContent": ArtifactContent.from_dict(obj["insertedContent"]) if obj.get("insertedContent") is not None else None,
99
+ "properties": PropertyBag.from_dict(obj["properties"]) if obj.get("properties") is not None else None
100
+ })
101
+ return _obj
102
+
103
+