11# coding: utf-8
22
33
4- class StixCyberObservableRelation :
4+ class StixCyberObservableRelationship :
55 def __init__ (self , opencti ):
66 self .opencti = opencti
77 self .properties = """
88 id
9- stix_id
109 entity_type
10+ parent_types
11+ spec_version
12+ created_at
13+ updated_at
14+ standard_id
1115 relationship_type
12- description
13- weight
14- role_played
15- first_seen
16- last_seen
16+ start_time
17+ stop_time
18+ revoked
19+ confidence
20+ lang
1721 created
1822 modified
19- created_at
20- updated_at
2123 from {
2224 id
23- stix_id
25+ standard_id
2426 entity_type
27+ parent_types
2528 observable_value
2629 }
2730 to {
2831 id
29- stix_id
32+ standard_id
3033 entity_type
34+ parent_types
3135 observable_value
3236 }
33- createdBy {
34- node {
37+ createdBy {
38+ ... on Identity {
3539 id
40+ standard_id
3641 entity_type
37- stix_id
38- stix_label
42+ parent_types
43+ spec_version
3944 name
4045 description
4146 roles
4247 contact_information
4348 x_opencti_aliases
4449 created
4550 modified
51+ objectLabel {
52+ edges {
53+ node {
54+ id
55+ value
56+ color
57+ }
58+ }
59+ }
4660 }
47- relation {
48- id
61+ ... on Organization {
62+ x_opencti_organization_type
63+ x_opencti_reliability
4964 }
50- }
51- markingDefinitions {
52- edges {
53- node {
54- id
55- entity_type
56- stix_id
57- definition_type
58- definition
59- level
60- color
61- created
62- modified
63- }
64- relation {
65- id
66- }
67- }
68- }
69- externalReferences {
70- edges {
71- node {
72- id
73- entity_type
74- stix_id
75- source_name
76- description
77- url
78- hash
79- external_id
80- created
81- modified
82- }
83- relation {
84- id
85- }
65+ ... on Individual {
66+ x_opencti_firstname
67+ x_opencti_lastname
8668 }
8769 }
8870 """
8971
9072 """
91- List stix_observable_relation objects
73+ List stix_observable_relationship objects
9274
9375 :param fromId: the id of the source entity of the relation
9476 :param toId: the id of the target entity of the relation
9577 :param relationship_type: the relation type
96- :param firstSeenStart : the first_seen date start filter
97- :param firstSeenStop : the first_seen date stop filter
98- :param lastSeenStart : the last_seen date start filter
99- :param lastSeenStop : the last_seen date stop filter
78+ :param startTimeStart : the first_seen date start filter
79+ :param startTimeStop : the first_seen date stop filter
80+ :param stopTimeStart : the last_seen date start filter
81+ :param stopTimeStop : the last_seen date stop filter
10082 :param first: return the first n rows from the after ID (or the beginning if not set)
10183 :param after: ID of the first row for pagination
102- :return List of stix_observable_relation objects
84+ :return List of stix_observable_relationship objects
10385 """
10486
10587 def list (self , ** kwargs ):
@@ -108,10 +90,10 @@ def list(self, **kwargs):
10890 to_id = kwargs .get ("toId" , None )
10991 to_types = kwargs .get ("toTypes" , None )
11092 relationship_type = kwargs .get ("relationship_type" , None )
111- first_seen_start = kwargs .get ("firstSeenStart " , None )
112- first_seen_stop = kwargs .get ("firstSeenStop " , None )
113- last_seen_start = kwargs .get ("lastSeenStart " , None )
114- last_seen_stop = kwargs .get ("lastSeenStop " , None )
93+ first_seen_start = kwargs .get ("startTimeStart " , None )
94+ first_seen_stop = kwargs .get ("startTimeStop " , None )
95+ last_seen_start = kwargs .get ("stopTimeStart " , None )
96+ last_seen_stop = kwargs .get ("stopTimeStop " , None )
11597 first = kwargs .get ("first" , 500 )
11698 after = kwargs .get ("after" , None )
11799 order_by = kwargs .get ("orderBy" , None )
@@ -123,7 +105,7 @@ def list(self, **kwargs):
123105
124106 self .opencti .log (
125107 "info" ,
126- "Listing stix_observable_relations with {type: "
108+ "Listing stix_observable_relationships with {type: "
127109 + str (relationship_type )
128110 + ", from_id: "
129111 + str (from_id )
@@ -133,8 +115,8 @@ def list(self, **kwargs):
133115 )
134116 query = (
135117 """
136- query StixCyberObservableRelations ($fromId: String, $fromTypes: [String], $toId: String, $toTypes: [String], $relationship_type: String, $firstSeenStart : DateTime, $firstSeenStop : DateTime, $lastSeenStart : DateTime, $lastSeenStop : DateTime, $first: Int, $after: ID, $orderBy: StixCyberObservableRelationsOrdering , $orderMode: OrderingMode) {
137- StixCyberObservableRelations (fromId: $fromId, fromTypes: $fromTypes, toId: $toId, toTypes: $toTypes, relationship_type: $relationship_type, firstSeenStart : $firstSeenStart, firstSeenStop : $firstSeenStop, lastSeenStart : $lastSeenStart, lastSeenStop : $lastSeenStop , first: $first, after: $after, orderBy: $orderBy, orderMode: $orderMode) {
118+ query StixCyberObservableRelationships ($fromId: String, $fromTypes: [String], $toId: String, $toTypes: [String], $relationship_type: String, $startTimeStart : DateTime, $startTimeStop : DateTime, $stopTimeStart : DateTime, $stopTimeStop : DateTime, $first: Int, $after: ID, $orderBy: StixCyberObservableRelationshipsOrdering , $orderMode: OrderingMode) {
119+ StixCyberObservableRelationships (fromId: $fromId, fromTypes: $fromTypes, toId: $toId, toTypes: $toTypes, relationship_type: $relationship_type, startTimeStart : $startTimeStart, startTimeStop : $startTimeStop, stopTimeStart : $stopTimeStart, stopTimeStop : $stopTimeStop , first: $first, after: $after, orderBy: $orderBy, orderMode: $orderMode) {
138120 edges {
139121 node {
140122 """
@@ -162,51 +144,53 @@ def list(self, **kwargs):
162144 "toId" : to_id ,
163145 "toTypes" : to_types ,
164146 "relationship_type" : relationship_type ,
165- "firstSeenStart " : first_seen_start ,
166- "firstSeenStop " : first_seen_stop ,
167- "lastSeenStart " : last_seen_start ,
168- "lastSeenStop " : last_seen_stop ,
147+ "Start " : first_seen_start ,
148+ "startTimeStop " : first_seen_stop ,
149+ "stopTimeStart " : last_seen_start ,
150+ "stopTimeStop " : last_seen_stop ,
169151 "first" : first ,
170152 "after" : after ,
171153 "orderBy" : order_by ,
172154 "orderMode" : order_mode ,
173155 },
174156 )
175157 return self .opencti .process_multiple (
176- result ["data" ]["StixCyberObservableRelations " ], with_pagination
158+ result ["data" ]["StixCyberObservableRelationships " ], with_pagination
177159 )
178160
179161 """
180- Read a stix_observable_relation object
162+ Read a stix_observable_relationship object
181163
182- :param id: the id of the stix_observable_relation
183- :param stix_id: the STIX id of the stix_observable_relation
164+ :param id: the id of the stix_observable_relationship
165+ :param stix_id: the STIX id of the stix_observable_relationship
184166 :param fromId: the id of the source entity of the relation
185167 :param toId: the id of the target entity of the relation
186168 :param relationship_type: the relation type
187- :param firstSeenStart : the first_seen date start filter
188- :param firstSeenStop : the first_seen date stop filter
189- :param lastSeenStart : the last_seen date start filter
190- :param lastSeenStop : the last_seen date stop filter
191- :return stix_observable_relation object
169+ :param startTimeStart : the first_seen date start filter
170+ :param startTimeStop : the first_seen date stop filter
171+ :param stopTimeStart : the last_seen date start filter
172+ :param stopTimeStop : the last_seen date stop filter
173+ :return stix_observable_relationship object
192174 """
193175
194176 def read (self , ** kwargs ):
195177 id = kwargs .get ("id" , None )
196178 from_id = kwargs .get ("fromId" , None )
197179 to_id = kwargs .get ("toId" , None )
198180 relationship_type = kwargs .get ("relationship_type" , None )
199- first_seen_start = kwargs .get ("firstSeenStart " , None )
200- first_seen_stop = kwargs .get ("firstSeenStop " , None )
201- last_seen_start = kwargs .get ("lastSeenStart " , None )
202- last_seen_stop = kwargs .get ("lastSeenStop " , None )
181+ first_seen_start = kwargs .get ("startTimeStart " , None )
182+ first_seen_stop = kwargs .get ("startTimeStop " , None )
183+ last_seen_start = kwargs .get ("stopTimeStart " , None )
184+ last_seen_stop = kwargs .get ("stopTimeStop " , None )
203185 custom_attributes = kwargs .get ("customAttributes" , None )
204186 if id is not None :
205- self .opencti .log ("info" , "Reading stix_observable_relation {" + id + "}." )
187+ self .opencti .log (
188+ "info" , "Reading stix_observable_relationship {" + id + "}."
189+ )
206190 query = (
207191 """
208- query StixCyberObservableRelation ($id: String!) {
209- StixCyberObservableRelation (id: $id) {
192+ query StixCyberObservableRelationship ($id: String!) {
193+ StixCyberObservableRelationship (id: $id) {
210194 """
211195 + (
212196 custom_attributes
@@ -220,28 +204,28 @@ def read(self, **kwargs):
220204 )
221205 result = self .opencti .query (query , {"id" : id })
222206 return self .opencti .process_multiple_fields (
223- result ["data" ]["StixCyberObservableRelation " ]
207+ result ["data" ]["StixCyberObservableRelationship " ]
224208 )
225209 else :
226210 result = self .list (
227211 fromId = from_id ,
228212 toId = to_id ,
229213 relationship_type = relationship_type ,
230- firstSeenStart = first_seen_start ,
231- firstSeenStop = first_seen_stop ,
232- lastSeenStart = last_seen_start ,
233- lastSeenStop = last_seen_stop ,
214+ startTimeStart = first_seen_start ,
215+ startTimeStop = first_seen_stop ,
216+ stopTimeStart = last_seen_start ,
217+ stopTimeStop = last_seen_stop ,
234218 )
235219 if len (result ) > 0 :
236220 return result [0 ]
237221 else :
238222 return None
239223
240224 """
241- Create a stix_observable_relation object
225+ Create a stix_observable_relationship object
242226
243227 :param from_id: id of the source entity
244- :return stix_observable_relation object
228+ :return stix_observable_relationship object
245229 """
246230
247231 def create (self , ** kwargs ):
@@ -251,11 +235,8 @@ def create(self, **kwargs):
251235 to_role = kwargs .get ("toRole" , None )
252236 relationship_type = kwargs .get ("relationship_type" , None )
253237 description = kwargs .get ("description" , None )
254- role_played = kwargs .get ("role_played" , None )
255- first_seen = kwargs .get ("first_seen" , None )
256- last_seen = kwargs .get ("last_seen" , None )
257- weight = kwargs .get ("weight" , None )
258- id = kwargs .get ("id" , None )
238+ start_time = kwargs .get ("start_time" , None )
239+ stop_time = kwargs .get ("stop_time" , None )
259240 stix_id = kwargs .get ("stix_id" , None )
260241 created = kwargs .get ("created" , None )
261242 modified = kwargs .get ("modified" , None )
@@ -265,7 +246,7 @@ def create(self, **kwargs):
265246
266247 self .opencti .log (
267248 "info" ,
268- "Creating stix_observable_relation {"
249+ "Creating stix_observable_relationship {"
269250 + from_role
270251 + ": "
271252 + from_id
@@ -276,10 +257,10 @@ def create(self, **kwargs):
276257 + "}." ,
277258 )
278259 query = """
279- mutation StixCyberObservableRelationAdd ($input: StixCyberObservableStixMetaRelationshipAddInput!) {
280- StixCyberObservableRelationAdd (input: $input) {
260+ mutation StixCyberObservableRelationshipAdd ($input: StixCyberObservableStixMetaRelationshipAddInput!) {
261+ StixCyberObservableRelationshipAdd (input: $input) {
281262 id
282- stix_id
263+ standard_id
283264 entity_type
284265 parent_types
285266 }
@@ -290,16 +271,11 @@ def create(self, **kwargs):
290271 {
291272 "input" : {
292273 "fromId" : from_id ,
293- "fromRole" : from_role ,
294274 "toId" : to_id ,
295- "toRole" : to_role ,
296275 "relationship_type" : relationship_type ,
297276 "description" : description ,
298- "role_played" : role_played ,
299- "first_seen" : first_seen ,
300- "last_seen" : last_seen ,
301- "weight" : weight ,
302- "internal_id_key" : id ,
277+ "start_time" : start_time ,
278+ "stop_time" : stop_time ,
303279 "stix_id" : stix_id ,
304280 "created" : created ,
305281 "modified" : modified ,
@@ -310,16 +286,16 @@ def create(self, **kwargs):
310286 },
311287 )
312288 return self .opencti .process_multiple_fields (
313- result ["data" ]["StixCyberObservableRelationAdd " ]
289+ result ["data" ]["StixCyberObservableRelationshipAdd " ]
314290 )
315291
316292 """
317- Update a stix_observable_relation object field
293+ Update a stix_observable_relationship object field
318294
319- :param id: the stix_observable_relation id
295+ :param id: the stix_observable_relationship id
320296 :param key: the key of the field
321297 :param value: the value of the field
322- :return The updated stix_observable_relation object
298+ :return The updated stix_observable_relationship object
323299 """
324300
325301 def update_field (self , ** kwargs ):
@@ -329,12 +305,16 @@ def update_field(self, **kwargs):
329305 if id is not None and key is not None and value is not None :
330306 self .opencti .log (
331307 "info" ,
332- "Updating stix_observable_relation {" + id + "} field {" + key + "}." ,
308+ "Updating stix_observable_relationship {"
309+ + id
310+ + "} field {"
311+ + key
312+ + "}." ,
333313 )
334314 query = (
335315 """
336- mutation StixCyberObservableRelationEdit ($id: ID!, $input: EditInput!) {
337- StixCyberObservableRelationEdit (id: $id) {
316+ mutation StixCyberObservableRelationshipEdit ($id: ID!, $input: EditInput!) {
317+ StixCyberObservableRelationshipEdit (id: $id) {
338318 fieldPatch(input: $input) {
339319 """
340320 + self .properties
@@ -348,7 +328,7 @@ def update_field(self, **kwargs):
348328 query , {"id" : id , "input" : {"key" : key , "value" : value }}
349329 )
350330 return self .opencti .process_multiple_fields (
351- result ["data" ]["StixCyberObservableRelationEdit " ]["fieldPatch" ]
331+ result ["data" ]["StixCyberObservableRelationshipEdit " ]["fieldPatch" ]
352332 )
353333 else :
354334 self .opencti .log ("error" , "Missing parameters: id and key and value" )
0 commit comments