joaopamaral commented on code in PR #40703:
URL: https://github.com/apache/airflow/pull/40703#discussion_r1675765214
##########
airflow/security/permissions.py:
##########
@@ -64,19 +67,38 @@
DEPRECATED_ACTION_CAN_DAG_READ = "can_dag_read"
DEPRECATED_ACTION_CAN_DAG_EDIT = "can_dag_edit"
-DAG_ACTIONS = {ACTION_CAN_READ, ACTION_CAN_EDIT, ACTION_CAN_DELETE}
+
+class ResourceDetails(TypedDict):
+ """Details of a resource (actions and prefix)."""
+
+ actions: set[str]
+ prefix: str
+
+
+RESOURCE_DETAILS_MAP = {
+ RESOURCE_DAG: ResourceDetails(
+ actions={ACTION_CAN_READ, ACTION_CAN_EDIT, ACTION_CAN_DELETE},
prefix=RESOURCE_DAG_PREFIX
+ ),
+ RESOURCE_DAG_RUN: ResourceDetails(
+ actions={ACTION_CAN_READ, ACTION_CAN_CREATE, ACTION_CAN_DELETE,
ACTION_CAN_ACCESS_MENU},
+ prefix=RESOURCE_DAG_RUN_PREFIX,
+ ),
+}
+PREFIX_RESOURCES_MAP = {
+ prefix: resource for resource, actions in RESOURCE_DETAILS_MAP.items() for
prefix in actions["prefix"]
+}
-def resource_name_for_dag(root_dag_id: str) -> str:
Review Comment:
Ok, I've readded the `DAG_ACTIONS` to keep the compatibility.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]