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

Commit f8ee0d3

Browse files
[client] Move merge function from stixCore to stix
1 parent 2103f57 commit f8ee0d3

File tree

2 files changed

+49
-49
lines changed

2 files changed

+49
-49
lines changed

pycti/entities/opencti_stix.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,52 @@ def delete(self, **kwargs):
2727
else:
2828
self.opencti.log("error", "[opencti_stix] Missing parameters: id")
2929
return None
30+
31+
"""
32+
Merge a Stix-Object object field
33+
34+
:param id: the Stix-Object id
35+
:param key: the key of the field
36+
:param value: the value of the field
37+
:return The updated Stix-Object object
38+
"""
39+
40+
def merge(self, **kwargs):
41+
id = kwargs.get("id", None)
42+
stix_objects_ids = kwargs.get("object_ids", None)
43+
if id is not None and stix_objects_ids is not None:
44+
self.opencti.log(
45+
"info",
46+
"Merging Stix object {"
47+
+ id
48+
+ "} with {"
49+
+ ",".join(stix_objects_ids)
50+
+ "}.",
51+
)
52+
query = """
53+
mutation StixEdit($id: ID!, $stixObjectsIds: [String]!) {
54+
stixEdit(id: $id) {
55+
merge(stixObjectsIds: $stixObjectsIds) {
56+
id
57+
standard_id
58+
entity_type
59+
}
60+
}
61+
}
62+
"""
63+
result = self.opencti.query(
64+
query,
65+
{
66+
"id": id,
67+
"stixObjectsIds": stix_objects_ids,
68+
},
69+
)
70+
return self.opencti.process_multiple_fields(
71+
result["data"]["stixEdit"]["merge"]
72+
)
73+
else:
74+
self.opencti.log(
75+
"error",
76+
"[opencti_stix] Missing parameters: id and object_ids",
77+
)
78+
return None

pycti/entities/opencti_stix_core_object.py

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -660,55 +660,6 @@ def list(self, **kwargs):
660660
result["data"]["stixCoreObjects"], with_pagination
661661
)
662662

663-
"""
664-
Update a Stix-Domain-Object object field
665-
666-
:param id: the Stix-Domain-Object id
667-
:param key: the key of the field
668-
:param value: the value of the field
669-
:return The updated Stix-Domain-Object object
670-
"""
671-
672-
def merge(self, **kwargs):
673-
id = kwargs.get("id", None)
674-
stix_core_objects_ids = kwargs.get("object_ids", None)
675-
if id is not None and stix_core_objects_ids is not None:
676-
self.opencti.log(
677-
"info",
678-
"Merging Core object {"
679-
+ id
680-
+ "} with {"
681-
+ ",".join(stix_core_objects_ids)
682-
+ "}.",
683-
)
684-
query = """
685-
mutation StixCoreObjectEdit($id: ID!, $stixCoreObjectsIds: [String]!) {
686-
stixCoreObjectEdit(id: $id) {
687-
merge(stixCoreObjectsIds: $stixCoreObjectsIds) {
688-
id
689-
standard_id
690-
entity_type
691-
}
692-
}
693-
}
694-
"""
695-
result = self.opencti.query(
696-
query,
697-
{
698-
"id": id,
699-
"stixCoreObjectsIds": stix_core_objects_ids,
700-
},
701-
)
702-
return self.opencti.process_multiple_fields(
703-
result["data"]["stixCoreObjectEdit"]["merge"]
704-
)
705-
else:
706-
self.opencti.log(
707-
"error",
708-
"[opencti_stix_core_object] Missing parameters: id and object_ids",
709-
)
710-
return None
711-
712663
def list_files(self, **kwargs):
713664
id = kwargs.get("id", None)
714665
self.opencti.log(

0 commit comments

Comments
 (0)