Implement the "remove_label" function for the "stix_core_relationship" #754
Labels
feature
use for describing a new feature to develop
needs triage
use to identify issue needing triage from Filigran Product team
Problem to Solve
stix_core_relationship does not have any remove_label function as there is for stix_cyber_observable and stix_domain_object despite having the same add_label function.
Current Workaround
Use GraphQL query
Proposed Solution
Implement the function in the python client. This is what the function could be:
if label_name is not None: label = self.client.label.read( filters={ "mode": "and", "filters": [{"key": "value", "values": [label_name]}], "filterGroups": [], } ) if label: label_id = label["id"] if rel_id is not None and label_id is not None: self.client.app_logger.info( "Removing label from Stix-Core-Relationship", {"label_id": label_id, "id": id}, ) query = """ mutation StixCoreRelationshipLabelsViewRelationDeleteMutation($id: ID!, $toId: StixRef!, $relationship_type: String!) { stixCoreRelationshipEdit(id: $id) { relationDelete(toId: $toId, relationship_type: $relationship_type) { objectLabel { id value color } id } } } """ self.client.query( query, { "id": id, "toId": label_id, "relationship_type": "object-label", }, ) else: self.client.app_logger.error("Missing parameters: id and label_id")
The text was updated successfully, but these errors were encountered: