stepxmlclient 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. stepxmlclient/__init__.py +22 -0
  2. stepxmlclient/client.py +373 -0
  3. stepxmlclient/creator.py +317 -0
  4. stepxmlclient/model/__init__.py +418 -0
  5. stepxmlclient/model/asset.py +250 -0
  6. stepxmlclient/model/attribute.py +288 -0
  7. stepxmlclient/model/business.py +233 -0
  8. stepxmlclient/model/classification.py +409 -0
  9. stepxmlclient/model/complex_elements.py +260 -0
  10. stepxmlclient/model/deletion.py +87 -0
  11. stepxmlclient/model/entity.py +368 -0
  12. stepxmlclient/model/metadata.py +199 -0
  13. stepxmlclient/model/organization.py +167 -0
  14. stepxmlclient/model/product.py +519 -0
  15. stepxmlclient/model/relations.py +105 -0
  16. stepxmlclient/model/replacement.py +417 -0
  17. stepxmlclient/parser.py +2805 -0
  18. stepxmlclient/rest_client/__init__.py +16 -0
  19. stepxmlclient/rest_client/base.py +388 -0
  20. stepxmlclient/rest_client/client.py +127 -0
  21. stepxmlclient/rest_client/exceptions.py +97 -0
  22. stepxmlclient/rest_client/models/__init__.py +175 -0
  23. stepxmlclient/rest_client/models/asset.py +253 -0
  24. stepxmlclient/rest_client/models/attribute.py +112 -0
  25. stepxmlclient/rest_client/models/background_process.py +23 -0
  26. stepxmlclient/rest_client/models/batch.py +41 -0
  27. stepxmlclient/rest_client/models/classification.py +57 -0
  28. stepxmlclient/rest_client/models/collection.py +26 -0
  29. stepxmlclient/rest_client/models/common.py +192 -0
  30. stepxmlclient/rest_client/models/context.py +16 -0
  31. stepxmlclient/rest_client/models/data_type_group.py +15 -0
  32. stepxmlclient/rest_client/models/entity.py +63 -0
  33. stepxmlclient/rest_client/models/event_processor.py +15 -0
  34. stepxmlclient/rest_client/models/import_export.py +43 -0
  35. stepxmlclient/rest_client/models/integration_endpoint.py +16 -0
  36. stepxmlclient/rest_client/models/product.py +200 -0
  37. stepxmlclient/rest_client/models/relations.py +280 -0
  38. stepxmlclient/rest_client/models/system_information.py +11 -0
  39. stepxmlclient/rest_client/models/user.py +28 -0
  40. stepxmlclient/rest_client/models/workflow.py +30 -0
  41. stepxmlclient/rest_client/operations/__init__.py +54 -0
  42. stepxmlclient/rest_client/operations/assets.py +652 -0
  43. stepxmlclient/rest_client/operations/attributes.py +252 -0
  44. stepxmlclient/rest_client/operations/background_processes.py +84 -0
  45. stepxmlclient/rest_client/operations/batch.py +28 -0
  46. stepxmlclient/rest_client/operations/classifications.py +248 -0
  47. stepxmlclient/rest_client/operations/collection_groups.py +46 -0
  48. stepxmlclient/rest_client/operations/collections.py +67 -0
  49. stepxmlclient/rest_client/operations/contexts.py +88 -0
  50. stepxmlclient/rest_client/operations/data_type_groups.py +68 -0
  51. stepxmlclient/rest_client/operations/entities.py +295 -0
  52. stepxmlclient/rest_client/operations/event_processors.py +109 -0
  53. stepxmlclient/rest_client/operations/exports.py +153 -0
  54. stepxmlclient/rest_client/operations/gateway.py +53 -0
  55. stepxmlclient/rest_client/operations/inbound.py +472 -0
  56. stepxmlclient/rest_client/operations/outbound.py +64 -0
  57. stepxmlclient/rest_client/operations/products.py +489 -0
  58. stepxmlclient/rest_client/operations/relations.py +349 -0
  59. stepxmlclient/rest_client/operations/reports.py +27 -0
  60. stepxmlclient/rest_client/operations/system_information.py +28 -0
  61. stepxmlclient/rest_client/operations/user_groups.py +79 -0
  62. stepxmlclient/rest_client/operations/users.py +119 -0
  63. stepxmlclient/rest_client/operations/workflow_tasks.py +61 -0
  64. stepxmlclient/rest_client/operations/workflows.py +50 -0
  65. stepxmlclient/upload.py +293 -0
  66. stepxmlclient-1.0.0.dist-info/METADATA +666 -0
  67. stepxmlclient-1.0.0.dist-info/RECORD +70 -0
  68. stepxmlclient-1.0.0.dist-info/WHEEL +5 -0
  69. stepxmlclient-1.0.0.dist-info/licenses/LICENSE +21 -0
  70. stepxmlclient-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,67 @@
1
+ """Collection operations for STEP REST API v2."""
2
+
3
+ from typing import Any
4
+
5
+ from ..base import BaseOperation, handle_rest_errors
6
+ from ..exceptions import NotFoundError, ValidationError
7
+ from ..models.collection import CollectionResponse
8
+
9
+
10
+ class CollectionOperations(BaseOperation):
11
+ """Operations for STEP Collections."""
12
+ def __init__(self, client, logger=None, context=None, workspace=None):
13
+ super().__init__(client, operation_name="CollectionOperations", logger=logger, context=context, workspace=workspace)
14
+
15
+ @handle_rest_errors
16
+ def create_collection(self, data: dict[str, Any]) -> CollectionResponse:
17
+ self._log_operation("createCollection", data)
18
+ try:
19
+ r = self.client.createCollection(json=data, **self._build_context_params())
20
+ except Exception as e:
21
+ if "409" in str(e): raise ValidationError(str(e))
22
+ raise
23
+ return CollectionResponse(**r) if isinstance(r, dict) else r
24
+
25
+ @handle_rest_errors
26
+ def get_collection(self, collection_id: str) -> CollectionResponse:
27
+ self._validate_required_params({"collection_id": collection_id}, ["collection_id"])
28
+ self._log_operation("getCollection", {"id": collection_id})
29
+ try:
30
+ r = self.client.getCollection(id=collection_id, **self._build_context_params())
31
+ except Exception as e:
32
+ if "404" in str(e): raise NotFoundError(collection_id, "Collection")
33
+ raise
34
+ return CollectionResponse(**r) if isinstance(r, dict) else r
35
+
36
+ @handle_rest_errors
37
+ def create_or_replace_collection(self, collection_id: str, data: dict[str, Any]) -> CollectionResponse:
38
+ self._validate_required_params({"collection_id": collection_id}, ["collection_id"])
39
+ self._log_operation("createOrReplaceCollection", {"id": collection_id})
40
+ try:
41
+ r = self.client.createOrReplaceCollection(id=collection_id, json=data, **self._build_context_params())
42
+ except Exception as e:
43
+ if "400" in str(e): raise ValidationError(str(e))
44
+ raise
45
+ return CollectionResponse(**r) if isinstance(r, dict) else r
46
+
47
+ @handle_rest_errors
48
+ def delete_collection(self, collection_id: str) -> bool:
49
+ self._validate_required_params({"collection_id": collection_id}, ["collection_id"])
50
+ self._log_operation("deleteCollection", {"id": collection_id})
51
+ try:
52
+ self.client.deleteCollection(id=collection_id, **self._build_context_params())
53
+ return True
54
+ except Exception as e:
55
+ if "404" in str(e): raise NotFoundError(collection_id, "Collection")
56
+ raise
57
+
58
+ @handle_rest_errors
59
+ def get_collection_content(self, collection_id: str) -> CollectionResponse:
60
+ self._validate_required_params({"collection_id": collection_id}, ["collection_id"])
61
+ self._log_operation("getCollectionContent", {"id": collection_id})
62
+ try:
63
+ r = self.client.getCollectionContent(id=collection_id, **self._build_context_params())
64
+ except Exception as e:
65
+ if "404" in str(e): raise NotFoundError(collection_id, "Collection")
66
+ raise
67
+ return CollectionResponse(**r) if isinstance(r, dict) else r
@@ -0,0 +1,88 @@
1
+ """Context operations for STEP REST API v2.
2
+
3
+ Covers the /contexts endpoints introduced in v1.4.0.
4
+ """
5
+
6
+ import logging
7
+ from typing import Any
8
+
9
+ from ..base import BaseOperation, handle_rest_errors
10
+ from ..exceptions import NotFoundError
11
+ from ..models.context import ContextResponse
12
+
13
+
14
+ class ContextOperations(BaseOperation):
15
+ """Operations for STEP Contexts."""
16
+
17
+ def __init__(self, client, logger: logging.Logger | None = None,
18
+ context: str | None = None, workspace: str | None = None):
19
+ super().__init__(client, operation_name="ContextOperations", logger=logger,
20
+ context=context, workspace=workspace)
21
+
22
+ @staticmethod
23
+ def _coerce_context_items(payload: Any) -> list[ContextResponse]:
24
+ """Normalize context list payloads from various response shapes."""
25
+ if payload is None:
26
+ return []
27
+
28
+ if isinstance(payload, list):
29
+ return [ContextResponse(**c) if isinstance(c, dict) else c for c in payload]
30
+
31
+ if isinstance(payload, dict):
32
+ for key in ("items", "data", "results", "contexts"):
33
+ items = payload.get(key)
34
+ if isinstance(items, list):
35
+ return [ContextResponse(**c) if isinstance(c, dict) else c for c in items]
36
+ if "id" in payload:
37
+ return [ContextResponse(**payload)]
38
+ return []
39
+
40
+ if hasattr(payload, "json"):
41
+ try:
42
+ parsed = payload.json()
43
+ except Exception: # noqa: BLE001
44
+ parsed = None
45
+ if parsed is not None:
46
+ return ContextOperations._coerce_context_items(parsed)
47
+
48
+ if hasattr(payload, "text"):
49
+ try:
50
+ import json
51
+ parsed = json.loads(payload.text)
52
+ except Exception: # noqa: BLE001
53
+ parsed = None
54
+ if parsed is not None:
55
+ return ContextOperations._coerce_context_items(parsed)
56
+
57
+ return []
58
+
59
+ @handle_rest_errors
60
+ def get_contexts(self) -> list[ContextResponse]:
61
+ """List all available contexts.
62
+
63
+ Calls: GET /contexts -> getContexts
64
+
65
+ The spec declares the response as ``type: array`` of Context objects.
66
+ Some STEP servers / requests-openapi versions may wrap the array in a
67
+ dict, and some transports may return a ``requests.Response`` object.
68
+ We handle those shapes as well.
69
+ """
70
+ self._log_operation("getContexts", {})
71
+ response = self.client.getContexts(**self._build_context_params())
72
+ return self._coerce_context_items(response)
73
+
74
+ @handle_rest_errors
75
+ def get_context(self, context_id: str) -> ContextResponse:
76
+ """Get a specific context by ID.
77
+
78
+ Calls: GET /contexts/{id} -> getContext
79
+ """
80
+ self._validate_required_params({"context_id": context_id}, ["context_id"])
81
+ self._log_operation("getContext", {"id": context_id})
82
+ try:
83
+ response = self.client.getContext(id=context_id, **self._build_context_params())
84
+ except Exception as e:
85
+ if "404" in str(e):
86
+ raise NotFoundError(context_id, "Context")
87
+ raise
88
+ return ContextResponse(**response) if isinstance(response, dict) else response
@@ -0,0 +1,68 @@
1
+ """Data type group operations for STEP REST API v2."""
2
+
3
+ from typing import Any
4
+
5
+ from ..base import BaseOperation, handle_rest_errors
6
+ from ..exceptions import NotFoundError
7
+ from ..models.data_type_group import DataTypeGroupResponse
8
+
9
+
10
+ class DataTypeGroupOperations(BaseOperation):
11
+ """Operations for STEP Data Type Groups."""
12
+ def __init__(self, client, logger=None, context=None, workspace=None):
13
+ super().__init__(client, operation_name="DataTypeGroupOperations", logger=logger, context=context, workspace=workspace)
14
+
15
+ @handle_rest_errors
16
+ def get_data_type_group(self, group_id: str) -> DataTypeGroupResponse:
17
+ self._validate_required_params({"group_id": group_id}, ["group_id"])
18
+ self._log_operation("getDataTypeGroup", {"id": group_id})
19
+ try:
20
+ r = self.client.getDataTypeGroup(id=group_id, **self._build_context_params())
21
+ except Exception as e:
22
+ if "404" in str(e): raise NotFoundError(group_id, "DataTypeGroup")
23
+ raise
24
+ return DataTypeGroupResponse(**r) if isinstance(r, dict) else r
25
+
26
+ @handle_rest_errors
27
+ def get_data_type_group_children(self, group_id: str) -> list[str]:
28
+ self._validate_required_params({"group_id": group_id}, ["group_id"])
29
+ self._log_operation("getDataTypeGroupChildren", {"id": group_id})
30
+ try:
31
+ r = self.client.getDataTypeGroupChildren(id=group_id, **self._build_context_params())
32
+ except Exception as e:
33
+ if "404" in str(e): raise NotFoundError(group_id, "DataTypeGroup")
34
+ raise
35
+ return r if isinstance(r, list) else []
36
+
37
+ @handle_rest_errors
38
+ def get_data_type_group_attributes(self, group_id: str) -> list[dict[str, Any]]:
39
+ self._validate_required_params({"group_id": group_id}, ["group_id"])
40
+ self._log_operation("getDataTypeGroupAttributes", {"id": group_id})
41
+ try:
42
+ r = self.client.getDataTypeGroupAttributes(id=group_id, **self._build_context_params())
43
+ except Exception as e:
44
+ if "404" in str(e): raise NotFoundError(group_id, "DataTypeGroup")
45
+ raise
46
+ return r if isinstance(r, list) else []
47
+
48
+ @handle_rest_errors
49
+ def get_data_type_group_data_container_types(self, group_id: str) -> list[dict[str, Any]]:
50
+ self._validate_required_params({"group_id": group_id}, ["group_id"])
51
+ self._log_operation("getDataTypeGroupDataContainerTypes", {"id": group_id})
52
+ try:
53
+ r = self.client.getDataTypeGroupDataContainerTypes(id=group_id, **self._build_context_params())
54
+ except Exception as e:
55
+ if "404" in str(e): raise NotFoundError(group_id, "DataTypeGroup")
56
+ raise
57
+ return r if isinstance(r, list) else []
58
+
59
+ @handle_rest_errors
60
+ def get_data_type_group_reference_types(self, group_id: str) -> list[dict[str, Any]]:
61
+ self._validate_required_params({"group_id": group_id}, ["group_id"])
62
+ self._log_operation("getDataTypeGroupReferenceTypes", {"id": group_id})
63
+ try:
64
+ r = self.client.getDataTypeGroupReferenceTypes(id=group_id, **self._build_context_params())
65
+ except Exception as e:
66
+ if "404" in str(e): raise NotFoundError(group_id, "DataTypeGroup")
67
+ raise
68
+ return r if isinstance(r, list) else []
@@ -0,0 +1,295 @@
1
+ """Entity operations for STEP REST API v2."""
2
+
3
+ import logging
4
+ from typing import Any, Optional
5
+
6
+ from ..base import BaseOperation, handle_rest_errors
7
+ from ..exceptions import NotFoundError, ValidationError
8
+ from ..models.entity import (
9
+ EntityListResponse,
10
+ EntityResponse,
11
+ )
12
+
13
+
14
+ class EntityOperations(BaseOperation):
15
+ """Operations for STEP Entities."""
16
+
17
+ def __init__(self, client, logger: Optional[logging.Logger] = None,
18
+ context: str | None = None, workspace: str | None = None):
19
+ """Initialize entity operations.
20
+
21
+ Args:
22
+ client: The REST API client
23
+ logger: Optional logger instance
24
+ context: STEP context ID for all API calls
25
+ workspace: STEP workspace ID (defaults to "Main" server-side)
26
+ """
27
+ super().__init__(client, operation_name="EntityOperations", logger=logger,
28
+ context=context, workspace=workspace)
29
+
30
+ @handle_rest_errors
31
+ def get_entity(self, entity_id: str,
32
+ key_id: str | None = None,
33
+ include_inherited_data: bool = False) -> EntityResponse:
34
+ """Get a single entity by ID.
35
+
36
+ Args:
37
+ entity_id: The entity ID (or alternate key value if key_id is set)
38
+ key_id: Alternate key ID to use for lookup (optional)
39
+ include_inherited_data: Whether to include inherited attribute values (default: False)
40
+
41
+ Returns:
42
+ EntityResponse with entity data
43
+
44
+ Raises:
45
+ ValidationError: If entity_id is missing
46
+ NotFoundError: If entity not found
47
+ RestApiError: For other API errors
48
+ """
49
+ self._validate_required_params(
50
+ {"entity_id": entity_id},
51
+ ["entity_id"]
52
+ )
53
+
54
+ query_params = self._build_context_params()
55
+ if key_id:
56
+ query_params["keyId"] = key_id
57
+ if include_inherited_data:
58
+ query_params["includeInheritedData"] = include_inherited_data
59
+ self._log_operation("getEntity", {"entity_id": entity_id})
60
+
61
+ try:
62
+ response = self.client.getEntity(id=entity_id, **query_params)
63
+ except Exception as e:
64
+ if "404" in str(e):
65
+ raise NotFoundError(entity_id, "Entity")
66
+ raise
67
+
68
+ if isinstance(response, dict):
69
+ return EntityResponse(**response)
70
+ return response
71
+
72
+ @handle_rest_errors
73
+ def search_entities(self, condition: dict) -> EntityListResponse:
74
+ """Search entities using a STEP condition query.
75
+
76
+ Args:
77
+ condition: A STEP condition object defining the search criteria.
78
+ Supported conditionTypes: 'and', 'or', 'id', 'name',
79
+ 'textvalue', 'numericvalue', 'objecttype', 'simplebelow',
80
+ 'lovvalue', 'hasreferenceto', 'hasdatacontainerobject'.
81
+
82
+ Returns:
83
+ EntityListResponse with matching entities
84
+
85
+ Raises:
86
+ ValidationError: If condition is invalid
87
+ RestApiError: For API errors
88
+ """
89
+ self._validate_required_params({"condition": condition}, ["condition"])
90
+ body = {"condition": condition}
91
+ self._log_operation("createEntitySearch", {"condition": condition})
92
+
93
+ response = self.client.createEntitySearch(json=body, **self._build_context_params())
94
+
95
+ if isinstance(response, dict):
96
+ return EntityListResponse(**response)
97
+ return response
98
+
99
+ def search_by_type(self, entity_type: str,
100
+ limit: int = 20, offset: int = 0) -> EntityListResponse:
101
+ """Convenience method to search entities by type.
102
+
103
+ Args:
104
+ entity_type: The entity type to filter by
105
+ limit: Result limit
106
+ offset: Result offset
107
+
108
+ Returns:
109
+ EntityListResponse filtered by type
110
+ """
111
+ return self.search_entities(
112
+ condition={"conditionType": "objecttype", "objectType": entity_type}
113
+ )
114
+
115
+
116
+ @handle_rest_errors
117
+ def find_similar_entities(self, entity_id: str,
118
+ key_id: str | None = None) -> dict[str, Any]:
119
+ self._validate_required_params({"entity_id": entity_id}, ["entity_id"])
120
+ qp = self._build_context_params()
121
+ if key_id: qp["keyId"] = key_id
122
+ self._log_operation("findSimilarEntities", {"id": entity_id})
123
+ try:
124
+ r = self.client.findSimilarEntities(id=entity_id, **qp)
125
+ except Exception as e:
126
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
127
+ raise
128
+ return r if isinstance(r, dict) else r
129
+
130
+ @handle_rest_errors
131
+ def entity_match_and_merge(self, data: dict[str, Any]) -> dict[str, Any]:
132
+ self._validate_required_params({"data": data}, ["data"])
133
+ self._log_operation("entityMatchAndMerge", data)
134
+ try:
135
+ r = self.client.entityMatchAndMerge(json=data, **self._build_context_params())
136
+ except Exception as e:
137
+ if "400" in str(e): raise ValidationError(str(e))
138
+ raise
139
+ return r if isinstance(r, dict) else r
140
+
141
+ @handle_rest_errors
142
+ def get_entity_approval_status(self, entity_id: str,
143
+ key_id: str | None = None) -> dict[str, Any]:
144
+ self._validate_required_params({"entity_id": entity_id}, ["entity_id"])
145
+ qp = self._build_context_params()
146
+ if key_id: qp["keyId"] = key_id
147
+ self._log_operation("getEntityApprovalStatus", {"id": entity_id})
148
+ try:
149
+ r = self.client.getEntityApprovalStatus(id=entity_id, **qp)
150
+ except Exception as e:
151
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
152
+ raise
153
+ return r if isinstance(r, dict) else r
154
+
155
+ @handle_rest_errors
156
+ def approve_entity(self, entity_id: str,
157
+ key_id: str | None = None) -> dict[str, Any]:
158
+ self._validate_required_params({"entity_id": entity_id}, ["entity_id"])
159
+ qp = self._build_context_params()
160
+ if key_id: qp["keyId"] = key_id
161
+ self._log_operation("approveEntity", {"id": entity_id})
162
+ try:
163
+ r = self.client.approveEntity(id=entity_id, **qp)
164
+ except Exception as e:
165
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
166
+ raise
167
+ return r if isinstance(r, dict) else r
168
+
169
+ @handle_rest_errors
170
+ def approve_entity_deletion(self, entity_id: str,
171
+ key_id: str | None = None) -> dict[str, Any]:
172
+ self._validate_required_params({"entity_id": entity_id}, ["entity_id"])
173
+ qp = self._build_context_params()
174
+ if key_id: qp["keyId"] = key_id
175
+ self._log_operation("approveEntityDeletion", {"id": entity_id})
176
+ try:
177
+ r = self.client.approveEntityDeletion(id=entity_id, **qp)
178
+ except Exception as e:
179
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
180
+ raise
181
+ return r if isinstance(r, dict) else r
182
+
183
+ @handle_rest_errors
184
+ def purge_entity(self, entity_id: str,
185
+ key_id: str | None = None) -> dict[str, Any]:
186
+ self._validate_required_params({"entity_id": entity_id}, ["entity_id"])
187
+ qp = self._build_context_params()
188
+ if key_id: qp["keyId"] = key_id
189
+ self._log_operation("purgeEntity", {"id": entity_id})
190
+ try:
191
+ r = self.client.purgeEntity(id=entity_id, **qp)
192
+ except Exception as e:
193
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
194
+ raise
195
+ return r if isinstance(r, dict) else r
196
+
197
+ @handle_rest_errors
198
+ def get_entity_children(self, entity_id: str,
199
+ key_id: str | None = None) -> list[str]:
200
+ self._validate_required_params({"entity_id": entity_id}, ["entity_id"])
201
+ qp = self._build_context_params()
202
+ if key_id: qp["keyId"] = key_id
203
+ self._log_operation("getEntityChildren", {"id": entity_id})
204
+ try:
205
+ r = self.client.getEntityChildren(id=entity_id, **qp)
206
+ except Exception as e:
207
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
208
+ raise
209
+ return r if isinstance(r, list) else []
210
+
211
+ @handle_rest_errors
212
+ def get_entity_data_containers(self, entity_id: str,
213
+ key_id: str | None = None) -> dict[str, Any]:
214
+ self._validate_required_params({"entity_id": entity_id}, ["entity_id"])
215
+ qp = self._build_context_params()
216
+ if key_id: qp["keyId"] = key_id
217
+ self._log_operation("getEntityDataContainers", {"id": entity_id})
218
+ try:
219
+ r = self.client.getEntityDataContainers(id=entity_id, **qp)
220
+ except Exception as e:
221
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
222
+ raise
223
+ return r if isinstance(r, dict) else r
224
+
225
+ @handle_rest_errors
226
+ def get_entity_incoming_references(self, entity_id: str,
227
+ key_id: str | None = None) -> dict[str, Any]:
228
+ self._validate_required_params({"entity_id": entity_id}, ["entity_id"])
229
+ qp = self._build_context_params()
230
+ if key_id: qp["keyId"] = key_id
231
+ self._log_operation("getEntityIncomingReferences", {"id": entity_id})
232
+ try:
233
+ r = self.client.getEntityIncomingReferences(id=entity_id, **qp)
234
+ except Exception as e:
235
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
236
+ raise
237
+ return r if isinstance(r, dict) else r
238
+
239
+ @handle_rest_errors
240
+ def get_entity_value(self, entity_id: str, attribute_id: str,
241
+ key_id: str | None = None) -> dict[str, Any]:
242
+ self._validate_required_params(
243
+ {"entity_id": entity_id, "attribute_id": attribute_id},
244
+ ["entity_id", "attribute_id"])
245
+ qp = self._build_context_params()
246
+ if key_id: qp["keyId"] = key_id
247
+ self._log_operation("getEntityValueByAttributeId",
248
+ {"id": entity_id, "attributeId": attribute_id})
249
+ try:
250
+ r = self.client.getEntityValueByAttributeId(
251
+ id=entity_id, attributeId=attribute_id, **qp)
252
+ except Exception as e:
253
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
254
+ raise
255
+ return r if isinstance(r, dict) else r
256
+
257
+ @handle_rest_errors
258
+ def replace_entity_value(self, entity_id: str, attribute_id: str,
259
+ value: dict[str, Any],
260
+ key_id: str | None = None) -> dict[str, Any]:
261
+ self._validate_required_params(
262
+ {"entity_id": entity_id, "attribute_id": attribute_id},
263
+ ["entity_id", "attribute_id"])
264
+ qp = self._build_context_params()
265
+ if key_id: qp["keyId"] = key_id
266
+ self._log_operation("replaceEntityValueByAttributeId",
267
+ {"id": entity_id, "attributeId": attribute_id})
268
+ try:
269
+ r = self.client.replaceEntityValueByAttributeId(
270
+ id=entity_id, attributeId=attribute_id, json=value, **qp)
271
+ except Exception as e:
272
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
273
+ if "400" in str(e): raise ValidationError(str(e))
274
+ raise
275
+ return r if isinstance(r, dict) else r
276
+
277
+ @handle_rest_errors
278
+ def delete_entity_value(self, entity_id: str, attribute_id: str,
279
+ key_id: str | None = None) -> bool:
280
+ self._validate_required_params(
281
+ {"entity_id": entity_id, "attribute_id": attribute_id},
282
+ ["entity_id", "attribute_id"])
283
+ qp = self._build_context_params()
284
+ if key_id: qp["keyId"] = key_id
285
+ self._log_operation("deleteEntityValueByAttributeId",
286
+ {"id": entity_id, "attributeId": attribute_id})
287
+ try:
288
+ self.client.deleteEntityValueByAttributeId(
289
+ id=entity_id, attributeId=attribute_id, **qp)
290
+ return True
291
+ except Exception as e:
292
+ if "404" in str(e): raise NotFoundError(entity_id, "Entity")
293
+ raise
294
+
295
+
@@ -0,0 +1,109 @@
1
+ """Event processor operations for STEP REST API v2."""
2
+
3
+ from typing import Any
4
+
5
+ from ..base import BaseOperation, handle_rest_errors
6
+ from ..exceptions import NotFoundError
7
+ from ..models.event_processor import EventProcessorResponse
8
+
9
+
10
+ class EventProcessorOperations(BaseOperation):
11
+ def __init__(self, client, logger=None, context=None, workspace=None):
12
+ super().__init__(client, operation_name="EventProcessorOperations", logger=logger, context=context, workspace=workspace)
13
+
14
+ @handle_rest_errors
15
+ def get_event_processors(self) -> list[dict[str, Any]]:
16
+ self._log_operation("getEventProcessors", {})
17
+ r = self.client.getEventProcessors(**self._build_context_params())
18
+ return r if isinstance(r, list) else []
19
+
20
+ @handle_rest_errors
21
+ def get_event_processor(self, ep_id: str) -> EventProcessorResponse:
22
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
23
+ self._log_operation("getEventProcessor", {"id": ep_id})
24
+ try:
25
+ r = self.client.getEventProcessor(id=ep_id, **self._build_context_params())
26
+ except Exception as e:
27
+ if "404" in str(e): raise NotFoundError(ep_id, "EventProcessor")
28
+ raise
29
+ return EventProcessorResponse(**r) if isinstance(r, dict) else r
30
+
31
+ @handle_rest_errors
32
+ def get_event_processor_status(self, ep_id: str) -> EventProcessorResponse:
33
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
34
+ self._log_operation("getEventProcessorStatus", {"id": ep_id})
35
+ try:
36
+ r = self.client.getEventProcessorStatus(id=ep_id, **self._build_context_params())
37
+ except Exception as e:
38
+ if "404" in str(e): raise NotFoundError(ep_id, "EventProcessor")
39
+ raise
40
+ return EventProcessorResponse(**r) if isinstance(r, dict) else r
41
+
42
+ @handle_rest_errors
43
+ def get_event_processor_execution_report(self, ep_id: str) -> list[dict[str, Any]]:
44
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
45
+ self._log_operation("getEventProcessorExecutionReport", {"id": ep_id})
46
+ try:
47
+ r = self.client.getEventProcessorExecutionReport(id=ep_id, **self._build_context_params())
48
+ except Exception as e:
49
+ if "404" in str(e): raise NotFoundError(ep_id, "EventProcessor")
50
+ raise
51
+ return r if isinstance(r, list) else []
52
+
53
+ @handle_rest_errors
54
+ def enable_event_processor(self, ep_id: str) -> EventProcessorResponse:
55
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
56
+ self._log_operation("enableEventProcessor", {"id": ep_id})
57
+ r = self.client.enableEventProcessor(id=ep_id, **self._build_context_params())
58
+ return EventProcessorResponse(**r) if isinstance(r, dict) else r
59
+
60
+ @handle_rest_errors
61
+ def disable_event_processor(self, ep_id: str) -> EventProcessorResponse:
62
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
63
+ self._log_operation("disableEventProcessor", {"id": ep_id})
64
+ r = self.client.disableEventProcessor(id=ep_id, **self._build_context_params())
65
+ return EventProcessorResponse(**r) if isinstance(r, dict) else r
66
+
67
+ @handle_rest_errors
68
+ def invoke_event_processor(self, ep_id: str, data: dict[str, Any] | None = None) -> EventProcessorResponse:
69
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
70
+ self._log_operation("invokeEventProcessor", {"id": ep_id})
71
+ kwargs = {"id": ep_id, **self._build_context_params()}
72
+ if data: kwargs["json"] = data
73
+ r = self.client.invokeEventProcessor(**kwargs)
74
+ return EventProcessorResponse(**r) if isinstance(r, dict) else r
75
+
76
+ @handle_rest_errors
77
+ def get_event_queue_status(self, ep_id: str) -> EventProcessorResponse:
78
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
79
+ self._log_operation("getEventProcessorEventQueueStatus", {"id": ep_id})
80
+ r = self.client.getEventProcessorEventQueueStatus(id=ep_id, **self._build_context_params())
81
+ return EventProcessorResponse(**r) if isinstance(r, dict) else r
82
+
83
+ @handle_rest_errors
84
+ def get_event_queue_unread_count(self, ep_id: str) -> EventProcessorResponse:
85
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
86
+ self._log_operation("getEventProcessorNumberOfUnreadEventsInEventQueue", {"id": ep_id})
87
+ r = self.client.getEventProcessorNumberOfUnreadEventsInEventQueue(id=ep_id, **self._build_context_params())
88
+ return EventProcessorResponse(**r) if isinstance(r, dict) else r
89
+
90
+ @handle_rest_errors
91
+ def enable_event_queue(self, ep_id: str) -> EventProcessorResponse:
92
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
93
+ self._log_operation("enableEventQueue", {"id": ep_id})
94
+ r = self.client.enableEventQueue(id=ep_id, **self._build_context_params())
95
+ return EventProcessorResponse(**r) if isinstance(r, dict) else r
96
+
97
+ @handle_rest_errors
98
+ def disable_event_queue(self, ep_id: str) -> EventProcessorResponse:
99
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
100
+ self._log_operation("disableEventQueue", {"id": ep_id})
101
+ r = self.client.disableEventQueue(id=ep_id, **self._build_context_params())
102
+ return EventProcessorResponse(**r) if isinstance(r, dict) else r
103
+
104
+ @handle_rest_errors
105
+ def get_event_processor_statistics(self, ep_id: str) -> EventProcessorResponse:
106
+ self._validate_required_params({"ep_id": ep_id}, ["ep_id"])
107
+ self._log_operation("getEventProcessorStatistics", {"id": ep_id})
108
+ r = self.client.getEventProcessorStatistics(id=ep_id, **self._build_context_params())
109
+ return EventProcessorResponse(**r) if isinstance(r, dict) else r