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

Commit 48b2cb4

Browse files
committed
[client-python] WIP PIR api
1 parent d112b34 commit 48b2cb4

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

pycti/api/opencti_api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import requests
1010

1111
from pycti import __version__
12+
from pycti.api.opencti_api_pir import OpenCTIApiPir
1213
from pycti.api.opencti_api_connector import OpenCTIApiConnector
1314
from pycti.api.opencti_api_playbook import OpenCTIApiPlaybook
1415
from pycti.api.opencti_api_work import OpenCTIApiWork
@@ -170,6 +171,7 @@ def __init__(
170171
self.playbook = OpenCTIApiPlaybook(self)
171172
self.connector = OpenCTIApiConnector(self)
172173
self.stix2 = OpenCTIStix2(self)
174+
self.pir = OpenCTIApiPir(self)
173175

174176
# Define the entities
175177
self.vocabulary = Vocabulary(self)

pycti/api/opencti_api_pir.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
class OpenCTIApiPir:
2+
"""OpenCTIApiPir"""
3+
4+
def __init__(self, api):
5+
self.api = api
6+
7+
def add_pir_dependency(self, **kwargs):
8+
id = kwargs.get("id", None)
9+
input = kwargs.get("input", None)
10+
query = """
11+
mutation PirAddDependency($id: ID!, $input: PirAddDependencyInput!) {
12+
pirAddDependency(id: $id, input: $input)
13+
}
14+
"""
15+
self.api.query(
16+
query,
17+
{
18+
"id": id,
19+
"input": input,
20+
},
21+
)
22+
23+
def delete_pir_dependency(self, **kwargs):
24+
id = kwargs.get("id", None)
25+
input = kwargs.get("input", None)
26+
query = """
27+
mutation PirDeleteDependency($id: ID!, $input: PirDeleteDependencyInput!) {
28+
pirDeleteDependency(id: $id, input: $input)
29+
}
30+
"""
31+
self.api.query(
32+
query,
33+
{
34+
"id": id,
35+
"input": input,
36+
},
37+
)

pycti/utils/opencti_stix2.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,14 @@ def apply_opencti_operation(self, item, operation):
24842484
self.opencti.stix.merge(id=target_id, object_ids=source_ids)
24852485
elif operation == "patch":
24862486
self.apply_patch(item=item)
2487+
elif operation == "add_pir_dependency":
2488+
id = item["id"]
2489+
input = item["input"]
2490+
self.opencti.pir.add_pir_dependency(id=id, input=input)
2491+
elif operation == "delete_pir_dependency":
2492+
id = item["id"]
2493+
input = item["input"]
2494+
self.opencti.pir.delete_pir_dependency(id=id, input=input)
24872495
else:
24882496
raise ValueError("Not supported opencti_operation")
24892497

0 commit comments

Comments
 (0)