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

Commit 073609f

Browse files
[client] Introduce api protocol helper for listening connectors (#850)
1 parent ac40fc8 commit 073609f

File tree

5 files changed

+229
-52
lines changed

5 files changed

+229
-52
lines changed

pycti/api/opencti_api_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,20 +751,21 @@ def send_bundle_to_api(self, **kwargs):
751751
"""
752752

753753
connector_id = kwargs.get("connector_id", None)
754+
work_id = kwargs.get("work_id", None)
754755
bundle = kwargs.get("bundle", None)
755756

756757
if connector_id is not None and bundle is not None:
757758
self.app_logger.info(
758759
"Pushing a bundle to queue through API", {connector_id}
759760
)
760761
mutation = """
761-
mutation StixBundlePush($connectorId: String!, $bundle: String!) {
762-
stixBundlePush(connectorId: $connectorId, bundle: $bundle)
762+
mutation StixBundlePush($connectorId: String!, $bundle: String!, $work_id: String) {
763+
stixBundlePush(connectorId: $connectorId, bundle: $bundle, work_id: $work_id)
763764
}
764765
"""
765766
return self.query(
766767
mutation,
767-
{"connectorId": connector_id, "bundle": bundle},
768+
{"connectorId": connector_id, "bundle": bundle, "work_id": work_id},
768769
)
769770
else:
770771
self.app_logger.error(

pycti/api/opencti_api_connector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def list(self) -> Dict:
7272
}
7373
listen
7474
listen_exchange
75+
listen_callback_uri
7576
push
7677
push_exchange
7778
push_routing

pycti/connector/opencti_connector.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def __init__(
4343
auto: bool,
4444
only_contextual: bool,
4545
playbook_compatible: bool,
46+
listen_callback_uri=None,
4647
):
4748
self.id = connector_id
4849
self.name = connector_name
@@ -56,6 +57,7 @@ def __init__(
5657
self.auto = auto
5758
self.only_contextual = only_contextual
5859
self.playbook_compatible = playbook_compatible
60+
self.listen_callback_uri = listen_callback_uri
5961

6062
def to_input(self) -> dict:
6163
"""connector input to use in API query
@@ -72,5 +74,6 @@ def to_input(self) -> dict:
7274
"auto": self.auto,
7375
"only_contextual": self.only_contextual,
7476
"playbook_compatible": self.playbook_compatible,
77+
"listen_callback_uri": self.listen_callback_uri,
7578
}
7679
}

0 commit comments

Comments
 (0)