Skip to content

Commit

Permalink
Platform MP: support quickactions in graph (#4830)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ilappe authored Feb 26, 2025
1 parent 89b5180 commit ab070d7
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .changelog/4830.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Update Graph objects to support the new quick action properties.
type: internal
pr_number: 4830
2 changes: 0 additions & 2 deletions demisto_sdk/commands/common/schemas/script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ mapping:
sequence:
- type: str
enum: ['script-name-incident-to-alert']
quickaction:
type: bool
prettyname:
type: str

Expand Down
1 change: 1 addition & 0 deletions demisto_sdk/commands/content_graph/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
2 changes: 2 additions & 0 deletions demisto_sdk/commands/content_graph/objects/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions demisto_sdk/commands/content_graph/parsers/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CommandParser:
description: str
args: List[dict]
outputs: List[dict]
quickaction: bool


class IntegrationParser(IntegrationScriptParser, content_type=ContentType.INTEGRATION):
Expand All @@ -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()
Expand Down Expand Up @@ -90,13 +94,15 @@ 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,
target_type=ContentType.COMMAND,
name=name,
deprecated=deprecated,
description=description,
quickaction=quickaction,
)
self.commands.append(
CommandParser(
Expand All @@ -105,6 +111,7 @@ def connect_to_commands(self) -> None:
deprecated=deprecated,
args=args,
outputs=outputs,
quickaction=quickaction,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ def build_in_pack_relationship(
ContentType.COMMAND,
description="",
deprecated=False,
quickaction=False,
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def repository(mocker) -> ContentDTO:
name="test-command",
description="",
deprecated=False,
quickaction=False,
),
mock_relationship(
"SampleIntegration",
Expand All @@ -117,6 +118,7 @@ def repository(mocker) -> ContentDTO:
name="deprecated-command",
description="",
deprecated=True,
quickaction=False,
),
],
RelationshipType.IMPORTS: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def repository(mocker) -> ContentDTO:
name="test-command",
description="",
deprecated=False,
quickaction=False,
)
],
RelationshipType.IMPORTS: [
Expand Down Expand Up @@ -455,6 +456,7 @@ def _testcase4__new_integration_with_existing_command(
name="test-command",
description="",
deprecated=False,
quickaction=False,
)
)
return [pack]
Expand Down

0 comments on commit ab070d7

Please sign in to comment.