Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit a78975b

Browse files
[client] add draft context to work when sending bundle in draft (opencti #6577)
1 parent 711f3a9 commit a78975b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pycti/api/opencti_api_work.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ def add_expectations(self, work_id: str, expectations: int):
8282
except:
8383
self.api.app_logger.error("Cannot report expectation")
8484

85+
def add_draft_context(self, work_id: str, draft_context: str):
86+
if self.api.bundle_send_to_queue:
87+
self.api.app_logger.info(
88+
"Update draft context",
89+
{"work_id": work_id, "draft_context": draft_context},
90+
)
91+
query = """
92+
mutation addDraftContext($id: ID!, $draftContext: String) {
93+
workEdit(id: $id) {
94+
addDraftContext(draftContext: $draftContext)
95+
}
96+
}
97+
"""
98+
try:
99+
self.api.query(query, {"id": work_id, "draftContext": draft_context})
100+
except:
101+
self.api.app_logger.error("Cannot report draft context")
102+
85103
def initiate_work(self, connector_id: str, friendly_name: str) -> str:
86104
if self.api.bundle_send_to_queue:
87105
self.api.app_logger.info("Initiate work", {"connector_id": connector_id})

pycti/connector/opencti_connector_helper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,8 @@ def send_stix2_bundle(self, bundle: str, **kwargs) -> list:
17321732
if bundle_send_to_queue:
17331733
if work_id:
17341734
self.api.work.add_expectations(work_id, expectations_number)
1735+
if draft_id:
1736+
self.api.work.add_draft_context(work_id, draft_id)
17351737
if entities_types is None:
17361738
entities_types = []
17371739
if self.queue_protocol == "amqp":

0 commit comments

Comments
 (0)