@@ -536,6 +536,7 @@ def update_field(self, **kwargs):
536536 id = kwargs .get ("id" , None )
537537 key = kwargs .get ("key" , None )
538538 value = kwargs .get ("value" , None )
539+ operation = kwargs .get ("operation" , "replace" )
539540 if isinstance (value , list ):
540541 value = [str (v ) for v in value ]
541542 else :
@@ -546,9 +547,9 @@ def update_field(self, **kwargs):
546547 "Updating stix_core_relationship {" + id + "} field {" + key + "}." ,
547548 )
548549 query = """
549- mutation StixCoreRelationshipEdit($id: ID!, $input: EditInput!) {
550+ mutation StixCoreRelationshipEdit($id: ID!, $input: EditInput!, $operation: EditOperation ) {
550551 stixCoreRelationshipEdit(id: $id) {
551- fieldPatch(input: $input) {
552+ fieldPatch(input: $input, operation: $operation ) {
552553 id
553554 standard_id
554555 entity_type
@@ -557,7 +558,11 @@ def update_field(self, **kwargs):
557558 }
558559 """
559560 result = self .opencti .query (
560- query , {"id" : id , "input" : {"key" : key , "value" : value }}
561+ query , {
562+ "id" : id ,
563+ "input" : {"key" : key , "value" : value },
564+ "operation" : operation
565+ }
561566 )
562567 return self .opencti .process_multiple_fields (
563568 result ["data" ]["stixCoreRelationshipEdit" ]["fieldPatch" ]
@@ -1068,16 +1073,8 @@ def import_from_stix2(self, **kwargs):
10681073 stix_relation ["relationship_type" ] = "part-of"
10691074 elif stix_relation ["relationship_type" ] == "localization" :
10701075 stix_relation ["relationship_type" ] = "located-at"
1071- source_ref = (
1072- stix_relation ["x_opencti_source_ref" ]
1073- if "x_opencti_source_ref" in stix_relation
1074- else stix_relation ["source_ref" ]
1075- )
1076- target_ref = (
1077- stix_relation ["x_opencti_target_ref" ]
1078- if "x_opencti_target_ref" in stix_relation
1079- else stix_relation ["target_ref" ]
1080- )
1076+ source_ref = stix_relation ["source_ref" ]
1077+ target_ref = stix_relation ["target_ref" ]
10811078 return self .create (
10821079 fromId = source_ref ,
10831080 toId = target_ref ,
0 commit comments