From ab070d77e3dd3a18676b45139572041f77879e67 Mon Sep 17 00:00:00 2001 From: Israel Lappe <79846863+ilappe@users.noreply.github.com> Date: Wed, 26 Feb 2025 16:47:34 +0200 Subject: [PATCH] Platform MP: support quickactions in graph (#4830) * add command quickaction * add script quick action * fix test * fix test * fix pre commit * fix test * changelog * CR changes * fix pre commit * script cant be a quickaction * fix pre commit --- .changelog/4830.yml | 4 ++++ demisto_sdk/commands/common/schemas/script.yml | 2 -- demisto_sdk/commands/content_graph/common.py | 1 + .../content_graph/interface/neo4j/queries/relationships.py | 3 ++- demisto_sdk/commands/content_graph/objects/integration.py | 2 ++ demisto_sdk/commands/content_graph/parsers/integration.py | 7 +++++++ .../commands/content_graph/strict_objects/script.py | 1 - .../content_graph/tests/create_content_graph_test.py | 1 + .../commands/content_graph/tests/graph_validator_test.py | 2 ++ .../content_graph/tests/update_content_graph_test.py | 2 ++ 10 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 .changelog/4830.yml diff --git a/.changelog/4830.yml b/.changelog/4830.yml new file mode 100644 index 00000000000..82f6da7d7c7 --- /dev/null +++ b/.changelog/4830.yml @@ -0,0 +1,4 @@ +changes: +- description: Update Graph objects to support the new quick action properties. + type: internal +pr_number: 4830 diff --git a/demisto_sdk/commands/common/schemas/script.yml b/demisto_sdk/commands/common/schemas/script.yml index 9d0eb14f495..01c902f279b 100644 --- a/demisto_sdk/commands/common/schemas/script.yml +++ b/demisto_sdk/commands/common/schemas/script.yml @@ -126,8 +126,6 @@ mapping: sequence: - type: str enum: ['script-name-incident-to-alert'] - quickaction: - type: bool prettyname: type: str diff --git a/demisto_sdk/commands/content_graph/common.py b/demisto_sdk/commands/content_graph/common.py index 3bad573cb78..30413630c96 100644 --- a/demisto_sdk/commands/content_graph/common.py +++ b/demisto_sdk/commands/content_graph/common.py @@ -346,6 +346,7 @@ class Relationship(BaseModel): description: Optional[str] = None deprecated: Optional[bool] = None name: Optional[str] = None + quickaction: Optional[bool] = None class Relationships(dict): diff --git a/demisto_sdk/commands/content_graph/interface/neo4j/queries/relationships.py b/demisto_sdk/commands/content_graph/interface/neo4j/queries/relationships.py index 8206a552372..9ffbe2a18b1 100644 --- a/demisto_sdk/commands/content_graph/interface/neo4j/queries/relationships.py +++ b/demisto_sdk/commands/content_graph/interface/neo4j/queries/relationships.py @@ -64,7 +64,8 @@ def build_has_command_relationships_query() -> str: // Create the relationship MERGE (integration)-[r:{RelationshipType.HAS_COMMAND}{{ deprecated: rel_data.deprecated, - description: rel_data.description + description: rel_data.description, + quickaction: rel_data.quickaction }}]->(cmd) RETURN count(r) AS relationships_merged""" diff --git a/demisto_sdk/commands/content_graph/objects/integration.py b/demisto_sdk/commands/content_graph/objects/integration.py index 42f305a8229..62e4d1f04e6 100644 --- a/demisto_sdk/commands/content_graph/objects/integration.py +++ b/demisto_sdk/commands/content_graph/objects/integration.py @@ -55,6 +55,7 @@ class IntegrationOutput(Output): class Command(BaseNode, content_type=ContentType.COMMAND): # type: ignore[call-arg] name: str + quickaction: bool = Field(False) # From HAS_COMMAND relationship args: List[Argument] = Field([], exclude=True) @@ -101,6 +102,7 @@ class Integration(IntegrationScript, content_type=ContentType.INTEGRATION): # t is_fetch: bool = Field(False, alias="isfetch") is_fetch_events: bool = Field(False, alias="isfetchevents") is_fetch_assets: bool = Field(False, alias="isfetchassets") + supports_quick_actions: bool = Field(False, alias="supportsquickactions") is_fetch_events_and_assets: bool = False is_fetch_samples: bool = False is_feed: bool = False diff --git a/demisto_sdk/commands/content_graph/parsers/integration.py b/demisto_sdk/commands/content_graph/parsers/integration.py index a2f297bee8e..0e3276b3508 100644 --- a/demisto_sdk/commands/content_graph/parsers/integration.py +++ b/demisto_sdk/commands/content_graph/parsers/integration.py @@ -24,6 +24,7 @@ class CommandParser: description: str args: List[dict] outputs: List[dict] + quickaction: bool class IntegrationParser(IntegrationScriptParser, content_type=ContentType.INTEGRATION): @@ -48,6 +49,9 @@ def __init__( self.is_fetch_samples = self.script_info.get("isFetchSamples", False) self.is_feed = self.script_info.get("feed", False) self.long_running = self.script_info.get("longRunning", False) + self.supports_quick_actions = self.script_info.get( + "supportsquickactions", False + ) self.commands: List[CommandParser] = [] self.connect_to_commands() self.connect_to_dependencies() @@ -90,6 +94,7 @@ def connect_to_commands(self) -> None: description = command_data.get("description") args = command_data.get("arguments") or [] outputs = command_data.get("outputs") or [] + quickaction = command_data.get("quickaction", False) self.add_relationship( RelationshipType.HAS_COMMAND, target=name, @@ -97,6 +102,7 @@ def connect_to_commands(self) -> None: name=name, deprecated=deprecated, description=description, + quickaction=quickaction, ) self.commands.append( CommandParser( @@ -105,6 +111,7 @@ def connect_to_commands(self) -> None: deprecated=deprecated, args=args, outputs=outputs, + quickaction=quickaction, ) ) diff --git a/demisto_sdk/commands/content_graph/strict_objects/script.py b/demisto_sdk/commands/content_graph/strict_objects/script.py index 0eecbb2e0cd..3d4c45e32a7 100644 --- a/demisto_sdk/commands/content_graph/strict_objects/script.py +++ b/demisto_sdk/commands/content_graph/strict_objects/script.py @@ -88,7 +88,6 @@ class _StrictScript(BaseIntegrationScript): # type:ignore[misc,valid-type] polling: Optional[bool] = None skip_prepare: Optional[List[SkipPrepare]] = Field(None, alias="skipprepare") prettyname: Optional[str] = None - quickaction: Optional[bool] = None StrictScript = create_model( diff --git a/demisto_sdk/commands/content_graph/tests/create_content_graph_test.py b/demisto_sdk/commands/content_graph/tests/create_content_graph_test.py index 536679da348..8d0b946fc81 100644 --- a/demisto_sdk/commands/content_graph/tests/create_content_graph_test.py +++ b/demisto_sdk/commands/content_graph/tests/create_content_graph_test.py @@ -410,6 +410,7 @@ def build_in_pack_relationship( ContentType.COMMAND, description="", deprecated=False, + quickaction=False, ), ) diff --git a/demisto_sdk/commands/content_graph/tests/graph_validator_test.py b/demisto_sdk/commands/content_graph/tests/graph_validator_test.py index 27bbb31fcbc..6fca5f86d0c 100644 --- a/demisto_sdk/commands/content_graph/tests/graph_validator_test.py +++ b/demisto_sdk/commands/content_graph/tests/graph_validator_test.py @@ -104,6 +104,7 @@ def repository(mocker) -> ContentDTO: name="test-command", description="", deprecated=False, + quickaction=False, ), mock_relationship( "SampleIntegration", @@ -117,6 +118,7 @@ def repository(mocker) -> ContentDTO: name="deprecated-command", description="", deprecated=True, + quickaction=False, ), ], RelationshipType.IMPORTS: [ diff --git a/demisto_sdk/commands/content_graph/tests/update_content_graph_test.py b/demisto_sdk/commands/content_graph/tests/update_content_graph_test.py index fa74d8079fb..ae663f7025d 100644 --- a/demisto_sdk/commands/content_graph/tests/update_content_graph_test.py +++ b/demisto_sdk/commands/content_graph/tests/update_content_graph_test.py @@ -96,6 +96,7 @@ def repository(mocker) -> ContentDTO: name="test-command", description="", deprecated=False, + quickaction=False, ) ], RelationshipType.IMPORTS: [ @@ -455,6 +456,7 @@ def _testcase4__new_integration_with_existing_command( name="test-command", description="", deprecated=False, + quickaction=False, ) ) return [pack]