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

Commit 3e4cfff

Browse files
authored
[client] Modularization of relation refs (#347)
1 parent 65a6f17 commit 3e4cfff

21 files changed

+103
-82
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ $ git push origin [branch-name]
4444
# Open a pull request
4545
```
4646

47+
### Install the package locally
48+
49+
```bash
50+
$ pip install -e .
51+
```
52+
4753
## Documentation
4854

4955
### Client usage

docs/pycti/pycti.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Classes
6868
- :py:class:`StixSightingRelationship`:
6969
Undocumented.
7070

71-
- :py:class:`StixCyberObservableRelation`:
71+
- :py:class:`StixNestedRefRelationship`:
7272
Undocumented.
7373

7474
- :py:class:`Identity`:
@@ -246,11 +246,11 @@ Classes
246246
.. inheritance-diagram:: StixSightingRelationship
247247
:parts: 1
248248

249-
.. autoclass:: StixCyberObservableRelation
249+
.. autoclass:: StixNestedRefRelationship
250250
:members:
251251

252252
.. rubric:: Inheritance
253-
.. inheritance-diagram:: StixCyberObservableRelation
253+
.. inheritance-diagram:: StixNestedRefRelationship
254254
:parts: 1
255255

256256
.. autoclass:: Identity

examples/create_ip_domain_resolution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
}
2424
)
2525

26-
opencti_api_client.stix_cyber_observable_relationship.create(
26+
opencti_api_client.stix_nested_ref_relationship.create(
2727
fromId=observable_domain["id"],
2828
toId=observable_ip["id"],
2929
relationship_type="resolves-to",
3030
)
3131

32-
relationships = opencti_api_client.stix_cyber_observable_relationship.list(
32+
relationships = opencti_api_client.stix_nested_ref_relationship.list(
3333
elementId=observable_domain["id"]
3434
)
3535

pycti/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@
3434
from .entities.opencti_report import Report
3535
from .entities.opencti_stix_core_relationship import StixCoreRelationship
3636
from .entities.opencti_stix_cyber_observable import StixCyberObservable
37-
from .entities.opencti_stix_cyber_observable_relationship import (
38-
StixCyberObservableRelationship,
39-
)
4037
from .entities.opencti_stix_domain_object import StixDomainObject
38+
from .entities.opencti_stix_nested_ref_relationship import StixNestedRefRelationship
4139
from .entities.opencti_stix_object_or_stix_relationship import (
4240
StixObjectOrStixRelationship,
4341
)
@@ -46,7 +44,7 @@
4644
from .entities.opencti_tool import Tool
4745
from .entities.opencti_vulnerability import Vulnerability
4846
from .utils.constants import (
49-
MultipleStixCyberObservableRelationship,
47+
MultipleRefRelationship,
5048
StixCyberObservableTypes,
5149
StixMetaTypes,
5250
)
@@ -91,11 +89,11 @@
9189
"Report",
9290
"StixCoreRelationship",
9391
"StixCyberObservable",
94-
"StixCyberObservableRelationship",
92+
"StixNestedRefRelationship",
9593
"StixCyberObservableTypes",
9694
"StixDomainObject",
9795
"StixMetaTypes",
98-
"MultipleStixCyberObservableRelationship",
96+
"MultipleRefRelationship",
9997
"StixObjectOrStixRelationship",
10098
"StixSightingRelationship",
10199
"ThreatActor",

pycti/api/opencti_api_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
from pycti.entities.opencti_stix_core_object import StixCoreObject
4646
from pycti.entities.opencti_stix_core_relationship import StixCoreRelationship
4747
from pycti.entities.opencti_stix_cyber_observable import StixCyberObservable
48-
from pycti.entities.opencti_stix_cyber_observable_relationship import (
49-
StixCyberObservableRelationship,
50-
)
5148
from pycti.entities.opencti_stix_domain_object import StixDomainObject
49+
from pycti.entities.opencti_stix_nested_ref_relationship import (
50+
StixNestedRefRelationship,
51+
)
5252
from pycti.entities.opencti_stix_object_or_stix_relationship import (
5353
StixObjectOrStixRelationship,
5454
)
@@ -166,7 +166,7 @@ def __init__(
166166
self.stix_cyber_observable = StixCyberObservable(self, File)
167167
self.stix_core_relationship = StixCoreRelationship(self)
168168
self.stix_sighting_relationship = StixSightingRelationship(self)
169-
self.stix_cyber_observable_relationship = StixCyberObservableRelationship(self)
169+
self.stix_nested_ref_relationship = StixNestedRefRelationship(self)
170170
self.identity = Identity(self)
171171
self.event = Event(self)
172172
self.location = Location(self)

pycti/entities/opencti_case_incident.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def add_stix_object_or_stix_relationship(self, **kwargs):
537537
+ "}",
538538
)
539539
query = """
540-
mutation CaseIncidentEditRelationAdd($id: ID!, $input: StixMetaRelationshipAddInput!) {
540+
mutation CaseIncidentEditRelationAdd($id: ID!, $input: StixRefRelationshipAddInput!) {
541541
caseIncidentRelationAdd(id: $id, input: $input) {
542542
id
543543
}

pycti/entities/opencti_feedback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def add_stix_object_or_stix_relationship(self, **kwargs):
554554
+ "}",
555555
)
556556
query = """
557-
mutation FeedbackEditRelationAdd($id: ID!, $input: StixMetaRelationshipAddInput!) {
557+
mutation FeedbackEditRelationAdd($id: ID!, $input: StixRefRelationshipAddInput!) {
558558
feedbackRelationAdd(id: $id, input: $input) {
559559
id
560560
}

pycti/entities/opencti_grouping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def add_stix_object_or_stix_relationship(self, **kwargs):
503503
*(stix_object_or_stix_relationship_id, id),
504504
)
505505
query = """
506-
mutation GroupingEditRelationAdd($id: ID!, $input: StixMetaRelationshipAddInput) {
506+
mutation GroupingEditRelationAdd($id: ID!, $input: StixRefRelationshipAddInput!) {
507507
groupingRelationAdd(id: $id, input: $input) {
508508
id
509509
}

pycti/entities/opencti_note.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def add_stix_object_or_stix_relationship(self, **kwargs):
495495
*(stix_object_or_stix_relationship_id, id),
496496
)
497497
query = """
498-
mutation NoteEdit($id: ID!, $input: StixMetaRelationshipAddInput) {
498+
mutation NoteEdit($id: ID!, $input: StixRefRelationshipAddInput!) {
499499
noteEdit(id: $id) {
500500
relationAdd(input: $input) {
501501
id

pycti/entities/opencti_observed_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def __init__(self, opencti):
209209
}
210210
... on Case {
211211
name
212-
}
212+
}
213213
... on StixCoreRelationship {
214214
standard_id
215215
spec_version
@@ -471,7 +471,7 @@ def add_stix_object_or_stix_relationship(self, **kwargs):
471471
*(stix_object_or_stix_relationship_id, id),
472472
)
473473
query = """
474-
mutation ObservedDataEdit($id: ID!, $input: StixMetaRelationshipAddInput) {
474+
mutation ObservedDataEdit($id: ID!, $input: StixRefRelationshipAddInput!) {
475475
observedDataEdit(id: $id) {
476476
relationAdd(input: $input) {
477477
id

0 commit comments

Comments
 (0)