Skip to content

Commit ab070d7

Browse files
authored
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
1 parent 89b5180 commit ab070d7

File tree

10 files changed

+21
-4
lines changed

10 files changed

+21
-4
lines changed

.changelog/4830.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
changes:
2+
- description: Update Graph objects to support the new quick action properties.
3+
type: internal
4+
pr_number: 4830

demisto_sdk/commands/common/schemas/script.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ mapping:
126126
sequence:
127127
- type: str
128128
enum: ['script-name-incident-to-alert']
129-
quickaction:
130-
type: bool
131129
prettyname:
132130
type: str
133131

demisto_sdk/commands/content_graph/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ class Relationship(BaseModel):
346346
description: Optional[str] = None
347347
deprecated: Optional[bool] = None
348348
name: Optional[str] = None
349+
quickaction: Optional[bool] = None
349350

350351

351352
class Relationships(dict):

demisto_sdk/commands/content_graph/interface/neo4j/queries/relationships.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def build_has_command_relationships_query() -> str:
6464
// Create the relationship
6565
MERGE (integration)-[r:{RelationshipType.HAS_COMMAND}{{
6666
deprecated: rel_data.deprecated,
67-
description: rel_data.description
67+
description: rel_data.description,
68+
quickaction: rel_data.quickaction
6869
}}]->(cmd)
6970
7071
RETURN count(r) AS relationships_merged"""

demisto_sdk/commands/content_graph/objects/integration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class IntegrationOutput(Output):
5555

5656
class Command(BaseNode, content_type=ContentType.COMMAND): # type: ignore[call-arg]
5757
name: str
58+
quickaction: bool = Field(False)
5859

5960
# From HAS_COMMAND relationship
6061
args: List[Argument] = Field([], exclude=True)
@@ -101,6 +102,7 @@ class Integration(IntegrationScript, content_type=ContentType.INTEGRATION): # t
101102
is_fetch: bool = Field(False, alias="isfetch")
102103
is_fetch_events: bool = Field(False, alias="isfetchevents")
103104
is_fetch_assets: bool = Field(False, alias="isfetchassets")
105+
supports_quick_actions: bool = Field(False, alias="supportsquickactions")
104106
is_fetch_events_and_assets: bool = False
105107
is_fetch_samples: bool = False
106108
is_feed: bool = False

demisto_sdk/commands/content_graph/parsers/integration.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class CommandParser:
2424
description: str
2525
args: List[dict]
2626
outputs: List[dict]
27+
quickaction: bool
2728

2829

2930
class IntegrationParser(IntegrationScriptParser, content_type=ContentType.INTEGRATION):
@@ -48,6 +49,9 @@ def __init__(
4849
self.is_fetch_samples = self.script_info.get("isFetchSamples", False)
4950
self.is_feed = self.script_info.get("feed", False)
5051
self.long_running = self.script_info.get("longRunning", False)
52+
self.supports_quick_actions = self.script_info.get(
53+
"supportsquickactions", False
54+
)
5155
self.commands: List[CommandParser] = []
5256
self.connect_to_commands()
5357
self.connect_to_dependencies()
@@ -90,13 +94,15 @@ def connect_to_commands(self) -> None:
9094
description = command_data.get("description")
9195
args = command_data.get("arguments") or []
9296
outputs = command_data.get("outputs") or []
97+
quickaction = command_data.get("quickaction", False)
9398
self.add_relationship(
9499
RelationshipType.HAS_COMMAND,
95100
target=name,
96101
target_type=ContentType.COMMAND,
97102
name=name,
98103
deprecated=deprecated,
99104
description=description,
105+
quickaction=quickaction,
100106
)
101107
self.commands.append(
102108
CommandParser(
@@ -105,6 +111,7 @@ def connect_to_commands(self) -> None:
105111
deprecated=deprecated,
106112
args=args,
107113
outputs=outputs,
114+
quickaction=quickaction,
108115
)
109116
)
110117

demisto_sdk/commands/content_graph/strict_objects/script.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class _StrictScript(BaseIntegrationScript): # type:ignore[misc,valid-type]
8888
polling: Optional[bool] = None
8989
skip_prepare: Optional[List[SkipPrepare]] = Field(None, alias="skipprepare")
9090
prettyname: Optional[str] = None
91-
quickaction: Optional[bool] = None
9291

9392

9493
StrictScript = create_model(

demisto_sdk/commands/content_graph/tests/create_content_graph_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ def build_in_pack_relationship(
410410
ContentType.COMMAND,
411411
description="",
412412
deprecated=False,
413+
quickaction=False,
413414
),
414415
)
415416

demisto_sdk/commands/content_graph/tests/graph_validator_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def repository(mocker) -> ContentDTO:
104104
name="test-command",
105105
description="",
106106
deprecated=False,
107+
quickaction=False,
107108
),
108109
mock_relationship(
109110
"SampleIntegration",
@@ -117,6 +118,7 @@ def repository(mocker) -> ContentDTO:
117118
name="deprecated-command",
118119
description="",
119120
deprecated=True,
121+
quickaction=False,
120122
),
121123
],
122124
RelationshipType.IMPORTS: [

demisto_sdk/commands/content_graph/tests/update_content_graph_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def repository(mocker) -> ContentDTO:
9696
name="test-command",
9797
description="",
9898
deprecated=False,
99+
quickaction=False,
99100
)
100101
],
101102
RelationshipType.IMPORTS: [
@@ -455,6 +456,7 @@ def _testcase4__new_integration_with_existing_command(
455456
name="test-command",
456457
description="",
457458
deprecated=False,
459+
quickaction=False,
458460
)
459461
)
460462
return [pack]

0 commit comments

Comments
 (0)